* Changed ReplacementEffects for TARGET and COUNTER events to ContinuousRuleModifyingEffects.

This commit is contained in:
LevelX2 2014-07-28 08:21:17 +02:00
parent e22174b148
commit f51e7722cc
18 changed files with 112 additions and 127 deletions

View file

@ -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;
}

View file

@ -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());

View file

@ -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());

View file

@ -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) {

View file

@ -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());

View file

@ -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());

View file

@ -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<String> savageSummoningSpells = new HashSet<String>();;
private Map<UUID, Set<String>> spellsCastWithSavageSummoning = new LinkedHashMap<UUID, Set<String>>();
private Map<String, Set<String>> cardsCastWithSavageSummoning = new LinkedHashMap<String, Set<String>>();
private Set<String> savageSummoningSpells = new HashSet<>();;
private Map<UUID, Set<String>> spellsCastWithSavageSummoning = new LinkedHashMap<>();
private Map<String, Set<String>> 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<String>(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<String>(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)) {

View file

@ -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));
}

View file

@ -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)) {

View file

@ -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());

View file

@ -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) {

View file

@ -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,11 +62,13 @@ 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
public CantCounterControlledEffect copy() {
@ -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;

View file

@ -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) {

View file

@ -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)) {

View file

@ -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)) {

View file

@ -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;

View file

@ -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;
}
}

View file

@ -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<StackObject> {
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;
}