From e457aba61d94b5dd51c4780c60bb22766f209a69 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 23 May 2019 18:10:15 -0400 Subject: [PATCH] Implemented Generous Gift --- Mage.Sets/src/mage/cards/g/GenerousGift.java | 74 ++++++++++++++++++++ Mage.Sets/src/mage/sets/ModernHorizons.java | 1 + 2 files changed, 75 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/g/GenerousGift.java diff --git a/Mage.Sets/src/mage/cards/g/GenerousGift.java b/Mage.Sets/src/mage/cards/g/GenerousGift.java new file mode 100644 index 0000000000..b1ba9ac7a7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GenerousGift.java @@ -0,0 +1,74 @@ +package mage.cards.g; + +import mage.abilities.Ability; +import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.ElephantToken; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.targetpointer.FixedTarget; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class GenerousGift extends CardImpl { + + public GenerousGift(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}"); + + // Destroy target permanent. Its controller creates a 3/3 green Elephant creature token. + this.getSpellAbility().addEffect(new GenerousGiftEffect()); + this.getSpellAbility().addTarget(new TargetPermanent()); + } + + private GenerousGift(final GenerousGift card) { + super(card); + } + + @Override + public GenerousGift copy() { + return new GenerousGift(this); + } +} + +class GenerousGiftEffect extends OneShotEffect { + + GenerousGiftEffect() { + super(Outcome.Benefit); + staticText = "Destroy target permanent. Its controller creates a 3/3 green Elephant creature token."; + } + + private GenerousGiftEffect(final GenerousGiftEffect effect) { + super(effect); + } + + @Override + public GenerousGiftEffect copy() { + return new GenerousGiftEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { + return false; + } + Player player = game.getPlayer(permanent.getControllerId()); + permanent.destroy(source.getSourceId(), game, false); + if (player == null) { + return false; + } + Effect effect = new CreateTokenTargetEffect(new ElephantToken()); + effect.setTargetPointer(new FixedTarget(player.getId(), game)); + return effect.apply(game, source); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/ModernHorizons.java b/Mage.Sets/src/mage/sets/ModernHorizons.java index a5fba4ea55..aa7ccb9c1b 100644 --- a/Mage.Sets/src/mage/sets/ModernHorizons.java +++ b/Mage.Sets/src/mage/sets/ModernHorizons.java @@ -45,6 +45,7 @@ public final class ModernHorizons extends ExpansionSet { cards.add(new SetCardInfo("Fiery Islet", 238, Rarity.RARE, mage.cards.f.FieryIslet.class)); cards.add(new SetCardInfo("Firebolt", 122, Rarity.UNCOMMON, mage.cards.f.Firebolt.class)); cards.add(new SetCardInfo("Flusterstorm", 255, Rarity.RARE, mage.cards.f.Flusterstorm.class)); + cards.add(new SetCardInfo("Generous Gift", 11, Rarity.UNCOMMON, mage.cards.g.GenerousGift.class)); cards.add(new SetCardInfo("Goblin Engineer", 128, Rarity.RARE, mage.cards.g.GoblinEngineer.class)); cards.add(new SetCardInfo("Goblin Matron", 129, Rarity.UNCOMMON, mage.cards.g.GoblinMatron.class)); cards.add(new SetCardInfo("Goblin War Party", 131, Rarity.COMMON, mage.cards.g.GoblinWarParty.class));