corrected implementation of Answered Prayers
@@ -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;
}
}
