From f88876d1374504eb28f6630f16fc3a4d2807e676 Mon Sep 17 00:00:00 2001 From: Scott Crawford Date: Wed, 3 May 2017 19:41:10 -0700 Subject: [PATCH] Misfortune's Gain implemented misfortune's gain --- .../src/mage/cards/m/MisfortunesGain.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/m/MisfortunesGain.java b/Mage.Sets/src/mage/cards/m/MisfortunesGain.java index 78425bee59..f9440cee85 100644 --- a/Mage.Sets/src/mage/cards/m/MisfortunesGain.java +++ b/Mage.Sets/src/mage/cards/m/MisfortunesGain.java @@ -28,13 +28,20 @@ package mage.cards.m; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.game.Game; +import mage.constants.Outcome; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCreaturePermanent; /** * - * @author anonymous + * @author Scott-Crawford */ public class MisfortunesGain extends CardImpl { @@ -43,6 +50,8 @@ public class MisfortunesGain extends CardImpl { // Destroy target creature. Its owner gains 4 life. + this.getSpellAbility().addEffect(new PathOfPeaceEffect()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent()); } public MisfortunesGain(final MisfortunesGain card) { @@ -54,3 +63,33 @@ public class MisfortunesGain extends CardImpl { return new MisfortunesGain(this); } } + +class MisfortunesGainEffect extends OneShotEffect { + + public MisfortunesGainEffect() { + super(Outcome.DestroyPermanent); + this.staticText = "Destroy target creature. Its owner gains 4 life."; + } + + public MisfortunesGainEffect(final MisfortunesGainEffect effect) { + super(effect); + } + + @Override + public MisfortunesGainEffect copy() { + return new MisfortunesGainEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + Permanent target = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + if (controller != null && target != null) { + target.destroy(source.getSourceId(), game, false); + Player player = game.getPlayer(target.getOwnerId()); + player.gainLife(4, game); + return true; + } + return false; + } +}