From f51e7722ccaa48b2e0fc2dcd2e8dad226ec3462e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 28 Jul 2014 08:21:17 +0200 Subject: [PATCH] * Changed ReplacementEffects for TARGET and COUNTER events to ContinuousRuleModifyingEffects. --- .../java/mage/server/game/GameWorker.java | 5 +++- .../sets/avacynrestored/CavernOfSouls.java | 14 +++++------ .../BoseijuWhoSheltersAll.java | 16 ++++++------ Mage.Sets/src/mage/sets/conflux/Banefire.java | 12 +++------ .../src/mage/sets/magic2013/GroundSeal.java | 18 ++++++------- .../sets/magic2014/FiendslayerPaladin.java | 15 +++++++---- .../mage/sets/magic2014/SavageSummoning.java | 24 +++++++++++------- .../mage/sets/shadowmoor/VexingShusher.java | 14 ++++++++--- .../src/mage/sets/tenth/GaeasHerald.java | 20 ++++++--------- .../mage/sets/theros/UnderworldCerberus.java | 10 +++----- .../CantActivateAbilitiesAttachedEffect.java | 11 +++----- .../common/CantCounterControlledEffect.java | 25 ++++++++----------- .../common/CantCounterSourceEffect.java | 11 +++----- .../effects/common/CantTargetEffect.java | 13 +++------- .../common/CantTargetSourceEffect.java | 15 ++++------- .../abilities/effects/common/EpicEffect.java | 1 - .../mage/game/permanent/PermanentImpl.java | 4 +-- Mage/src/mage/game/stack/SpellStack.java | 11 +++++--- 18 files changed, 112 insertions(+), 127 deletions(-) diff --git a/Mage.Server/src/main/java/mage/server/game/GameWorker.java b/Mage.Server/src/main/java/mage/server/game/GameWorker.java index 789ecdee1d..83ab9a874d 100644 --- a/Mage.Server/src/main/java/mage/server/game/GameWorker.java +++ b/Mage.Server/src/main/java/mage/server/game/GameWorker.java @@ -61,10 +61,13 @@ public class GameWorker implements Callable { game.cleanUp(); } catch (MageException ex) { logger.fatal("GameWorker mage error [" + game.getId() + "]" +ex, ex); + ex.printStackTrace(); } catch (Exception e) { - logger.fatal("GameWorker general exception [" + game.getId() + "]" + e, e); + logger.fatal("GameWorker general exception [" + game.getId() + "]" + e.getMessage(), e); + e.printStackTrace(); } catch (Error err) { logger.fatal("GameWorker general error [" + game.getId() + "]" +err, err); + err.printStackTrace(); } return null; } diff --git a/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java b/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java index 392c4ee7dc..f54638f7cb 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java @@ -36,6 +36,7 @@ import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.mana.ColorlessManaAbility; @@ -208,7 +209,7 @@ class CavernOfSoulsWatcher extends Watcher { } } -class CavernOfSoulsCantCounterEffect extends ReplacementEffectImpl { +class CavernOfSoulsCantCounterEffect extends ContinuousRuleModifiyingEffectImpl { public CavernOfSoulsCantCounterEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); @@ -230,17 +231,16 @@ class CavernOfSoulsCantCounterEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - Player caster = game.getPlayer(event.getPlayerId()); + public String getInfoMessage(Ability source, Game game) { MageObject sourceObject = game.getObject(source.getSourceId()); - if (caster != null) { - game.informPlayer(caster, "This spell can't be countered because a colored mana from " + sourceObject.getName() + " was spent to cast it."); + if (sourceObject != null) { + return "This spell can't be countered because a colored mana from " + sourceObject.getName() + " was spent to cast it."; } - return true; + return null; } @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.COUNTER) { CavernOfSoulsWatcher watcher = (CavernOfSoulsWatcher) game.getState().getWatchers().get("ManaPaidFromCavernOfSoulsWatcher"); Spell spell = game.getStack().getSpell(event.getTargetId()); diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java b/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java index a145d7db8c..958a5039b0 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java @@ -37,6 +37,7 @@ import mage.abilities.common.EntersBattlefieldTappedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.PayLifeCost; import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.mana.SimpleManaAbility; import mage.cards.CardImpl; @@ -125,7 +126,7 @@ class BoseijuWhoSheltersAllWatcher extends Watcher { } } -class BoseijuWhoSheltersAllCantCounterEffect extends ReplacementEffectImpl { +class BoseijuWhoSheltersAllCantCounterEffect extends ContinuousRuleModifiyingEffectImpl { private static final FilterCard filter = new FilterInstantOrSorceryCard(); @@ -149,17 +150,16 @@ class BoseijuWhoSheltersAllCantCounterEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - Player player = game.getPlayer(event.getPlayerId()); - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (player != null && spell != null) { - game.informPlayers(new StringBuilder(spell.getName()).append(" can't be countered by spells or abilities (Boseiju, Who Shelters All) - counter ignored").toString()); + public String getInfoMessage(Ability source, Game game) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (sourceObject != null) { + return "This spell can't be countered by spells or abilities (" + sourceObject.getName() + ")."; } - return true; + return null; } @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.COUNTER) { BoseijuWhoSheltersAllWatcher watcher = (BoseijuWhoSheltersAllWatcher) game.getState().getWatchers().get("ManaPaidFromBoseijuWhoSheltersAllWatcher"); Spell spell = game.getStack().getSpell(event.getTargetId()); diff --git a/Mage.Sets/src/mage/sets/conflux/Banefire.java b/Mage.Sets/src/mage/sets/conflux/Banefire.java index 52d11829a0..c9119e0c3a 100644 --- a/Mage.Sets/src/mage/sets/conflux/Banefire.java +++ b/Mage.Sets/src/mage/sets/conflux/Banefire.java @@ -33,6 +33,7 @@ import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.Condition; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.ManacostVariableValue; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.Card; @@ -128,14 +129,14 @@ class BaneFireEffect extends OneShotEffect { return true; } if (targetCreature != null) { - targetCreature.damage(damage, source.getSourceId(), game, preventable, false); + targetCreature.damage(damage, source.getSourceId(), game, false, preventable); return true; } return false; } } -class BanefireCantCounterEffect extends ReplacementEffectImpl { +class BanefireCantCounterEffect extends ContinuousRuleModifiyingEffectImpl { Condition condition = new testCondition(new ManacostVariableValue(), 5); @@ -160,12 +161,7 @@ class BanefireCantCounterEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == EventType.COUNTER) { Card card = game.getCard(source.getSourceId()); if (card != null) { diff --git a/Mage.Sets/src/mage/sets/magic2013/GroundSeal.java b/Mage.Sets/src/mage/sets/magic2013/GroundSeal.java index 3d11dc4c5d..db1cf5f135 100644 --- a/Mage.Sets/src/mage/sets/magic2013/GroundSeal.java +++ b/Mage.Sets/src/mage/sets/magic2013/GroundSeal.java @@ -28,15 +28,18 @@ package mage.sets.magic2013; import java.util.UUID; - -import mage.constants.*; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.Card; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.StackObject; @@ -70,7 +73,7 @@ public class GroundSeal extends CardImpl { } } -class GroundSealEffect extends ReplacementEffectImpl { +class GroundSealEffect extends ContinuousRuleModifiyingEffectImpl { public GroundSealEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); @@ -92,12 +95,7 @@ class GroundSealEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.TARGET) { Card targetCard = game.getCard(event.getTargetId()); StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/magic2014/FiendslayerPaladin.java b/Mage.Sets/src/mage/sets/magic2014/FiendslayerPaladin.java index 74ff771483..66725a2535 100644 --- a/Mage.Sets/src/mage/sets/magic2014/FiendslayerPaladin.java +++ b/Mage.Sets/src/mage/sets/magic2014/FiendslayerPaladin.java @@ -32,7 +32,7 @@ import mage.MageInt; import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.keyword.FirstStrikeAbility; import mage.abilities.keyword.LifelinkAbility; import mage.cards.Card; @@ -44,6 +44,7 @@ import mage.constants.Rarity; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.game.stack.StackObject; /** @@ -83,7 +84,7 @@ public class FiendslayerPaladin extends CardImpl { } } -class FiendslayerPaladinEffect extends ReplacementEffectImpl { +class FiendslayerPaladinEffect extends ContinuousRuleModifiyingEffectImpl { public FiendslayerPaladinEffect() { super(Duration.WhileOnBattlefield, Outcome.BoostCreature); @@ -105,12 +106,16 @@ class FiendslayerPaladinEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public String getInfoMessage(Ability source, Game game) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + if (sourcePermanent != null) { + return sourcePermanent.getLogName() + " can't be the target of black or red spells opponents control"; + } + return null; } @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.TARGET) { Card targetCard = game.getCard(event.getTargetId()); StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/magic2014/SavageSummoning.java b/Mage.Sets/src/mage/sets/magic2014/SavageSummoning.java index a3375a9899..c49352a26d 100644 --- a/Mage.Sets/src/mage/sets/magic2014/SavageSummoning.java +++ b/Mage.Sets/src/mage/sets/magic2014/SavageSummoning.java @@ -33,9 +33,11 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.CantCounterAbility; import mage.abilities.effects.AsThoughEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.Card; import mage.cards.CardImpl; @@ -141,9 +143,9 @@ class SavageSummoningAsThoughEffect extends AsThoughEffectImpl { class SavageSummoningWatcher extends Watcher { - private Set savageSummoningSpells = new HashSet();; - private Map> spellsCastWithSavageSummoning = new LinkedHashMap>(); - private Map> cardsCastWithSavageSummoning = new LinkedHashMap>(); + private Set savageSummoningSpells = new HashSet<>();; + private Map> spellsCastWithSavageSummoning = new LinkedHashMap<>(); + private Map> cardsCastWithSavageSummoning = new LinkedHashMap<>(); public SavageSummoningWatcher() { super("consumeSavageSummoningWatcher", WatcherScope.PLAYER); @@ -171,9 +173,9 @@ class SavageSummoningWatcher extends Watcher { if (isSavageSummoningSpellActive() && event.getPlayerId().equals(getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getCardType().contains(CardType.CREATURE)) { - spellsCastWithSavageSummoning.put(spell.getId(), new HashSet(savageSummoningSpells)); + spellsCastWithSavageSummoning.put(spell.getId(), new HashSet<>(savageSummoningSpells)); String cardKey = new StringBuilder(spell.getCard().getId().toString()).append("_").append(spell.getCard().getZoneChangeCounter()).toString(); - cardsCastWithSavageSummoning.put(cardKey, new HashSet(savageSummoningSpells)); + cardsCastWithSavageSummoning.put(cardKey, new HashSet<>(savageSummoningSpells)); savageSummoningSpells.clear(); } } @@ -219,7 +221,7 @@ class SavageSummoningWatcher extends Watcher { } -class SavageSummoningCantCounterEffect extends ReplacementEffectImpl { +class SavageSummoningCantCounterEffect extends ContinuousRuleModifiyingEffectImpl { private SavageSummoningWatcher watcher; private int zoneChangeCounter; @@ -255,12 +257,16 @@ class SavageSummoningCantCounterEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public String getInfoMessage(Ability source, Game game) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (sourceObject != null) { + return "This creature spell can't be countered (" + sourceObject.getName() + ")."; + } + return null; } @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.COUNTER) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && watcher.isSpellCastWithThisSavageSummoning(spell.getId(), source.getSourceId(), zoneChangeCounter)) { diff --git a/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java b/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java index 9c461bc3f5..d128566058 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java @@ -29,10 +29,12 @@ package mage.sets.shadowmoor; import java.util.UUID; import mage.MageInt; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.CantCounterAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.CardImpl; import mage.constants.CardType; @@ -80,7 +82,7 @@ public class VexingShusher extends CardImpl { } } -class VexingShusherCantCounterTargetEffect extends ReplacementEffectImpl { +class VexingShusherCantCounterTargetEffect extends ContinuousRuleModifiyingEffectImpl { public VexingShusherCantCounterTargetEffect() { super(Duration.EndOfTurn, Outcome.Benefit); @@ -102,12 +104,16 @@ class VexingShusherCantCounterTargetEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public String getInfoMessage(Ability source, Game game) { + MageObject sourceObject = game.getObject(source.getSourceId()); + if (sourceObject != null) { + return "This spell can't be countered by spells or abilities (" + sourceObject.getName() + ")."; + } + return null; } @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { return event.getType() == EventType.COUNTER && event.getTargetId().equals(targetPointer.getFirst(game, source)); } diff --git a/Mage.Sets/src/mage/sets/tenth/GaeasHerald.java b/Mage.Sets/src/mage/sets/tenth/GaeasHerald.java index a1e45cbaf9..db611a9dd0 100644 --- a/Mage.Sets/src/mage/sets/tenth/GaeasHerald.java +++ b/Mage.Sets/src/mage/sets/tenth/GaeasHerald.java @@ -27,15 +27,17 @@ */ package mage.sets.tenth; - import java.util.UUID; - -import mage.constants.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.Spell; @@ -70,8 +72,7 @@ public class GaeasHerald extends CardImpl { } -class CantCounterEffect extends ReplacementEffectImpl { - +class CantCounterEffect extends ContinuousRuleModifiyingEffectImpl { public CantCounterEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); @@ -94,12 +95,7 @@ class CantCounterEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.COUNTER) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getCardType().contains(CardType.CREATURE)) { diff --git a/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java b/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java index ae2f52af93..ed568339c2 100644 --- a/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java +++ b/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java @@ -32,6 +32,7 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.ExileSourceEffect; import mage.abilities.effects.common.ReturnToHandFromGraveyardAllEffect; @@ -84,7 +85,7 @@ public class UnderworldCerberus extends CardImpl { } } -class UnderworldCerberusEffect extends ReplacementEffectImpl { +class UnderworldCerberusEffect extends ContinuousRuleModifiyingEffectImpl { public UnderworldCerberusEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); @@ -106,12 +107,7 @@ class UnderworldCerberusEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.TARGET) { Card targetCard = game.getCard(event.getTargetId()); StackObject stackObject = (StackObject) game.getStack().getStackObject(event.getSourceId()); diff --git a/Mage/src/mage/abilities/effects/common/CantActivateAbilitiesAttachedEffect.java b/Mage/src/mage/abilities/effects/common/CantActivateAbilitiesAttachedEffect.java index 1fbfcac616..d8b27eb95e 100644 --- a/Mage/src/mage/abilities/effects/common/CantActivateAbilitiesAttachedEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantActivateAbilitiesAttachedEffect.java @@ -28,7 +28,7 @@ package mage.abilities.effects.common; import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.constants.Duration; import mage.constants.Outcome; import mage.game.Game; @@ -40,7 +40,7 @@ import mage.game.permanent.Permanent; * @author LevelX2 */ -public class CantActivateAbilitiesAttachedEffect extends ReplacementEffectImpl { +public class CantActivateAbilitiesAttachedEffect extends ContinuousRuleModifiyingEffectImpl { public CantActivateAbilitiesAttachedEffect() { super(Duration.WhileOnBattlefield, Outcome.UnboostCreature); @@ -62,12 +62,7 @@ public class CantActivateAbilitiesAttachedEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { Permanent enchantment = game.getPermanent(source.getSourceId()); if (enchantment != null && enchantment.getAttachedTo() != null) { diff --git a/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java b/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java index 1a9005f13f..9d4b81679f 100644 --- a/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantCounterControlledEffect.java @@ -28,11 +28,11 @@ package mage.abilities.effects.common; -import mage.constants.Duration; -import mage.constants.Outcome; import mage.MageObject; import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; +import mage.constants.Duration; +import mage.constants.Outcome; import mage.filter.FilterObject; import mage.filter.FilterSpell; import mage.game.Game; @@ -44,7 +44,7 @@ import mage.game.stack.Spell; * * @author BetaSteward_at_googlemail.com */ -public class CantCounterControlledEffect extends ReplacementEffectImpl { +public class CantCounterControlledEffect extends ContinuousRuleModifiyingEffectImpl { private FilterSpell filterTarget; private FilterObject filterSource; @@ -62,10 +62,12 @@ public class CantCounterControlledEffect extends ReplacementEffectImpl { public CantCounterControlledEffect(final CantCounterControlledEffect effect) { super(effect); - if (effect.filterTarget != null) + if (effect.filterTarget != null) { this.filterTarget = effect.filterTarget.copy(); - if (effect.filterSource != null) + } + if (effect.filterSource != null) { this.filterSource = effect.filterSource.copy(); + } } @Override @@ -79,19 +81,14 @@ public class CantCounterControlledEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == EventType.COUNTER) { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getControllerId().equals(source.getControllerId()) && filterTarget.match(spell, game)) { - if (filterSource == null) + if (filterSource == null) { return true; - else { + } else { MageObject sourceObject = game.getObject(source.getSourceId()); if (sourceObject != null && filterSource.match(sourceObject, game)) { return true; diff --git a/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java b/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java index e86a6dc8b5..bd136b89bb 100644 --- a/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantCounterSourceEffect.java @@ -30,7 +30,7 @@ package mage.abilities.effects.common; import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.cards.Card; import mage.constants.Duration; import mage.constants.Outcome; @@ -42,7 +42,7 @@ import mage.game.events.GameEvent.EventType; * * @author BetaSteward_at_googlemail.com */ -public class CantCounterSourceEffect extends ReplacementEffectImpl { +public class CantCounterSourceEffect extends ContinuousRuleModifiyingEffectImpl { public CantCounterSourceEffect() { super(Duration.WhileOnStack, Outcome.Benefit); @@ -64,12 +64,7 @@ public class CantCounterSourceEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == EventType.COUNTER) { Card card = game.getCard(source.getSourceId()); if (card != null) { diff --git a/Mage/src/mage/abilities/effects/common/CantTargetEffect.java b/Mage/src/mage/abilities/effects/common/CantTargetEffect.java index c1ad025a2d..386f96b819 100644 --- a/Mage/src/mage/abilities/effects/common/CantTargetEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantTargetEffect.java @@ -28,10 +28,10 @@ package mage.abilities.effects.common; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.constants.Duration; import mage.constants.Outcome; -import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; import mage.filter.FilterPermanent; import mage.filter.FilterStackObject; import mage.game.Game; @@ -44,7 +44,7 @@ import mage.game.stack.StackObject; * * @author BetaSteward_at_googlemail.com */ -public class CantTargetEffect extends ReplacementEffectImpl { +public class CantTargetEffect extends ContinuousRuleModifiyingEffectImpl { private FilterPermanent filterTarget; private FilterStackObject filterSource; @@ -82,12 +82,7 @@ public class CantTargetEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == EventType.TARGET) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && filterTarget.match(permanent, source.getSourceId(), source.getControllerId(), game)) { diff --git a/Mage/src/mage/abilities/effects/common/CantTargetSourceEffect.java b/Mage/src/mage/abilities/effects/common/CantTargetSourceEffect.java index a6781650fb..bd6dddf2a9 100644 --- a/Mage/src/mage/abilities/effects/common/CantTargetSourceEffect.java +++ b/Mage/src/mage/abilities/effects/common/CantTargetSourceEffect.java @@ -28,10 +28,10 @@ package mage.abilities.effects.common; +import mage.abilities.Ability; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.constants.Duration; import mage.constants.Outcome; -import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; import mage.filter.FilterStackObject; import mage.game.Game; import mage.game.events.GameEvent; @@ -42,9 +42,9 @@ import mage.game.stack.StackObject; * * @author BetaSteward_at_googlemail.com */ -public class CantTargetSourceEffect extends ReplacementEffectImpl { +public class CantTargetSourceEffect extends ContinuousRuleModifiyingEffectImpl { - private FilterStackObject filterSource; + private final FilterStackObject filterSource; public CantTargetSourceEffect(FilterStackObject filterSource, Duration duration) { super(duration, Outcome.Benefit); @@ -68,12 +68,7 @@ public class CantTargetSourceEffect extends ReplacementEffectImpl { } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { + public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) { if (event.getType() == EventType.TARGET && event.getTargetId().equals(source.getSourceId())) { StackObject sourceObject = game.getStack().getStackObject(event.getSourceId()); if (sourceObject != null && filterSource.match(sourceObject, source.getControllerId(), game)) { diff --git a/Mage/src/mage/abilities/effects/common/EpicEffect.java b/Mage/src/mage/abilities/effects/common/EpicEffect.java index 4fe5c58d37..48516ad6ca 100644 --- a/Mage/src/mage/abilities/effects/common/EpicEffect.java +++ b/Mage/src/mage/abilities/effects/common/EpicEffect.java @@ -11,7 +11,6 @@ import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredA import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; -import mage.abilities.effects.ReplacementEffectImpl; import mage.constants.Duration; import mage.constants.Outcome; import mage.game.Game; diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index f92ee4e698..330f894d00 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -750,9 +750,9 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { if (hasProtectionFrom(source, game)) { return false; } - // needed to get the correct possible targets if target replacement effects are active + // needed to get the correct possible targets if target rule modification effects are active // e.g. Fiendslayer Paladin tried to target with Ultimate Price - if (game.replaceEvent(GameEvent.getEvent(EventType.TARGET, this.getId(), source.getId(), sourceControllerId))) { + if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.TARGET, this.getId(), source.getId(), sourceControllerId), game, true)) { return false; } } diff --git a/Mage/src/mage/game/stack/SpellStack.java b/Mage/src/mage/game/stack/SpellStack.java index 3e221ec5de..14fb35ddf1 100644 --- a/Mage/src/mage/game/stack/SpellStack.java +++ b/Mage/src/mage/game/stack/SpellStack.java @@ -30,6 +30,7 @@ package mage.game.stack; import java.util.ArrayDeque; import java.util.UUID; +import mage.MageObject; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; @@ -73,18 +74,20 @@ public class SpellStack extends ArrayDeque { public boolean counter(UUID objectId, UUID sourceId, Game game) { StackObject stackObject = getStackObject(objectId); - if (stackObject != null) { + MageObject sourceObject = game.getObject(sourceId); + if (stackObject != null && sourceObject != null) { if (!game.replaceEvent(GameEvent.getEvent(GameEvent.EventType.COUNTER, objectId, sourceId, stackObject.getControllerId()))) { if ( stackObject instanceof Spell ) { game.rememberLKI(objectId, Zone.STACK, (Spell)stackObject); } this.remove(stackObject); stackObject.counter(sourceId, game); - game.informPlayers(new StringBuilder(stackObject.getName()).append(" is countered").toString()); + game.informPlayers(new StringBuilder(stackObject.getName()).append(" is countered by ").append(sourceObject.getLogName()).toString()); game.fireEvent(GameEvent.getEvent(GameEvent.EventType.COUNTERED, objectId, sourceId, stackObject.getControllerId())); - return true; + } else { + game.informPlayers(new StringBuilder(stackObject.getName()).append(" could not be countered by ").append(sourceObject.getLogName()).toString()); } - return false; + return true; } return false; }