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,47 @@
package mage.cards.f;
import mage.abilities.dynamicvalue.common.CardsDrawnThisTurnDynamicValue;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.abilities.effects.common.continuous.BoostTargetEffect;
import mage.abilities.effects.common.continuous.GainAbilityTargetEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.CardsDrawnThisTurnWatcher;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class FistsOfFlame extends CardImpl {
public FistsOfFlame(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{R}");
// Draw a card. Until end of turn, target creature gains trample and gets +1/+0 for each card you've drawn this turn.
this.getSpellAbility().addEffect(new DrawCardSourceControllerEffect(1));
this.getSpellAbility().addEffect(new GainAbilityTargetEffect(
TrampleAbility.getInstance(), Duration.EndOfTurn
).setText("Until end of turn, target creature gains trample"));
this.getSpellAbility().addEffect(new BoostTargetEffect(
CardsDrawnThisTurnDynamicValue.instance,
StaticValue.getZeroValue(), Duration.EndOfTurn
).setText("and gets +1/+0 for each card you've drawn this turn."));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
this.getSpellAbility().addWatcher(new CardsDrawnThisTurnWatcher());
}
private FistsOfFlame(final FistsOfFlame card) {
super(card);
}
@Override
public FistsOfFlame copy() {
return new FistsOfFlame(this);
}
}

View file

@ -1,13 +1,9 @@
package mage.cards.k;
import java.util.*;
import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.dynamicvalue.common.CardsDrawnThisTurnDynamicValue;
import mage.abilities.keyword.PartnerAbility;
import mage.abilities.mana.DynamicManaAbility;
import mage.cards.CardImpl;
@ -15,13 +11,11 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
import mage.watchers.common.CardsDrawnThisTurnWatcher;
import java.util.UUID;
/**
*
* @author spjspj
*/
public final class KydeleChosenOfKruphix extends CardImpl {
@ -36,14 +30,16 @@ public final class KydeleChosenOfKruphix extends CardImpl {
this.toughness = new MageInt(3);
// {T}: Add {C} for each card you've drawn this turn.
DynamicManaAbility ability = new DynamicManaAbility(Mana.ColorlessMana(1), new CardsDrawnThisTurnDynamicValue(), new TapSourceCost());
this.addAbility(ability, new KydeleCardsDrawnThisTurnWatcher());
DynamicManaAbility ability = new DynamicManaAbility(
Mana.ColorlessMana(1), CardsDrawnThisTurnDynamicValue.instance, new TapSourceCost()
);
this.addAbility(ability, new CardsDrawnThisTurnWatcher());
// Partner
this.addAbility(PartnerAbility.getInstance());
}
public KydeleChosenOfKruphix(final KydeleChosenOfKruphix card) {
private KydeleChosenOfKruphix(final KydeleChosenOfKruphix card) {
super(card);
}
@ -52,68 +48,3 @@ public final class KydeleChosenOfKruphix extends CardImpl {
return new KydeleChosenOfKruphix(this);
}
}
class CardsDrawnThisTurnDynamicValue implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
KydeleCardsDrawnThisTurnWatcher watcher = game.getState().getWatcher(KydeleCardsDrawnThisTurnWatcher.class);
if(watcher != null) {
return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId());
}
return 0;
}
@Override
public CardsDrawnThisTurnDynamicValue copy() {
return new CardsDrawnThisTurnDynamicValue();
}
@Override
public String toString() {
return "1";
}
@Override
public String getMessage() {
return "card you've drawn this turn";
}
}
class KydeleCardsDrawnThisTurnWatcher extends Watcher {
private final Map<UUID, Integer> cardsDrawnThisTurn = new HashMap<>();
public KydeleCardsDrawnThisTurnWatcher() {
super(WatcherScope.GAME);
}
public KydeleCardsDrawnThisTurnWatcher(final KydeleCardsDrawnThisTurnWatcher 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 KydeleCardsDrawnThisTurnWatcher copy() {
return new KydeleCardsDrawnThisTurnWatcher(this);
}
}

View file

@ -51,6 +51,7 @@ public final class ModernHorizons extends ExpansionSet {
cards.add(new SetCardInfo("Feaster of Fools", 90, Rarity.UNCOMMON, mage.cards.f.FeasterOfFools.class));
cards.add(new SetCardInfo("Fiery Islet", 238, Rarity.RARE, mage.cards.f.FieryIslet.class));
cards.add(new SetCardInfo("Firebolt", 122, Rarity.UNCOMMON, mage.cards.f.Firebolt.class));
cards.add(new SetCardInfo("Fists of Flame", 123, Rarity.COMMON, mage.cards.f.FistsOfFlame.class));
cards.add(new SetCardInfo("Flusterstorm", 255, Rarity.RARE, mage.cards.f.Flusterstorm.class));
cards.add(new SetCardInfo("Force of Despair", 92, Rarity.RARE, mage.cards.f.ForceOfDespair.class));
cards.add(new SetCardInfo("Force of Negation", 52, Rarity.RARE, mage.cards.f.ForceOfNegation.class));

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