From cddfff4a2894b853cc73f81ae581b986ab5a19d6 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 14 Nov 2021 15:43:34 -0500 Subject: [PATCH] [APC] Implemented Zombie Boa --- Mage.Sets/src/mage/cards/z/ZombieBoa.java | 128 ++++++++++++++++++++++ Mage.Sets/src/mage/sets/Apocalypse.java | 1 + 2 files changed, 129 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/z/ZombieBoa.java diff --git a/Mage.Sets/src/mage/cards/z/ZombieBoa.java b/Mage.Sets/src/mage/cards/z/ZombieBoa.java new file mode 100644 index 00000000000..90587e6fdcf --- /dev/null +++ b/Mage.Sets/src/mage/cards/z/ZombieBoa.java @@ -0,0 +1,128 @@ +package mage.cards.z; + +import mage.MageInt; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.DelayedTriggeredAbility; +import mage.abilities.common.ActivateAsSorceryActivatedAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DestroyTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.ChoiceColor; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class ZombieBoa extends CardImpl { + + public ZombieBoa(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}"); + + this.subtype.add(SubType.ZOMBIE); + this.subtype.add(SubType.SNAKE); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // {1}{B}: Choose a color. Whenever Zombie Boa becomes blocked by a creature of that color this turn, destroy that creature. Activate this ability only any time you could cast a sorcery. + this.addAbility(new ActivateAsSorceryActivatedAbility(new ZombieBoaEffect(), new ManaCostsImpl<>("{1}{B}"))); + } + + private ZombieBoa(final ZombieBoa card) { + super(card); + } + + @Override + public ZombieBoa copy() { + return new ZombieBoa(this); + } +} + +class ZombieBoaEffect extends OneShotEffect { + + ZombieBoaEffect() { + super(Outcome.Benefit); + staticText = "choose a color. Whenever {this} becomes blocked by " + + "a creature of that color this turn, destroy that creature"; + } + + private ZombieBoaEffect(final ZombieBoaEffect effect) { + super(effect); + } + + @Override + public ZombieBoaEffect copy() { + return new ZombieBoaEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getSourceId()); + if (player == null) { + return false; + } + ChoiceColor choice = new ChoiceColor(true); + player.choose(outcome, choice, game); + ObjectColor color = choice.getColor(); + if (color == null) { + return false; + } + game.addDelayedTriggeredAbility(new ZombieBoaTriggeredAbility(color), source); + return true; + } +} + +class ZombieBoaTriggeredAbility extends DelayedTriggeredAbility { + + private final ObjectColor color; + + ZombieBoaTriggeredAbility(ObjectColor color) { + super(new DestroyTargetEffect(), Duration.EndOfTurn, false, false); + this.color = color; + } + + private ZombieBoaTriggeredAbility(final ZombieBoaTriggeredAbility ability) { + super(ability); + this.color = ability.color; + } + + @Override + public ZombieBoaTriggeredAbility copy() { + return new ZombieBoaTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CREATURE_BLOCKED; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!event.getTargetId().equals(this.getSourceId())) { + return false; + } + Permanent permanent = game.getPermanent(event.getSourceId()); + if (permanent == null || !permanent.isCreature(game) || !permanent.getColor(game).contains(color)) { + return false; + } + this.getEffects().setTargetPointer(new FixedTarget(permanent, game)); + return true; + } + + @Override + public String getRule() { + return "Whenever {this} becomes blocked by a creature of that color this turn, destroy that creature"; + } +} diff --git a/Mage.Sets/src/mage/sets/Apocalypse.java b/Mage.Sets/src/mage/sets/Apocalypse.java index 787c55c20ab..e051b236d6c 100644 --- a/Mage.Sets/src/mage/sets/Apocalypse.java +++ b/Mage.Sets/src/mage/sets/Apocalypse.java @@ -160,5 +160,6 @@ public final class Apocalypse extends ExpansionSet { cards.add(new SetCardInfo("Wild Research", 72, Rarity.RARE, mage.cards.w.WildResearch.class)); cards.add(new SetCardInfo("Yavimaya Coast", 143, Rarity.RARE, mage.cards.y.YavimayaCoast.class)); cards.add(new SetCardInfo("Yavimaya's Embrace", 127, Rarity.RARE, mage.cards.y.YavimayasEmbrace.class)); + cards.add(new SetCardInfo("Zombie Boa", 54, Rarity.COMMON, mage.cards.z.ZombieBoa.class)); } }