From aaa611679f3d628b3dc9734423d0412c49d8cee5 Mon Sep 17 00:00:00 2001 From: Cameron Merkel <44722506+Cguy7777@users.noreply.github.com> Date: Sat, 30 Nov 2024 11:46:06 -0600 Subject: [PATCH] [DSK] Implement Fear of Abduction (#13079) --- .../src/mage/cards/f/FearOfAbduction.java | 125 ++++++++++++++++++ .../src/mage/sets/DuskmournHouseOfHorror.java | 1 + 2 files changed, 126 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/f/FearOfAbduction.java diff --git a/Mage.Sets/src/mage/cards/f/FearOfAbduction.java b/Mage.Sets/src/mage/cards/f/FearOfAbduction.java new file mode 100644 index 00000000000..72792029d78 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FearOfAbduction.java @@ -0,0 +1,125 @@ +package mage.cards.f; + +import java.util.UUID; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.LeavesBattlefieldTriggeredAbility; +import mage.abilities.costs.common.ExileTargetCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.ExileTargetEffect; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; +import mage.filter.StaticFilters; +import mage.game.ExileZone; +import mage.game.Game; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; +import mage.target.common.TargetCreaturePermanent; +import mage.util.CardUtil; + +/** + * @author Cguy7777 + */ +public final class FearOfAbduction extends CardImpl { + + public FearOfAbduction(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT, CardType.CREATURE}, "{4}{W}{W}"); + + this.subtype.add(SubType.NIGHTMARE); + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // As an additional cost to cast this spell, exile a creature you control. + this.getSpellAbility().addCost( + new ExileTargetCost(new TargetControlledPermanent(StaticFilters.FILTER_CONTROLLED_A_CREATURE))); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // When Fear of Abduction enters, exile target creature an opponent controls. + Ability ability = new EntersBattlefieldTriggeredAbility(new FearOfAbductionExileEffect()); + ability.addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE)); + this.addAbility(ability); + + // When Fear of Abduction leaves the battlefield, put each card exiled with it into its owner's hand. + this.addAbility(new LeavesBattlefieldTriggeredAbility(new FearOfAbductionReturnEffect())); + } + + private FearOfAbduction(final FearOfAbduction card) { + super(card); + } + + @Override + public FearOfAbduction copy() { + return new FearOfAbduction(this); + } +} + +class FearOfAbductionExileEffect extends OneShotEffect { + + FearOfAbductionExileEffect() { + super(Outcome.Benefit); + this.staticText = "exile target creature an opponent controls"; + } + + private FearOfAbductionExileEffect(final FearOfAbductionExileEffect effect) { + super(effect); + } + + @Override + public FearOfAbductionExileEffect copy() { + return new FearOfAbductionExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + MageObject sourceObject = source.getSourceObject(game); + if (sourceObject != null) { + return new ExileTargetEffect( + // Offset -1 so that opponent's creature is exiled to the same exile zone as your creature + CardUtil.getExileZoneId(game, source, -1), + CardUtil.getSourceName(game, source)) + .apply(game, source); + } + return false; + } +} + +class FearOfAbductionReturnEffect extends OneShotEffect { + + FearOfAbductionReturnEffect() { + super(Outcome.Neutral); + this.staticText = "put each card exiled with it into its owner's hand"; + } + + private FearOfAbductionReturnEffect(final FearOfAbductionReturnEffect effect) { + super(effect); + } + + @Override + public FearOfAbductionReturnEffect copy() { + return new FearOfAbductionReturnEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + // Offset -2 since Fear of Abduction has left the battlefield since last time + ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source, -2)); + if (exileZone != null) { + controller.moveCards(exileZone, Zone.HAND, source, game); + } + return true; + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java b/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java index 84e21a7a17b..363a6bcc017 100644 --- a/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java +++ b/Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java @@ -80,6 +80,7 @@ public final class DuskmournHouseOfHorror extends ExpansionSet { cards.add(new SetCardInfo("Ethereal Armor", 7, Rarity.UNCOMMON, mage.cards.e.EtherealArmor.class)); cards.add(new SetCardInfo("Exorcise", 8, Rarity.UNCOMMON, mage.cards.e.Exorcise.class)); cards.add(new SetCardInfo("Fanatic of the Harrowing", 96, Rarity.COMMON, mage.cards.f.FanaticOfTheHarrowing.class)); + cards.add(new SetCardInfo("Fear of Abduction", 9, Rarity.UNCOMMON, mage.cards.f.FearOfAbduction.class)); cards.add(new SetCardInfo("Fear of Being Hunted", 134, Rarity.UNCOMMON, mage.cards.f.FearOfBeingHunted.class)); cards.add(new SetCardInfo("Fear of Burning Alive", 135, Rarity.UNCOMMON, mage.cards.f.FearOfBurningAlive.class)); cards.add(new SetCardInfo("Fear of Exposure", 177, Rarity.UNCOMMON, mage.cards.f.FearOfExposure.class));