diff --git a/Mage.Sets/src/mage/sets/futuresight/GraveScrabbler.java b/Mage.Sets/src/mage/sets/futuresight/GraveScrabbler.java index 44e7ee27ac..096be9d518 100644 --- a/Mage.Sets/src/mage/sets/futuresight/GraveScrabbler.java +++ b/Mage.Sets/src/mage/sets/futuresight/GraveScrabbler.java @@ -2,7 +2,10 @@ package mage.sets.futuresight; import java.util.UUID; import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.condition.Condition; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.decorator.ConditionalTriggeredAbility; import mage.abilities.effects.common.ReturnToHandTargetEffect; @@ -12,6 +15,7 @@ import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Rarity; import mage.filter.common.FilterCreatureCard; +import mage.game.Game; import mage.target.common.TargetCardInGraveyard; public class GraveScrabbler extends CardImpl { @@ -29,9 +33,9 @@ public class GraveScrabbler extends CardImpl { //When Grave Scrabbler enters the battlefield, if its madness cost was paid, //you may return target creature card from a graveyard to its owner's hand. - EntersBattlefieldTriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), true); + TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ReturnToHandTargetEffect(), true); ability.addTarget(new TargetCardInGraveyard(new FilterCreatureCard("creature card in a graveyard"))); - this.addAbility(new ConditionalTriggeredAbility(ability, MadnessAbility.GetCondition(), + this.addAbility(new ConditionalTriggeredAbility(ability, MadnessPaidCondition.getInstance(), "When {this} enters the battlefield, if its madness cost was paid, you may return target creature card from a graveyard to its owner's hand.")); } @@ -45,3 +49,32 @@ public class GraveScrabbler extends CardImpl { } } + +class MadnessPaidCondition implements Condition { + + private static MadnessPaidCondition fInstance = null; + + private MadnessPaidCondition() { + } + + public static Condition getInstance() { + if (fInstance == null) { + fInstance = new MadnessPaidCondition(); + } + return fInstance; + } + + @Override + public boolean apply(Game game, Ability source) { + Card card = game.getCard(source.getSourceId()); + if (card != null) { + for (Ability ability : card.getAbilities()) { + if (ability instanceof MadnessAbility) { + return ((MadnessAbility) ability).getCosts().isPaid(); + } + } + } + return false; + } + +}