Added early eventType check for ContinuousRuleModifying effects.

This commit is contained in:
LevelX2 2015-01-22 22:41:03 +01:00
parent 8ea8e77b88
commit dbffbad3cb
44 changed files with 343 additions and 188 deletions

View file

@ -28,29 +28,22 @@
package mage.sets.alarareborn; package mage.sets.alarareborn;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect; import mage.abilities.effects.common.NameACardEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository; import mage.constants.CardType;
import mage.choices.Choice; import mage.constants.Duration;
import mage.choices.ChoiceImpl; import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/** /**
* *

View file

@ -137,13 +137,16 @@ class SpiritOfTheLabyrinthEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DRAW_CARD;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DRAW_CARD) { SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatchers().get("DrewCard");
SpiritOfTheLabyrinthWatcher watcher = (SpiritOfTheLabyrinthWatcher) game.getState().getWatchers().get("DrewCard"); if (watcher != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId())) {
if (watcher != null && watcher.hasPlayerDrewCardThisTurn(event.getPlayerId())) { return true;
return true;
}
} }
return false; return false;
} }

View file

@ -65,7 +65,6 @@ public class AkromaAngelOfFury extends CardImpl {
this.supertype.add("Legendary"); this.supertype.add("Legendary");
this.subtype.add("Angel"); this.subtype.add("Angel");
this.color.setRed(true);
this.power = new MageInt(6); this.power = new MageInt(6);
this.toughness = new MageInt(6); this.toughness = new MageInt(6);

View file

@ -106,9 +106,14 @@ class WakeTheDeadEffect extends ContinuousRuleModifiyingEffectImpl {
super(effect); super(effect);
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) { if (event.getSourceId().equals(source.getSourceId())) {
if (game.getPhase().getType().equals(TurnPhase.COMBAT)) { if (game.getPhase().getType().equals(TurnPhase.COMBAT)) {
return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId()); return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
} }

View file

@ -29,11 +29,6 @@
package mage.sets.dragonsmaze; package mage.sets.dragonsmaze;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -41,21 +36,20 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect; import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility; import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository; import mage.constants.CardType;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CostModificationType; import mage.constants.CostModificationType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
/** /**
@ -83,7 +77,6 @@ public class CouncilOfTheAbsolute extends CardImpl {
// Spells with the chosen name cost 2 less for you to cast. // Spells with the chosen name cost 2 less for you to cast.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CouncilOfTheAbsoluteCostReductionEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CouncilOfTheAbsoluteCostReductionEffect()));
} }
public CouncilOfTheAbsolute (final CouncilOfTheAbsolute card) { public CouncilOfTheAbsolute (final CouncilOfTheAbsolute card) {
@ -127,9 +120,14 @@ class CouncilOfTheAbsoluteReplacementEffect extends ContinuousRuleModifiyingEffe
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.CAST_SPELL && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) { if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY))) {
return true; return true;

View file

@ -146,13 +146,16 @@ class RenderSilentEffect extends ContinuousRuleModifiyingEffectImpl {
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL ) { Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player != null && player.getId().equals(event.getPlayerId())) {
if (player != null && player.getId().equals(event.getPlayerId())) { return true;
return true;
}
} }
return false; return false;
} }

View file

@ -110,15 +110,19 @@ class MoonholdEffect extends ContinuousRuleModifiyingEffectImpl {
public String getInfoMessage(Ability source, GameEvent event, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) { if (mageObject != null) {
return "You can't play land cards this turn (" + mageObject.getLogName() + ")."; return "you can't play land cards this turn (" + mageObject.getLogName() + ").";
} }
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.PLAY_LAND;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.PLAY_LAND if (event.getPlayerId().equals(source.getFirstTarget())) {
&& event.getPlayerId().equals(source.getFirstTarget())) {
return true; return true;
} }
return false; return false;
@ -154,10 +158,14 @@ class MoonholdEffect2 extends ContinuousRuleModifiyingEffectImpl {
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL if (event.getPlayerId().equals(source.getFirstTarget())) {
&& event.getPlayerId().equals(source.getFirstTarget())) {
Card card = game.getCard(event.getSourceId()); Card card = game.getCard(event.getSourceId());
if (card != null && card.getCardType().contains(CardType.CREATURE)) { if (card != null && card.getCardType().contains(CardType.CREATURE)) {
return true; return true;

View file

@ -79,9 +79,14 @@ class HewedStoneRetainersEffect extends ContinuousRuleModifiyingEffectImpl {
super(effect); super(effect);
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) { if (event.getSourceId().equals(source.getSourceId())) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) { if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) {
return true; return true;

View file

@ -96,13 +96,16 @@ class WardscaleDragonRuleEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL ) { Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null && sourcePermanent.isAttacking()) {
if (sourcePermanent != null && sourcePermanent.isAttacking()) { return event.getPlayerId() == game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game);
return event.getPlayerId() == game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game);
}
} }
return false; return false;
} }

View file

@ -81,7 +81,7 @@ class DamageCantBePreventedEffect extends ContinuousRuleModifiyingEffectImpl {
public DamageCantBePreventedEffect() { public DamageCantBePreventedEffect() {
super(Duration.EndOfTurn, Outcome.Benefit, false, false); super(Duration.EndOfTurn, Outcome.Benefit, false, false);
staticText = "Damage can't be prevented this turn"; staticText = "damage can't be prevented this turn";
} }
public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) { public DamageCantBePreventedEffect(final DamageCantBePreventedEffect effect) {
@ -98,11 +98,13 @@ class DamageCantBePreventedEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.PREVENT_DAMAGE;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType().equals(GameEvent.EventType.PREVENT_DAMAGE)) { return true;
return true;
}
return false;
} }
} }

View file

@ -182,9 +182,14 @@ class AngelicArbiterEffect2 extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.CAST_SPELL && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { if (game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
AngelicArbiterWatcher2 watcher = (AngelicArbiterWatcher2) game.getState().getWatchers().get("PlayerAttacked"); AngelicArbiterWatcher2 watcher = (AngelicArbiterWatcher2) game.getState().getWatchers().get("PlayerAttacked");
if (watcher != null && watcher.hasPlayerAttackedThisTurn(event.getPlayerId())) { if (watcher != null && watcher.hasPlayerAttackedThisTurn(event.getPlayerId())) {
return true; return true;

View file

@ -97,9 +97,14 @@ class AggressiveMiningEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.PLAY_LAND;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return event.getType().equals(GameEvent.EventType.PLAY_LAND) && event.getPlayerId().equals(source.getControllerId()); return event.getPlayerId().equals(source.getControllerId());
} }
} }

View file

@ -99,17 +99,20 @@ class HushwingGryffEffect extends ContinuousRuleModifiyingEffectImpl {
} }
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ENTERS_THE_BATTLEFIELD) { Permanent permanent = ((EntersTheBattlefieldEvent)event).getTarget();
Permanent permanent = ((EntersTheBattlefieldEvent)event).getTarget(); if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) {
if (permanent != null && permanent.getCardType().contains(CardType.CREATURE)) { // Because replacement events have to be executed
// Because replacement events have to be executed // call replaceEvent here without calling the triggering event after
// call replaceEvent here without calling the triggering event after game.getContinuousEffects().replaceEvent(event, game);
game.getContinuousEffects().replaceEvent(event, game); return true;
return true;
}
} }
return false; return false;
} }

View file

@ -110,9 +110,14 @@ class CeaseFireEffect extends ContinuousRuleModifiyingEffectImpl {
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL && event.getPlayerId().equals(source.getFirstTarget())) { if (event.getPlayerId().equals(source.getFirstTarget())) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (filter.match((Spell) object, game)) { if (filter.match((Spell) object, game)) {
return true; return true;

View file

@ -30,12 +30,12 @@ package mage.sets.returntoravnica;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.CantCounterAbility; import mage.abilities.common.CantBeCounteredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.abilities.effects.common.CantCounterSourceEffect; import mage.abilities.effects.common.CantBeCounteredSourceEffect;
import mage.abilities.effects.common.DestroyAllEffect; import mage.abilities.effects.common.DestroyAllEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.Zone; import mage.constants.Zone;
@ -55,7 +55,7 @@ public class SupremeVerdict extends CardImpl {
this.color.setBlue(true); this.color.setBlue(true);
// Supreme Verdict can't be countered. // Supreme Verdict can't be countered.
Ability ability = new CantCounterAbility(); Ability ability = new CantBeCounteredAbility();
ability.setRuleAtTheTop(true); ability.setRuleAtTheTop(true);
this.addAbility(ability); this.addAbility(ability);

View file

@ -129,13 +129,16 @@ class XantidSwarmReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL ) { Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player != null && player.getId().equals(event.getPlayerId())) {
if (player != null && player.getId().equals(event.getPlayerId())) { return true;
return true;
}
} }
return false; return false;
} }

View file

@ -111,9 +111,14 @@ class VexingShusherCantCounterTargetEffect extends ContinuousRuleModifiyingEffec
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.COUNTER;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
return event.getType() == EventType.COUNTER && event.getTargetId().equals(targetPointer.getFirst(game, source)); return event.getTargetId().equals(targetPointer.getFirst(game, source));
} }
} }

View file

@ -144,14 +144,17 @@ class EtherswornCanonistReplacementEffect extends ContinuousRuleModifiyingEffect
return new EtherswornCanonistReplacementEffect(this); return new EtherswornCanonistReplacementEffect(this);
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL) { EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher)game.getState().getWatchers().get("EtherswornCanonistWatcher");
EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher)game.getState().getWatchers().get("EtherswornCanonistWatcher"); Card card = game.getCard(event.getSourceId());
Card card = game.getCard(event.getSourceId()); if (card != null && !card.getCardType().contains(CardType.ARTIFACT) && watcher.castNonArtifactSpell(event.getPlayerId())) {
if (card != null && !card.getCardType().contains(CardType.ARTIFACT) && watcher.castNonArtifactSpell(event.getPlayerId())) { return true;
return true;
}
} }
return false; return false;
} }

View file

@ -91,13 +91,16 @@ class IncinerateEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.REGENERATE;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.REGENERATE) { DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId()); if (watcher != null) {
if (watcher != null) { return watcher.wasDamaged(event.getTargetId(), game);
return watcher.wasDamaged(event.getTargetId(), game);
}
} }
return false; return false;
} }

View file

@ -28,19 +28,13 @@
package mage.sets.theros; package mage.sets.theros;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.keyword.ScryEffect; import mage.abilities.effects.keyword.ScryEffect;
import mage.abilities.effects.common.ruleModifying.CantRegenerateTargetEffect; import mage.abilities.effects.common.ruleModifying.CantRegenerateTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.watchers.common.DamagedByWatcher; import mage.watchers.common.DamagedByWatcher;

View file

@ -105,6 +105,13 @@ class ShipbreakerKrakenReplacementEffect extends ContinuousRuleModifiyingEffectI
return false; return false;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.LOST_CONTROL ||
event.getType() == GameEvent.EventType.ZONE_CHANGE ||
event.getType() == GameEvent.EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
// Source must be on the battlefield (it's neccessary to check here because if as response to the enter // Source must be on the battlefield (it's neccessary to check here because if as response to the enter

View file

@ -105,16 +105,19 @@ class UnderworldCerberusEffect extends ContinuousRuleModifiyingEffectImpl {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.TARGET;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.TARGET) { Card targetCard = game.getCard(event.getTargetId());
Card targetCard = game.getCard(event.getTargetId()); StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId());
StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId()); if (targetCard != null && stackObject != null) {
if (targetCard != null && stackObject != null) { Zone zone = game.getState().getZone(targetCard.getId());
Zone zone = game.getState().getZone(targetCard.getId()); if (zone != null && (zone == Zone.GRAVEYARD)) {
if (zone != null && (zone == Zone.GRAVEYARD)) { return true;
return true;
}
} }
} }
return false; return false;

View file

@ -87,6 +87,11 @@ class AbyssalPersecutorCannotWinEffect extends ContinuousRuleModifiyingEffectImp
super(effect); super(effect);
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.LOSES || event.getType() == EventType.WINS ;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if ((event.getType() == EventType.LOSES && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) if ((event.getType() == EventType.LOSES && game.getOpponents(source.getControllerId()).contains(event.getPlayerId()))

View file

@ -99,6 +99,16 @@ public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModi
return false; return false;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
if (effect.checksEventType(event, game)) {
return true;
} else if (otherwiseEffect != null) {
return otherwiseEffect.checksEventType(event, game);
}
return false;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (!initDone) { // if simpleStaticAbility, init won't be called if (!initDone) { // if simpleStaticAbility, init won't be called

View file

@ -646,6 +646,9 @@ public class ContinuousEffects implements Serializable {
*/ */
public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) { public boolean preventedByRuleModification(GameEvent event, Ability targetAbility, Game game, boolean checkPlayableMode) {
for (ContinuousRuleModifiyingEffect effect: continuousRuleModifyingEffects) { for (ContinuousRuleModifiyingEffect effect: continuousRuleModifyingEffects) {
if (!effect.checksEventType(event, game)) {
continue;
}
for (Ability sourceAbility : continuousRuleModifyingEffects.getAbility(effect.getId())) { for (Ability sourceAbility : continuousRuleModifyingEffects.getAbility(effect.getId())) {
if (!(sourceAbility instanceof StaticAbility) || sourceAbility.isInUseableZone(game, null, false)) { if (!(sourceAbility instanceof StaticAbility) || sourceAbility.isInUseableZone(game, null, false)) {
if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) { if (effect.getDuration() != Duration.OneUse || !effect.isUsed()) {

View file

@ -38,6 +38,15 @@ import mage.game.events.GameEvent;
*/ */
public interface ContinuousRuleModifiyingEffect extends ContinuousEffect { public interface ContinuousRuleModifiyingEffect extends ContinuousEffect {
/**
* This check for the relevant events is called at first to prevent further actions if
* the current event is ignored from this effect
* @param event
* @param game
* @return
*/
boolean checksEventType(GameEvent event, Game game);
/** /**
* *
* @param event the event to check if it may happen * @param event the event to check if it may happen

View file

@ -78,6 +78,11 @@ public abstract class ContinuousRuleModifiyingEffectImpl extends ContinuousEffec
this.messageToGameLog = effect.messageToGameLog; this.messageToGameLog = effect.messageToGameLog;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return true;
}
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return true; return true;

View file

@ -61,14 +61,17 @@ public class CantActivateAbilitiesAttachedEffect extends ContinuousRuleModifiyin
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ACTIVATE_ABILITY;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { Permanent enchantment = game.getPermanent(source.getSourceId());
Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) {
if (enchantment != null && enchantment.getAttachedTo() != null) { if (event.getSourceId().equals(enchantment.getAttachedTo())) {
if (event.getSourceId().equals(enchantment.getAttachedTo())) { return true;
return true;
}
} }
} }
return false; return false;

View file

@ -80,19 +80,22 @@ public class CantBeCounteredControlledEffect extends ContinuousRuleModifiyingEff
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.COUNTER;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.COUNTER) { Spell spell = game.getStack().getSpell(event.getTargetId());
Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getControllerId().equals(source.getControllerId())
if (spell != null && spell.getControllerId().equals(source.getControllerId()) && filterTarget.match(spell, game)) {
&& filterTarget.match(spell, game)) { if (filterSource == null) {
if (filterSource == null) { return true;
} else {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, game)) {
return true; return true;
} else {
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, game)) {
return true;
}
} }
} }
} }

View file

@ -74,14 +74,18 @@ public class CantBeCounteredSourceEffect extends ContinuousRuleModifiyingEffectI
return staticText; return staticText;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.COUNTER;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.COUNTER) { Spell spell = game.getStack().getSpell(event.getTargetId());
Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null) {
if (spell != null) { if (spell.getSourceId().equals(source.getSourceId())) {
if (spell.getSourceId().equals(source.getSourceId())) { return true;
return true;
}
} }
} }
return false; return false;

View file

@ -81,20 +81,23 @@ public class CantBeTargetedAllEffect extends ContinuousRuleModifiyingEffectImpl
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.TARGET) { Permanent permanent = game.getPermanent(event.getTargetId());
Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) { if (filterSource == null) {
if (filterSource == null) { return true;
}
else {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, sourceObject.getSourceId(), game)) {
return true; return true;
} }
else {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, sourceObject.getSourceId(), game)) {
return true;
}
}
} }
} }
return false; return false;

View file

@ -72,15 +72,18 @@ public class CantBeTargetedAttachedEffect extends ContinuousRuleModifiyingEffect
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.TARGET) { Permanent attachment = game.getPermanent(source.getSourceId());
Permanent attachment = game.getPermanent(source.getSourceId()); if (attachment != null && event.getTargetId().equals(attachment.getAttachedTo())) {
if (attachment != null && event.getTargetId().equals(attachment.getAttachedTo())) { StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) { return true;
return true;
}
} }
} }
return false; return false;

View file

@ -66,10 +66,15 @@ public class CantBeTargetedSourceEffect extends ContinuousRuleModifiyingEffectIm
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.TARGET && event.getTargetId().equals(source.getSourceId())) { if (event.getTargetId().equals(source.getSourceId())) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) { if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
return true; return true;

View file

@ -67,9 +67,14 @@ public class CantBeTargetedTargetEffect extends ContinuousRuleModifiyingEffectIm
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.TARGET;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.TARGET && getTargetPointer().getTargets(game, source).contains(event.getTargetId())) { if (getTargetPointer().getTargets(game, source).contains(event.getTargetId())) {
StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); StackObject sourceObject = game.getStack().getStackObject(event.getSourceId());
if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) { if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) {
return true; return true;

View file

@ -42,7 +42,11 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP_STEP || event.getType() == GameEvent.EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
// the check for turn number is needed if multiple effects are added to prevent untap in next untap step // the check for turn number is needed if multiple effects are added to prevent untap in next untap step
@ -55,7 +59,7 @@ public class DontUntapInControllersNextUntapStepSourceEffect extends ContinuousR
return false; return false;
} }
// remember the turn of the untap step the effect has to be applied // remember the turn of the untap step the effect has to be applied
if (GameEvent.EventType.UNTAP_STEP.equals(event.getType()) if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())
&& game.getActivePlayerId().equals(source.getControllerId())) { && game.getActivePlayerId().equals(source.getControllerId())) {
if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step
discard(); discard();

View file

@ -86,6 +86,11 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
} }
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP_STEP || event.getType() == EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
@ -99,7 +104,7 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
return false; return false;
} }
// remember the turn of the untap step the effect has to be applied // remember the turn of the untap step the effect has to be applied
if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())) { if (GameEvent.EventType.UNTAP_STEP.equals(event.getType())) {
UUID controllerId = null; UUID controllerId = null;
for(UUID targetId : getTargetPointer().getTargets(game, source)) { for(UUID targetId : getTargetPointer().getTargets(game, source)) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);
@ -109,17 +114,16 @@ public class DontUntapInControllersNextUntapStepTargetEffect extends ContinuousR
} }
if (controllerId == null) { // no more targets on the battlefield, effect can be discarded if (controllerId == null) { // no more targets on the battlefield, effect can be discarded
discard(); discard();
return false; return false;
} }
if (game.getActivePlayerId().equals(controllerId)) { if (game.getActivePlayerId().equals(controllerId)) {
if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step if (validForTurnNum == game.getTurnNum()) { // the turn has a second untap step but the effect is already related to the first untap step
discard(); discard();
return false; return false;
} }
validForTurnNum = game.getTurnNum(); validForTurnNum = game.getTurnNum();
} }
} }
if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == EventType.UNTAP) { if (game.getTurn().getStepType() == PhaseStep.UNTAP && event.getType() == EventType.UNTAP) {

View file

@ -41,6 +41,7 @@ import static mage.constants.TargetController.YOU;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -76,10 +77,15 @@ public class DontUntapInControllersUntapStepAllEffect extends ContinuousRuleModi
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
return false; return false;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (GameEvent.EventType.UNTAP.equals(event.getType()) && PhaseStep.UNTAP.equals(game.getTurn().getStepType())) { if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) {
Permanent permanent = game.getPermanent(event.getTargetId()); Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null) { if (permanent != null) {
switch(targetController) { switch(targetController) {

View file

@ -45,10 +45,14 @@ public class DontUntapInControllersUntapStepEnchantedEffect extends ContinuousRu
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (GameEvent.EventType.UNTAP.equals(event.getType()) && PhaseStep.UNTAP.equals(game.getTurn().getStepType())) { if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) {
Permanent enchantment = game.getPermanent(source.getSourceId()); Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) { if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) {
Permanent permanent = game.getPermanent(enchantment.getAttachedTo()); Permanent permanent = game.getPermanent(enchantment.getAttachedTo());

View file

@ -62,10 +62,14 @@ public class DontUntapInControllersUntapStepSourceEffect extends ContinuousRuleM
return false; return false;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP if (game.getTurn().getStepType() == PhaseStep.UNTAP
&& event.getType() == EventType.UNTAP
&& event.getTargetId().equals(source.getSourceId())) { && event.getTargetId().equals(source.getSourceId())) {
Permanent permanent = game.getPermanent(source.getSourceId()); Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && permanent.getControllerId().equals(game.getActivePlayerId())) { if (permanent != null && permanent.getControllerId().equals(game.getActivePlayerId())) {

View file

@ -38,7 +38,6 @@ import mage.constants.Outcome;
import mage.constants.PhaseStep; import mage.constants.PhaseStep;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
@ -74,10 +73,15 @@ public class DontUntapInControllersUntapStepTargetEffect extends ContinuousRuleM
} }
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.UNTAP;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (GameEvent.EventType.UNTAP.equals(event.getType()) && PhaseStep.UNTAP.equals(game.getTurn().getStepType())) { if (PhaseStep.UNTAP.equals(game.getTurn().getStepType())) {
for (UUID targetId : targetPointer.getTargets(game, source)) { for (UUID targetId : targetPointer.getTargets(game, source)) {
if (event.getTargetId().equals(targetId)) { if (event.getTargetId().equals(targetId)) {
Permanent permanent = game.getPermanent(targetId); Permanent permanent = game.getPermanent(targetId);

View file

@ -108,11 +108,15 @@ class EpicReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
} }
return null; return null;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL if (source.getControllerId() == event.getPlayerId()) {
&& source.getControllerId() == event.getPlayerId()) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null) { if (object != null) {
return true; return true;

View file

@ -68,35 +68,38 @@ public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifiyingEffe
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL) { switch (targetController) {
switch (targetController) { case YOU:
case YOU: if (!event.getPlayerId().equals(source.getControllerId())) {
if (!event.getPlayerId().equals(source.getControllerId())) { return false;
return false; }
} break;
break; case NOT_YOU:
case NOT_YOU: if (event.getPlayerId().equals(source.getControllerId())) {
if (event.getPlayerId().equals(source.getControllerId())) { return false;
return false; }
} break;
break; case OPPONENT:
case OPPONENT: if (!game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
if (!game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) { return false;
return false; }
} break;
break; case CONTROLLER_ATTACHED_TO:
case CONTROLLER_ATTACHED_TO: Permanent attachment = game.getPermanent(source.getSourceId());
Permanent attachment = game.getPermanent(source.getSourceId()); if (attachment == null || !attachment.getAttachedTo().equals(event.getPlayerId())) {
if (attachment == null || !attachment.getAttachedTo().equals(event.getPlayerId())) { return false;
return false; }
} }
} CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher"); if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId())> 0) {
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId())> 0) { return true;
return true;
}
} }
return false; return false;
} }

View file

@ -35,6 +35,7 @@ import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
/** /**
* *
@ -62,13 +63,16 @@ public class CantRegenerateTargetEffect extends ContinuousRuleModifiyingEffectIm
return true; return true;
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.REGENERATE;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (GameEvent.EventType.REGENERATE.equals(event.getType())) { UUID targetId = getTargetPointer().getFirst(game, source);
UUID targetId = getTargetPointer().getFirst(game, source); if (targetId != null) {
if (targetId != null) { return targetId.equals(event.getTargetId());
return targetId.equals(event.getTargetId());
}
} }
return false; return false;
} }

View file

@ -55,6 +55,11 @@ class SplitSecondEffect extends ContinuousRuleModifiyingEffectImpl {
return "You can't cast spells or activate abilities that aren't mana abilities (Split second)."; return "You can't cast spells or activate abilities that aren't mana abilities (Split second).";
} }
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.CAST_SPELL || event.getType() == GameEvent.EventType.ACTIVATE_ABILITY;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL) { if (event.getType() == GameEvent.EventType.CAST_SPELL) {