* 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

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