From d8fa5eaeee51d804b5c01e6568498d0e94c66005 Mon Sep 17 00:00:00 2001 From: Daniel Bomar Date: Tue, 8 Nov 2022 16:43:03 -0600 Subject: [PATCH] [BRO] Implemented Ashnod's Intervention --- .../src/mage/cards/a/AshnodsIntervention.java | 77 +++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + .../common/ReturnToHandSourceEffect.java | 1 + 3 files changed, 79 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AshnodsIntervention.java diff --git a/Mage.Sets/src/mage/cards/a/AshnodsIntervention.java b/Mage.Sets/src/mage/cards/a/AshnodsIntervention.java new file mode 100644 index 0000000000..d8cdc5528f --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AshnodsIntervention.java @@ -0,0 +1,77 @@ +package mage.cards.a; + +import java.util.UUID; + +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.ReturnToHandSourceEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author weirddan455 + */ +public final class AshnodsIntervention extends CardImpl { + + public AshnodsIntervention(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}"); + + // Until end of turn, target creature gets +2/+0 and gains "When this creature dies or is put into exile from the battlefield, return it to its owner's hand." + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); + this.getSpellAbility().addEffect(new BoostTargetEffect(2, 0) + .setText("until end of turn, target creature gets +2/+0")); + this.getSpellAbility().addEffect(new GainAbilityTargetEffect(new AshnodsInterventionAbility()) + .setText("and gains \"When this creature dies or is put into exile from the battlefield, return it to its owner's hand.\"")); + } + + private AshnodsIntervention(final AshnodsIntervention card) { + super(card); + } + + @Override + public AshnodsIntervention copy() { + return new AshnodsIntervention(this); + } +} + +class AshnodsInterventionAbility extends TriggeredAbilityImpl { + + public AshnodsInterventionAbility() { + super(Zone.ALL, new ReturnToHandSourceEffect()); + setLeavesTheBattlefieldTrigger(true); + } + + private AshnodsInterventionAbility(final AshnodsInterventionAbility ability) { + super(ability); + } + + @Override + public AshnodsInterventionAbility copy() { + return new AshnodsInterventionAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + ZoneChangeEvent zEvent = (ZoneChangeEvent) event; + return zEvent.getTargetId().equals(sourceId) && zEvent.getFromZone() == Zone.BATTLEFIELD + && (zEvent.getToZone() == Zone.GRAVEYARD || zEvent.getToZone() == Zone.EXILED); + } + + @Override + public String getRule() { + return "When {this} dies or is put into exile from the battlefield, return it to its owner's hand"; + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index 5f1528935f..64a13bb48e 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -48,6 +48,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Argothian Sprite", 168, Rarity.COMMON, mage.cards.a.ArgothianSprite.class)); cards.add(new SetCardInfo("Artificer's Dragon", 291, Rarity.RARE, mage.cards.a.ArtificersDragon.class)); cards.add(new SetCardInfo("Ashnod's Harvester", 117, Rarity.UNCOMMON, mage.cards.a.AshnodsHarvester.class)); + cards.add(new SetCardInfo("Ashnod's Intervention", 85, Rarity.COMMON, mage.cards.a.AshnodsIntervention.class)); cards.add(new SetCardInfo("Ashnod, Flesh Mechanist", 84, Rarity.RARE, mage.cards.a.AshnodFleshMechanist.class)); cards.add(new SetCardInfo("Audacity", 169, Rarity.UNCOMMON, mage.cards.a.Audacity.class)); cards.add(new SetCardInfo("Autonomous Assembler", 34, Rarity.RARE, mage.cards.a.AutonomousAssembler.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java index f30a0b3c16..7fc048560b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ReturnToHandSourceEffect.java @@ -78,6 +78,7 @@ public class ReturnToHandSourceEffect extends OneShotEffect { } break; case GRAVEYARD: + case EXILED: Card card = (Card) mageObject; return !fromBattlefieldOnly && controller.moveCards(card, Zone.HAND, source, game); case STACK: