solving review issues

This commit is contained in:
ingmargoudt 2017-02-16 14:03:25 +01:00
parent 570c2c2c5d
commit 14c459b924
8 changed files with 15 additions and 15 deletions

View file

@ -39,7 +39,7 @@ import mage.watchers.Watcher;
/** /**
* @author jeffwadsworth * @author jeffwadsworth
* <p> *
* Amount of damage received by a player this turn * Amount of damage received by a player this turn
*/ */
public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher { public class AmountOfDamageAPlayerReceivedThisTurnWatcher extends Watcher {

View file

@ -61,7 +61,7 @@ public class CardsAmountDrawnThisTurnWatcher extends Watcher {
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DREW_CARD) { if (event.getType() == GameEvent.EventType.DREW_CARD) {
amountOfCardsDrawnThisTurn.putIfAbsent(event.getPlayerId(), 0); 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) { public int getAmountCardsDrawn(UUID playerId) {
return amountOfCardsDrawnThisTurn.getOrDefault(playerId,0); return amountOfCardsDrawnThisTurn.getOrDefault(playerId, 0);
} }
@Override @Override

View file

@ -41,7 +41,7 @@ import mage.watchers.Watcher;
/** /**
* @author LevelX2 * @author LevelX2
* <p> *
* Counts cards drawn during draw step * Counts cards drawn during draw step
*/ */

View file

@ -90,7 +90,7 @@ public class CastSpellLastTurnWatcher extends Watcher {
} }
public int getAmountOfSpellsAllPlayersCastOnCurrentTurn() { public int getAmountOfSpellsAllPlayersCastOnCurrentTurn() {
return amountOfSpellsCastOnCurrentTurn.values().stream().mapToInt(Integer::intValue).sum(); return amountOfSpellsCastOnCurrentTurn.values().stream().reduce(0, Integer::sum);
} }
public int getAmountOfSpellsPlayerCastOnCurrentTurn(UUID playerId) { public int getAmountOfSpellsPlayerCastOnCurrentTurn(UUID playerId) {

View file

@ -77,7 +77,7 @@ public class CommanderInfoWatcher extends Watcher {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage()) { if (damageEvent.isCombatDamage()) {
UUID playerUUID = event.getTargetId(); UUID playerUUID = event.getTargetId();
Integer damage = damageToPlayer.getOrDefault(playerUUID,0); Integer damage = damageToPlayer.getOrDefault(playerUUID, 0);
damage += damageEvent.getAmount(); damage += damageEvent.getAmount();
damageToPlayer.put(playerUUID, damage); damageToPlayer.put(playerUUID, damage);
Player player = game.getPlayer(playerUUID); Player player = game.getPlayer(playerUUID);

View file

@ -75,9 +75,9 @@ public class MiracleWatcher extends Watcher {
if (game.getPhase() != null && event.getType() == GameEvent.EventType.DREW_CARD) { if (game.getPhase() != null && event.getType() == GameEvent.EventType.DREW_CARD) {
UUID playerId = event.getPlayerId(); UUID playerId = event.getPlayerId();
if (playerId != null) { if (playerId != null) {
amountOfCardsDrawnThisTurn.putIfAbsent(playerId, 0); Integer amount = 1 + amountOfCardsDrawnThisTurn.getOrDefault(playerId, 0);
amountOfCardsDrawnThisTurn.compute(playerId, (p, amount) -> amount + 1); amountOfCardsDrawnThisTurn.put(playerId, amount);
if (amountOfCardsDrawnThisTurn.get(playerId) == 1) { if (amount == 1) {
checkMiracleAbility(event, game); checkMiracleAbility(event, game);
} }
} }

View file

@ -31,20 +31,20 @@ package mage.watchers.common;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import mage.constants.WatcherScope; import mage.constants.WatcherScope;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.watchers.Watcher; import mage.watchers.Watcher;
/** /**
*
* @author LevelX2 * @author LevelX2
*/ */
public class PlayerAttackedWatcher extends Watcher { public class PlayerAttackedWatcher extends Watcher {
// With how many creatures attacked this player this turn // With how many creatures attacked this player this turn
private final Map<UUID,Integer> playerAttacked = new HashMap<>(); private final Map<UUID, Integer> playerAttacked = new HashMap<>();
public PlayerAttackedWatcher() { public PlayerAttackedWatcher() {
super("PlayerAttackedWatcher", WatcherScope.GAME); super("PlayerAttackedWatcher", WatcherScope.GAME);
@ -52,7 +52,7 @@ public class PlayerAttackedWatcher extends Watcher {
public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) { public PlayerAttackedWatcher(final PlayerAttackedWatcher watcher) {
super(watcher); super(watcher);
for (Map.Entry<UUID,Integer> entry: watcher.playerAttacked.entrySet()) { for (Map.Entry<UUID, Integer> entry : watcher.playerAttacked.entrySet()) {
this.playerAttacked.put(entry.getKey(), entry.getValue()); this.playerAttacked.put(entry.getKey(), entry.getValue());
} }
@ -67,7 +67,7 @@ public class PlayerAttackedWatcher extends Watcher {
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) { if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
playerAttacked.putIfAbsent(event.getPlayerId(), 0); playerAttacked.putIfAbsent(event.getPlayerId(), 0);
playerAttacked.compute(event.getPlayerId(), (p,amount)->amount + 1); playerAttacked.compute(event.getPlayerId(), (p, amount) -> amount + 1);
} }
} }

View file

@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import mage.constants.WatcherScope; import mage.constants.WatcherScope;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
@ -39,7 +40,6 @@ import mage.watchers.Watcher;
/** /**
* Counts amount of life gained during the current turn by players. * Counts amount of life gained during the current turn by players.
* *
*
* @author LevelX2 * @author LevelX2
*/ */
public class PlayerGainedLifeWatcher extends Watcher { public class PlayerGainedLifeWatcher extends Watcher {
@ -66,7 +66,7 @@ public class PlayerGainedLifeWatcher extends Watcher {
UUID playerId = event.getPlayerId(); UUID playerId = event.getPlayerId();
if (playerId != null) { if (playerId != null) {
amountOfLifeGainedThisTurn.putIfAbsent(playerId, 0); amountOfLifeGainedThisTurn.putIfAbsent(playerId, 0);
amountOfLifeGainedThisTurn.compute(playerId, (p, amount) -> amount +event.getAmount()); amountOfLifeGainedThisTurn.compute(playerId, (p, amount) -> amount + event.getAmount());
} }
} }
} }