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);
} }
} }

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

@ -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,13 +31,13 @@ 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
*/ */

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 {