From 92ddceef8f14ed8f0e63f9e0d2261a8b681003c8 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Mon, 30 May 2022 14:14:19 -0400 Subject: [PATCH] [CLB] Implemented Moonshae Pixie --- Mage.Sets/src/mage/cards/m/MoonshaePixie.java | 123 ++++++++++++++++++ .../CommanderLegendsBattleForBaldursGate.java | 1 + 2 files changed, 124 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MoonshaePixie.java diff --git a/Mage.Sets/src/mage/cards/m/MoonshaePixie.java b/Mage.Sets/src/mage/cards/m/MoonshaePixie.java new file mode 100644 index 00000000000..c85bf6fb27e --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MoonshaePixie.java @@ -0,0 +1,123 @@ +package mage.cards.m; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.DrawCardSourceControllerEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.hint.Hint; +import mage.abilities.hint.ValueHint; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.AdventureCard; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.WatcherScope; +import mage.game.Game; +import mage.game.events.DamagedEvent; +import mage.game.events.GameEvent; +import mage.target.common.TargetCreaturePermanent; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MoonshaePixie extends AdventureCard { + + private static final Hint hint = new ValueHint("Opponents dealt damage this turn", MoonshaePixieValue.instance); + + public MoonshaePixie(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, new CardType[]{CardType.INSTANT}, "{3}{U}", "Pixie Dust", "{1}{U}"); + + this.subtype.add(SubType.FAERIE); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // When Moonshae Pixie enters the battlefield, draw cards equal to the number of opponents who were dealt combat damage this turn. + this.addAbility(new EntersBattlefieldTriggeredAbility( + new DrawCardSourceControllerEffect(MoonshaePixieValue.instance) + .setText("draw cards equal to the number of opponents who were dealt combat damage this turn") + ), new MoonshaePixieWatcher()); + + // Pixie Dust + // Up to three target creatures gain flying until end of turn. + this.getSpellCard().getSpellAbility().addEffect(new GainAbilityTargetEffect(FlyingAbility.getInstance())); + this.getSpellCard().getSpellAbility().addTarget(new TargetCreaturePermanent(0, 3)); + } + + private MoonshaePixie(final MoonshaePixie card) { + super(card); + } + + @Override + public MoonshaePixie copy() { + return new MoonshaePixie(this); + } +} + +enum MoonshaePixieValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + return MoonshaePixieWatcher.getDamaged(sourceAbility.getControllerId(), game); + } + + @Override + public MoonshaePixieValue copy() { + return this; + } + + @Override + public String getMessage() { + return ""; + } + + @Override + public String toString() { + return ""; + } +} + +class MoonshaePixieWatcher extends Watcher { + + private final Set players = new HashSet<>(); + + MoonshaePixieWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER + && ((DamagedEvent) event).isCombatDamage()) { + players.add(event.getTargetId()); + } + } + + @Override + public void reset() { + players.clear(); + super.reset(); + } + + static int getDamaged(UUID playerId, Game game) { + return game + .getState() + .getWatcher(MoonshaePixieWatcher.class) + .players + .stream() + .filter(game.getOpponents(playerId)::contains) + .mapToInt(x -> 1) + .sum(); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index e8322ca715c..a089661252b 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -181,6 +181,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Minsc & Boo, Timeless Heroes", 285, Rarity.MYTHIC, mage.cards.m.MinscBooTimelessHeroes.class)); cards.add(new SetCardInfo("Mold Folk", 133, Rarity.COMMON, mage.cards.m.MoldFolk.class)); cards.add(new SetCardInfo("Monster Manual", 242, Rarity.RARE, mage.cards.m.MonsterManual.class)); + cards.add(new SetCardInfo("Moonshae Pixie", 84, Rarity.UNCOMMON, mage.cards.m.MoonshaePixie.class)); cards.add(new SetCardInfo("Morphic Pool", 357, Rarity.RARE, mage.cards.m.MorphicPool.class)); cards.add(new SetCardInfo("Moss Diamond", 327, Rarity.COMMON, mage.cards.m.MossDiamond.class)); cards.add(new SetCardInfo("Mountain", 463, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));