fixed Emergency Powers addendum not working

This commit is contained in:
Evan Kranzler 2019-01-12 20:23:39 -05:00
parent 0c3174ccda
commit 5cffe367ee

View file

@ -1,7 +1,8 @@
package mage.cards.e;
import mage.abilities.Ability;
import mage.abilities.condition.common.AddendumCondition;
import mage.abilities.decorator.ConditionalOneShotEffect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DrawCardAllEffect;
import mage.abilities.effects.common.ExileSpellEffect;
import mage.abilities.effects.common.PutCardFromHandOntoBattlefieldEffect;
@ -10,8 +11,10 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Outcome;
import mage.filter.common.FilterPermanentCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import java.util.UUID;
@ -20,30 +23,15 @@ import java.util.UUID;
*/
public final class EmergencyPowers extends CardImpl {
public static final FilterPermanentCard filter
= new FilterPermanentCard("a permanent card with converted mana cost 7 or less");
static {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 8));
}
public EmergencyPowers(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{5}{W}{U}");
// Each player shuffles their hand and graveyard into their library, then draws seven cards. Exile Emergency Powers.
this.getSpellAbility().addEffect(new ShuffleHandGraveyardAllEffect());
this.getSpellAbility().addEffect(new DrawCardAllEffect(7).setText(", then draws seven cards"));
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
// Addendum If you cast this spell during your main phase, you may put a permanent card with converted mana cost 7 or less from your hand onto the battlefield.
this.getSpellAbility().addEffect(new ConditionalOneShotEffect(
new PutCardFromHandOntoBattlefieldEffect(filter),
AddendumCondition.instance,
"<br><i>Addendum</i> &mdash; " +
"If you cast this spell during your main phase, " +
"you may put a permanent card with converted mana cost 7 or less " +
"from your hand onto the battlefield."
));
this.getSpellAbility().addEffect(new EmergencyPowersEffect());
}
private EmergencyPowers(final EmergencyPowers card) {
@ -55,4 +43,37 @@ public final class EmergencyPowers extends CardImpl {
return new EmergencyPowers(this);
}
}
class EmergencyPowersEffect extends OneShotEffect {
public static final FilterPermanentCard filter
= new FilterPermanentCard("a permanent card with converted mana cost 7 or less");
static {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, 8));
}
EmergencyPowersEffect() {
super(Outcome.Benefit);
staticText = "Exile {this}.<br><i>Addendum</i> &mdash; If you cast this spell during your main phase, " +
"you may put a permanent card with converted mana cost 7 or less from your hand onto the battlefield.";
}
private EmergencyPowersEffect(final EmergencyPowersEffect effect) {
super(effect);
}
@Override
public EmergencyPowersEffect copy() {
return new EmergencyPowersEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
if (AddendumCondition.instance.apply(game, source)) {
new PutCardFromHandOntoBattlefieldEffect(filter).apply(game, source);
}
return ExileSpellEffect.getInstance().apply(game, source);
}
}
// I am the senate!