[CMR] Implemented Thalisse, Reverent Medium

This commit is contained in:
Evan Kranzler 2020-10-30 20:56:44 -04:00
parent f234dd47e0
commit eca77e3347
2 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1,108 @@
package mage.cards.t;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.hint.Hint;
import mage.abilities.hint.ValueHint;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.token.SpiritWhiteToken;
import mage.watchers.Watcher;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class ThalisseReverentMedium extends CardImpl {
private static final Hint hint = new ValueHint(
"The number of tokens you created this turn",
ThalisseReverentMediumValue.instance
);
public ThalisseReverentMedium(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{B}");
this.addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.CLERIC);
this.power = new MageInt(3);
this.toughness = new MageInt(4);
// At the beginning of each end step, create X 1/1 white Spirit creature tokens with flying, where X is the number of tokens you created this turn.
this.addAbility(new BeginningOfEndStepTriggeredAbility(new CreateTokenEffect(
new SpiritWhiteToken(), ThalisseReverentMediumValue.instance
), TargetController.ANY, false).addHint(hint), new ThalisseReverentMediumWatcher());
}
private ThalisseReverentMedium(final ThalisseReverentMedium card) {
super(card);
}
@Override
public ThalisseReverentMedium copy() {
return new ThalisseReverentMedium(this);
}
}
enum ThalisseReverentMediumValue implements DynamicValue {
instance;
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
ThalisseReverentMediumWatcher watcher = game.getState().getWatcher(ThalisseReverentMediumWatcher.class);
return watcher == null ? 0 : watcher.getTokenCount(sourceAbility.getControllerId());
}
@Override
public ThalisseReverentMediumValue copy() {
return instance;
}
@Override
public String getMessage() {
return "the number of tokens you created this turn";
}
@Override
public String toString() {
return "X";
}
}
class ThalisseReverentMediumWatcher extends Watcher {
private final Map<UUID, Integer> tokenMap = new HashMap<>();
ThalisseReverentMediumWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.CREATED_TOKEN) {
return;
}
tokenMap.compute(event.getPlayerId(), (u, i) -> i == null ? 1 : Integer.sum(i, 1));
}
@Override
public void reset() {
tokenMap.clear();
super.reset();
}
int getTokenCount(UUID playerId) {
return tokenMap.getOrDefault(playerId, 0);
}
}

View file

@ -146,6 +146,7 @@ public final class CommanderLegends extends ExpansionSet {
cards.add(new SetCardInfo("Supreme Will", 102, Rarity.UNCOMMON, mage.cards.s.SupremeWill.class));
cards.add(new SetCardInfo("Sweet-Gum Recluse", 260, Rarity.RARE, mage.cards.s.SweetGumRecluse.class));
cards.add(new SetCardInfo("Tevesh Szat, Doom of Fools", 153, Rarity.MYTHIC, mage.cards.t.TeveshSzatDoomOfFools.class));
cards.add(new SetCardInfo("Thalisse, Reverent Medium", 291, Rarity.UNCOMMON, mage.cards.t.ThalisseReverentMedium.class));
cards.add(new SetCardInfo("Thorn of the Black Rose", 154, Rarity.COMMON, mage.cards.t.ThornOfTheBlackRose.class));
cards.add(new SetCardInfo("Thrasios, Triton Hero", 538, Rarity.MYTHIC, mage.cards.t.ThrasiosTritonHero.class));
cards.add(new SetCardInfo("Three Visits", 261, Rarity.UNCOMMON, mage.cards.t.ThreeVisits.class));