From 14c459b9242e8d64d9206c7c7a6f477783dc54e3 Mon Sep 17 00:00:00 2001 From: ingmargoudt Date: Thu, 16 Feb 2017 14:03:25 +0100 Subject: [PATCH] solving review issues --- .../AmountOfDamageAPlayerReceivedThisTurnWatcher.java | 2 +- .../watchers/common/CardsAmountDrawnThisTurnWatcher.java | 4 ++-- .../watchers/common/CardsDrawnDuringDrawStepWatcher.java | 2 +- .../mage/watchers/common/CastSpellLastTurnWatcher.java | 2 +- .../java/mage/watchers/common/CommanderInfoWatcher.java | 2 +- .../main/java/mage/watchers/common/MiracleWatcher.java | 6 +++--- .../java/mage/watchers/common/PlayerAttackedWatcher.java | 8 ++++---- .../mage/watchers/common/PlayerGainedLifeWatcher.java | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java index 23a4884150..e372d8d612 100644 --- a/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/AmountOfDamageAPlayerReceivedThisTurnWatcher.java @@ -39,7 +39,7 @@ import mage.watchers.Watcher; /** * @author jeffwadsworth - *

+ * * Amount of damage received by a player this turn */ public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher { diff --git a/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java index ad0f8568d6..39fc825179 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsAmountDrawnThisTurnWatcher.java @@ -61,7 +61,7 @@ public class CardsAmountDrawnThisTurnWatcher extends Watcher { public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.DREW_CARD) { amountOfCardsDrawnThisTurn.putIfAbsent(event.getPlayerId(), 0); - amountOfCardsDrawnThisTurn.compute(event.getPlayerId(), (k, amount) -> amount += 1); + amountOfCardsDrawnThisTurn.compute(event.getPlayerId(), (k, amount) -> amount + 1); } } @@ -86,7 +86,7 @@ public class CardsAmountDrawnThisTurnWatcher extends Watcher { } public int getAmountCardsDrawn(UUID playerId) { - return amountOfCardsDrawnThisTurn.getOrDefault(playerId,0); + return amountOfCardsDrawnThisTurn.getOrDefault(playerId, 0); } @Override diff --git a/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java b/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java index 8f213a336d..59e9a91b77 100644 --- a/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CardsDrawnDuringDrawStepWatcher.java @@ -41,7 +41,7 @@ import mage.watchers.Watcher; /** * @author LevelX2 - *

+ * * Counts cards drawn during draw step */ diff --git a/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java b/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java index 17e204b339..27193a9dda 100644 --- a/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CastSpellLastTurnWatcher.java @@ -90,7 +90,7 @@ public class CastSpellLastTurnWatcher extends Watcher { } public int getAmountOfSpellsAllPlayersCastOnCurrentTurn() { - return amountOfSpellsCastOnCurrentTurn.values().stream().mapToInt(Integer::intValue).sum(); + return amountOfSpellsCastOnCurrentTurn.values().stream().reduce(0, Integer::sum); } public int getAmountOfSpellsPlayerCastOnCurrentTurn(UUID playerId) { diff --git a/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java b/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java index 769484331b..f6784b84c9 100644 --- a/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/CommanderInfoWatcher.java @@ -77,7 +77,7 @@ public class CommanderInfoWatcher extends Watcher { DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; if (damageEvent.isCombatDamage()) { UUID playerUUID = event.getTargetId(); - Integer damage = damageToPlayer.getOrDefault(playerUUID,0); + Integer damage = damageToPlayer.getOrDefault(playerUUID, 0); damage += damageEvent.getAmount(); damageToPlayer.put(playerUUID, damage); Player player = game.getPlayer(playerUUID); diff --git a/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java b/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java index f5ff489e4b..a3a966bd78 100644 --- a/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/MiracleWatcher.java @@ -75,9 +75,9 @@ public class MiracleWatcher extends Watcher { if (game.getPhase() != null && event.getType() == GameEvent.EventType.DREW_CARD) { UUID playerId = event.getPlayerId(); if (playerId != null) { - amountOfCardsDrawnThisTurn.putIfAbsent(playerId, 0); - amountOfCardsDrawnThisTurn.compute(playerId, (p, amount) -> amount + 1); - if (amountOfCardsDrawnThisTurn.get(playerId) == 1) { + Integer amount = 1 + amountOfCardsDrawnThisTurn.getOrDefault(playerId, 0); + amountOfCardsDrawnThisTurn.put(playerId, amount); + if (amount == 1) { checkMiracleAbility(event, game); } } diff --git a/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java index 96e1f89209..434cbb2dc9 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerAttackedWatcher.java @@ -31,20 +31,20 @@ package mage.watchers.common; import java.util.HashMap; import java.util.Map; import java.util.UUID; + import mage.constants.WatcherScope; import mage.game.Game; import mage.game.events.GameEvent; import mage.watchers.Watcher; /** - * * @author LevelX2 */ public class PlayerAttackedWatcher extends Watcher { // With how many creatures attacked this player this turn - private final Map playerAttacked = new HashMap<>(); + private final Map playerAttacked = new HashMap<>(); public PlayerAttackedWatcher() { super("PlayerAttackedWatcher", WatcherScope.GAME); @@ -52,7 +52,7 @@ public class PlayerAttackedWatcher extends Watcher { public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) { super(watcher); - for (Map.Entry entry: watcher.playerAttacked.entrySet()) { + for (Map.Entry entry : watcher.playerAttacked.entrySet()) { this.playerAttacked.put(entry.getKey(), entry.getValue()); } @@ -67,7 +67,7 @@ public class PlayerAttackedWatcher extends Watcher { public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) { playerAttacked.putIfAbsent(event.getPlayerId(), 0); - playerAttacked.compute(event.getPlayerId(), (p,amount)->amount + 1); + playerAttacked.compute(event.getPlayerId(), (p, amount) -> amount + 1); } } diff --git a/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java index f3e9039c39..8e9839e3fa 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerGainedLifeWatcher.java @@ -31,6 +31,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; + import mage.constants.WatcherScope; import mage.game.Game; import mage.game.events.GameEvent; @@ -39,7 +40,6 @@ import mage.watchers.Watcher; /** * Counts amount of life gained during the current turn by players. * - * * @author LevelX2 */ public class PlayerGainedLifeWatcher extends Watcher { @@ -66,7 +66,7 @@ public class PlayerGainedLifeWatcher extends Watcher { UUID playerId = event.getPlayerId(); if (playerId != null) { amountOfLifeGainedThisTurn.putIfAbsent(playerId, 0); - amountOfLifeGainedThisTurn.compute(playerId, (p, amount) -> amount +event.getAmount()); + amountOfLifeGainedThisTurn.compute(playerId, (p, amount) -> amount + event.getAmount()); } } }