Implemented Fists of Flame

This commit is contained in:
Evan Kranzler 2019-05-25 10:00:15 -04:00
parent f5432dd0eb
commit b5f96cacc9
5 changed files with 148 additions and 78 deletions

View file

@ -0,0 +1,39 @@
package mage.abilities.dynamicvalue.common;
import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import mage.watchers.common.CardsDrawnThisTurnWatcher;
/**
* @author TheElk801
*/
public enum CardsDrawnThisTurnDynamicValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
CardsDrawnThisTurnWatcher watcher = game.getState().getWatcher(CardsDrawnThisTurnWatcher.class);
if (watcher != null) {
return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId());
}
return 0;
}
@Override
public CardsDrawnThisTurnDynamicValue copy() {
return instance;
}
@Override
public String toString() {
return "1";
}
@Override
public String getMessage() {
return "card you've drawn this turn";
}
}

View file

@ -0,0 +1,52 @@
package mage.watchers.common;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author TheElk801
*/
public class CardsDrawnThisTurnWatcher extends Watcher {
private final Map<UUID, Integer> cardsDrawnThisTurn = new HashMap<>();
public CardsDrawnThisTurnWatcher() {
super(WatcherScope.GAME);
}
private CardsDrawnThisTurnWatcher(final CardsDrawnThisTurnWatcher watcher) {
super(watcher);
this.cardsDrawnThisTurn.putAll(watcher.cardsDrawnThisTurn);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DREW_CARD) {
int cardsDrawn = getCardsDrawnThisTurn(event.getPlayerId());
cardsDrawnThisTurn.put(event.getPlayerId(), cardsDrawn + 1);
}
}
public int getCardsDrawnThisTurn(UUID playerId) {
return cardsDrawnThisTurn.getOrDefault(playerId, 0);
}
@Override
public void reset() {
super.reset();
cardsDrawnThisTurn.clear();
}
@Override
public CardsDrawnThisTurnWatcher copy() {
return new CardsDrawnThisTurnWatcher(this);
}
}