corrected implementation of Answered Prayers

This commit is contained in:
Evan Kranzler 2019-05-29 13:09:07 -04:00
parent 2f8518c61c
commit dddc47fedc

View file

@ -3,8 +3,7 @@ package mage.cards.a;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility; import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.condition.Condition; import mage.abilities.effects.OneShotEffect;
import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect; import mage.abilities.effects.common.continuous.BecomesCreatureSourceEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
@ -12,6 +11,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
@ -29,17 +29,9 @@ public final class AnsweredPrayers extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}{W}"); 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. // 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( this.addAbility(new EntersBattlefieldControlledTriggeredAbility(
new EntersBattlefieldControlledTriggeredAbility( new AnsweredPrayersEffect(), StaticFilters.FILTER_PERMANENT_CREATURE
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(ability);
} }
private AnsweredPrayers(final AnsweredPrayers card) { private AnsweredPrayers(final AnsweredPrayers card) {
@ -52,13 +44,37 @@ public final class AnsweredPrayers extends CardImpl {
} }
} }
enum AnsweredPrayersCondition implements Condition { class AnsweredPrayersEffect extends OneShotEffect {
instance;
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 @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); new GainLifeEffect(1).apply(game, source);
return permanent != null && !permanent.isCreature(); 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;
} }
} }