[ANA] - fixed Confront the Assault

This commit is contained in:
Oleg Agafonov 2018-10-09 20:36:59 +04:00
parent 10f56fb2a1
commit 74fb0acc75

View file

@ -1,18 +1,16 @@
package mage.cards.c;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
import mage.abilities.condition.common.AttackedThisStepCondition;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.constants.PhaseStep;
import mage.constants.TurnPhase;
import mage.game.permanent.token.SpiritWhiteToken;
import mage.watchers.common.PlayerAttackedStepWatcher;
import java.util.UUID;
@ -25,7 +23,12 @@ public final class ConfrontTheAssault extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{W}");
// Cast this spell only if a creature is attacking you.
this.addAbility(new SimpleStaticAbility(Zone.ALL, new ConfrontTheAssaultRestrictEffect()));
Ability ability = new CastOnlyDuringPhaseStepSourceAbility(
TurnPhase.COMBAT, PhaseStep.DECLARE_ATTACKERS, AttackedThisStepCondition.instance,
"Cast this spell only if a creature is attacking you."
);
ability.addWatcher(new PlayerAttackedStepWatcher());
this.addAbility(ability);
// Create three 1/1 white Spirit creature tokens with flying.
this.getSpellAbility().addEffect(new CreateTokenEffect(new SpiritWhiteToken("ANA"), 3));
@ -39,35 +42,4 @@ public final class ConfrontTheAssault extends CardImpl {
public ConfrontTheAssault copy() {
return new ConfrontTheAssault(this);
}
}
class ConfrontTheAssaultRestrictEffect extends ContinuousRuleModifyingEffectImpl {
ConfrontTheAssaultRestrictEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast this spell only if a creature is attacking you.";
}
ConfrontTheAssaultRestrictEffect(final ConfrontTheAssaultRestrictEffect effect) {
super(effect);
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED
&& event.getTargetId().equals(source.getControllerId())) {
return true;
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public ConfrontTheAssaultRestrictEffect copy() {
return new ConfrontTheAssaultRestrictEffect(this);
}
}