From dddc47fedc9931da34f0b0eae1f952bbf80b7e7e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Wed, 29 May 2019 13:09:07 -0400 Subject: [PATCH] corrected implementation of Answered Prayers --- .../src/mage/cards/a/AnsweredPrayers.java | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AnsweredPrayers.java b/Mage.Sets/src/mage/cards/a/AnsweredPrayers.java index 456f120f144..7b4301b3438 100644 --- a/Mage.Sets/src/mage/cards/a/AnsweredPrayers.java +++ b/Mage.Sets/src/mage/cards/a/AnsweredPrayers.java @@ -3,8 +3,7 @@ package mage.cards.a; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; -import mage.abilities.condition.Condition; -import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect; import mage.abilities.keyword.FlyingAbility; @@ -12,6 +11,7 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; +import mage.constants.Outcome; import mage.constants.SubType; import mage.filter.StaticFilters; import mage.game.Game; @@ -29,17 +29,9 @@ public final class AnsweredPrayers extends CardImpl { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{W}"); // Whenever a creature enters the battlefield under your control, you gain 1 life. If Answered Prayers isn't a creature, it becomes a 3/3 Angel creature with flying in addition to its other types until end of turn. - Ability ability = new ConditionalInterveningIfTriggeredAbility( - new EntersBattlefieldControlledTriggeredAbility( - new GainLifeEffect(1), StaticFilters.FILTER_PERMANENT_CREATURE - ), AnsweredPrayersCondition.instance, "Whenever a creature enters the battlefield " + - "under your control, you gain 1 life. If {this} isn't a creature, " + - "it becomes a 3/3 Angel creature with flying in addition to its other types until end of turn." - ); - ability.addEffect(new BecomesCreatureSourceEffect( - new AnsweredPrayersToken(), "enchantment", Duration.EndOfTurn + this.addAbility(new EntersBattlefieldControlledTriggeredAbility( + new AnsweredPrayersEffect(), StaticFilters.FILTER_PERMANENT_CREATURE )); - this.addAbility(ability); } private AnsweredPrayers(final AnsweredPrayers card) { @@ -52,13 +44,37 @@ public final class AnsweredPrayers extends CardImpl { } } -enum AnsweredPrayersCondition implements Condition { - instance; +class AnsweredPrayersEffect extends OneShotEffect { + + AnsweredPrayersEffect() { + super(Outcome.Benefit); + staticText = "you gain 1 life. If {this} isn't a creature, it becomes a " + + "3/3 Angel creature with flying in addition to its other types until end of turn."; + } + + private AnsweredPrayersEffect(final AnsweredPrayersEffect effect) { + super(effect); + } + + @Override + public AnsweredPrayersEffect copy() { + return new AnsweredPrayersEffect(this); + } @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - return permanent != null && !permanent.isCreature(); + new GainLifeEffect(1).apply(game, source); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent == null) { + return false; + } + if (permanent.isCreature()) { + return true; + } + game.addEffect(new BecomesCreatureSourceEffect( + new AnsweredPrayersToken(), "enchantment", Duration.EndOfTurn + ), source); + return true; } }