From 94d1178a5a3678dc5dc5790bcad7482fbcee007a Mon Sep 17 00:00:00 2001 From: theelk801 Date: Sat, 1 Apr 2023 19:56:01 -0400 Subject: [PATCH] [MOM] Implement Deeproot Wayfinder --- .../src/mage/cards/d/DeeprootWayfinder.java | 81 +++++++++++++++++++ .../src/mage/sets/MarchOfTheMachine.java | 1 + ...CombatDamageToAPlayerTriggeredAbility.java | 12 ++- 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/d/DeeprootWayfinder.java diff --git a/Mage.Sets/src/mage/cards/d/DeeprootWayfinder.java b/Mage.Sets/src/mage/cards/d/DeeprootWayfinder.java new file mode 100644 index 0000000000..1fcf1fc180 --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DeeprootWayfinder.java @@ -0,0 +1,81 @@ +package mage.cards.d; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.players.Player; +import mage.target.TargetCard; +import mage.target.common.TargetCardInYourGraveyard; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class DeeprootWayfinder extends CardImpl { + + public DeeprootWayfinder(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}"); + + this.subtype.add(SubType.MERFOLK); + this.subtype.add(SubType.SCOUT); + this.power = new MageInt(2); + this.toughness = new MageInt(3); + + // Whenever Deeproot Wayfinder deals combat damage to a player or battle, surveil 1, then you may return a land card from your graveyard to the battlefield tapped. + this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new DeeprootWayfinderEffect(), false).setOrBattle(true)); + } + + private DeeprootWayfinder(final DeeprootWayfinder card) { + super(card); + } + + @Override + public DeeprootWayfinder copy() { + return new DeeprootWayfinder(this); + } +} + +class DeeprootWayfinderEffect extends OneShotEffect { + + DeeprootWayfinderEffect() { + super(Outcome.Benefit); + staticText = "surveil 1, then you may return a land card from your graveyard to the battlefield tapped"; + } + + private DeeprootWayfinderEffect(final DeeprootWayfinderEffect effect) { + super(effect); + } + + @Override + public DeeprootWayfinderEffect copy() { + return new DeeprootWayfinderEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + player.surveil(1, source, game); + TargetCard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_LAND_A); + target.setNotTarget(true); + player.choose(outcome, target, source, game); + Card card = game.getCard(target.getFirstTarget()); + return player.moveCards( + card, Zone.BATTLEFIELD, source, game, true, + false, false, null + ); + } +} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index f7c996de04..2080e4ce86 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -35,6 +35,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Copper Host Crusher", 181, Rarity.UNCOMMON, mage.cards.c.CopperHostCrusher.class)); cards.add(new SetCardInfo("Cragsmasher Yeti", 333, Rarity.COMMON, mage.cards.c.CragsmasherYeti.class)); cards.add(new SetCardInfo("Deadly Derision", 99, Rarity.COMMON, mage.cards.d.DeadlyDerision.class)); + cards.add(new SetCardInfo("Deeproot Wayfinder", 184, Rarity.RARE, mage.cards.d.DeeprootWayfinder.class)); cards.add(new SetCardInfo("Dismal Backwater", 269, Rarity.COMMON, mage.cards.d.DismalBackwater.class)); cards.add(new SetCardInfo("Dusk Legion Duelist", 11, Rarity.RARE, mage.cards.d.DuskLegionDuelist.class)); cards.add(new SetCardInfo("Elspeth's Smite", 13, Rarity.UNCOMMON, mage.cards.e.ElspethsSmite.class)); diff --git a/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java index e2c0d872f7..123371768e 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java @@ -18,6 +18,7 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility protected String text; protected boolean onlyOpponents; private boolean orPlaneswalker = false; + private boolean orBattle = false; public DealsCombatDamageToAPlayerTriggeredAbility(Effect effect, boolean optional) { this(effect, optional, false); @@ -45,6 +46,7 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility this.setTargetPointer = ability.setTargetPointer; this.onlyOpponents = ability.onlyOpponents; this.orPlaneswalker = ability.orPlaneswalker; + this.orBattle = ability.orBattle; } public DealsCombatDamageToAPlayerTriggeredAbility setOrPlaneswalker(boolean orPlaneswalker) { @@ -52,6 +54,11 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility return this; } + public DealsCombatDamageToAPlayerTriggeredAbility setOrBattle(boolean orBattle) { + this.orBattle = orBattle; + return this; + } + @Override public DealsCombatDamageToAPlayerTriggeredAbility copy() { return new DealsCombatDamageToAPlayerTriggeredAbility(this); @@ -78,8 +85,8 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility case DAMAGED_PERMANENT: Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent == null - || !permanent.isPlaneswalker(game) - || !orPlaneswalker) { + || (!orPlaneswalker || !permanent.isPlaneswalker(game)) + && (!orBattle || !permanent.isBattle(game))) { return false; } } @@ -104,6 +111,7 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility return "Whenever {this} deals combat damage to " + (onlyOpponents ? "an opponent" : "a player") + (orPlaneswalker ? " or planeswalker" : "") + + (orBattle ? " or battle" : "") + ", "; } }