Changed ReplacementEffects to ContinuousRuleModifyingEffects for 10 objects.

This commit is contained in:
LevelX2 2014-07-25 13:11:14 +02:00
parent 05a2e09b2a
commit 54570bac59
10 changed files with 98 additions and 123 deletions

View file

@ -34,6 +34,7 @@ import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -112,7 +113,7 @@ class GrafdiggersCageEffect extends ReplacementEffectImpl {
}
class GrafdiggersCageEffect2 extends ReplacementEffectImpl {
class GrafdiggersCageEffect2 extends ContinuousRuleModifiyingEffectImpl {
public GrafdiggersCageEffect2() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
@ -134,12 +135,7 @@ class GrafdiggersCageEffect2 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.CAST_SPELL) {
Card card = game.getCard(event.getSourceId());
if (card != null) {

View file

@ -55,6 +55,7 @@ import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
/**
* GATECRASH FAQ 11.01.2013
@ -147,7 +148,7 @@ class AureliasFuryEffect extends OneShotEffect {
}
}
class AureliasFuryCantCastEffect extends ReplacementEffectImpl {
class AureliasFuryCantCastEffect extends ContinuousRuleModifiyingEffectImpl {
public AureliasFuryCantCastEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
@ -169,12 +170,16 @@ class AureliasFuryCantCastEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
public String getInfoMessage(Ability source, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
return "You can't cast noncreature spells this turn (you were dealt damage by " + mageObject.getLogName() + ")";
}
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.CAST_SPELL ) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null && player.getId().equals(event.getPlayerId())) {
@ -190,8 +195,8 @@ class AureliasFuryCantCastEffect extends ReplacementEffectImpl {
class AureliasFuryDamagedByWatcher extends Watcher {
public List<UUID> damagedCreatures = new ArrayList<UUID>();
public List<UUID> damagedPlayers = new ArrayList<UUID>();
public List<UUID> damagedCreatures = new ArrayList<>();
public List<UUID> damagedPlayers = new ArrayList<>();
public AureliasFuryDamagedByWatcher() {
super("AureliasFuryDamagedByWatcher", WatcherScope.CARD);

View file

@ -38,12 +38,14 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
/**
@ -60,11 +62,15 @@ public class AngelicArbiter extends CardImpl {
this.power = new MageInt(5);
this.toughness = new MageInt(6);
// Flying
this.addAbility(FlyingAbility.getInstance());
// Each opponent who cast a spell this turn can't attack with creatures.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AngelicArbiterCantAttackTargetEffect(Duration.WhileOnBattlefield)));
this.addWatcher(new AngelicArbiterWatcher1());
this.addWatcher(new AngelicArbiterWatcher2());
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AngelicArbiterEffect1()));
// Each opponent who attacked with a creature this turn can't cast spells.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AngelicArbiterEffect2()));
this.addWatcher(new AngelicArbiterWatcher2());
}
public AngelicArbiter(final AngelicArbiter card) {
@ -95,10 +101,12 @@ class AngelicArbiterWatcher1 extends Watcher {
@Override
public void watch(GameEvent event, Game game) {
if (condition == true) //no need to check - condition has already occured
if (condition == true) { //no need to check - condition has already occured
return;
if (event.getType() == EventType.SPELL_CAST && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(controllerId).contains(event.getPlayerId()))
}
if (event.getType() == EventType.SPELL_CAST && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(controllerId).contains(event.getPlayerId())) {
condition = true;
}
}
}
@ -120,51 +128,46 @@ class AngelicArbiterWatcher2 extends Watcher {
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == EventType.DECLARED_ATTACKERS && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(controllerId).contains(event.getPlayerId()))
if (event.getType() == EventType.DECLARED_ATTACKERS && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(controllerId).contains(event.getPlayerId())) {
condition = true;
}
}
}
class AngelicArbiterEffect1 extends ReplacementEffectImpl {
class AngelicArbiterCantAttackTargetEffect extends RestrictionEffect {
public AngelicArbiterEffect1() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
}
public AngelicArbiterEffect1(final AngelicArbiterEffect1 effect) {
super(effect);
public AngelicArbiterCantAttackTargetEffect(Duration duration) {
super(duration);
staticText = "Each opponent who cast a spell this turn can't attack with creatures";
}
@Override
public AngelicArbiterEffect1 copy() {
return new AngelicArbiterEffect1(this);
public AngelicArbiterCantAttackTargetEffect(final AngelicArbiterCantAttackTargetEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.DECLARE_ATTACKER && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
public boolean applies(Permanent permanent, Ability source, Game game) {
if (game.getActivePlayerId().equals(permanent.getControllerId()) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId())) {
Watcher watcher = game.getState().getWatchers().get("OpponentCastSpell", source.getControllerId());
if (watcher != null && watcher.conditionMet())
if (watcher != null && watcher.conditionMet()) {
return true;
}
}
return false;
}
@Override
public boolean canAttack(Game game) {
return false;
}
@Override
public AngelicArbiterCantAttackTargetEffect copy() {
return new AngelicArbiterCantAttackTargetEffect(this);
}
}
class AngelicArbiterEffect2 extends ReplacementEffectImpl {
class AngelicArbiterEffect2 extends ContinuousRuleModifiyingEffectImpl {
public AngelicArbiterEffect2() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
@ -186,16 +189,12 @@ class AngelicArbiterEffect2 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.CAST_SPELL && game.getActivePlayerId().equals(event.getPlayerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
Watcher watcher = game.getState().getWatchers().get("OpponentAttacked", source.getControllerId());
if (watcher != null && watcher.conditionMet())
if (watcher != null && watcher.conditionMet()) {
return true;
}
}
return false;
}

View file

@ -32,7 +32,7 @@ import mage.MageInt;
import mage.MageObject;
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;
@ -42,6 +42,7 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
/**
* @author nantuko
@ -72,11 +73,11 @@ public class GrandAbolisher extends CardImpl {
}
}
class GrandAbolisherEffect extends ReplacementEffectImpl {
class GrandAbolisherEffect extends ContinuousRuleModifiyingEffectImpl {
public GrandAbolisherEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = "During your turn, your opponents can't cast spells or activate abilities of artifacts, creatures, or enchantments";
staticText = "During your turn, your opponents can't cast spells or activate abilities of artifacts, creatures, or enchantments";
}
public GrandAbolisherEffect(final GrandAbolisherEffect effect) {
@ -94,12 +95,18 @@ class GrandAbolisherEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
public String getInfoMessage(Ability source, Game game) {
Player activePlayer = game.getPlayer(game.getActivePlayerId());
MageObject mageObject = game.getObject(source.getSourceId());
if (activePlayer != null && mageObject != null) {
return "You can't cast spells or activate abilities of artifacts, creatures, or enchantments during the turns of " + activePlayer.getName() +
" (" + mageObject.getLogName() + ")";
}
return null;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
boolean spell = event.getType() == GameEvent.EventType.CAST_SPELL;
boolean activated = event.getType() == GameEvent.EventType.ACTIVATE_ABILITY;
if ((spell || activated) && game.getActivePlayerId().equals(source.getControllerId()) && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {

View file

@ -36,6 +36,7 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -76,10 +77,10 @@ public class IllusoryAngel extends CardImpl {
}
}
class IllusoryAngelEffect extends ReplacementEffectImpl {
class IllusoryAngelEffect extends ContinuousRuleModifiyingEffectImpl {
IllusoryAngelEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast Illusory Angel only if you've cast another spell this turn";
staticText = "Cast {this} only if you've cast another spell this turn";
}
IllusoryAngelEffect(final IllusoryAngelEffect effect) {
@ -87,12 +88,7 @@ class IllusoryAngelEffect 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.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get("CastSpellLastTurnWatcher");
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) {

View file

@ -30,11 +30,10 @@ package mage.sets.returntoravnica;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.ActivatedAbility;
import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.common.OpponentsLostLifeCount;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.abilities.keyword.FlyingAbility;
@ -91,7 +90,7 @@ public class RakdosLordOfRiots extends CardImpl {
}
}
class RakdosLordOfRiotsCantCastEffect extends ReplacementEffectImpl {
class RakdosLordOfRiotsCantCastEffect extends ContinuousRuleModifiyingEffectImpl {
public RakdosLordOfRiotsCantCastEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -113,16 +112,7 @@ class RakdosLordOfRiotsCantCastEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
game.informPlayer(controller, "You can't cast Rakdos, Lord of Riots because your opponents lost no life this turn yet");
}
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.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) {
if (new OpponentsLostLifeCount().calculate(game, source) == 0) {
return true;

View file

@ -34,7 +34,7 @@ import mage.MageInt;
import mage.MageObject;
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.game.Game;
import mage.game.events.GameEvent;
@ -67,7 +67,7 @@ public class SteelGolem extends CardImpl {
}
}
class SteelGolemEffect extends ReplacementEffectImpl {
class SteelGolemEffect extends ContinuousRuleModifiyingEffectImpl {
public SteelGolemEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -89,12 +89,7 @@ class SteelGolemEffect 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.CAST_SPELL && event.getPlayerId().equals(source.getControllerId())) {
MageObject object = game.getObject(event.getSourceId());
if (object.getCardType().contains(CardType.CREATURE)) {

View file

@ -36,6 +36,7 @@ import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.VigilanceAbility;
@ -81,7 +82,7 @@ public class SerraAvenger extends CardImpl {
}
}
class CantCastSerraAvengerEffect extends ReplacementEffectImpl {
class CantCastSerraAvengerEffect extends ContinuousRuleModifiyingEffectImpl {
public CantCastSerraAvengerEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -103,16 +104,7 @@ class CantCastSerraAvengerEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
game.informPlayer(controller, "You can't cast Serra Avenger during your first, second, or third turns of the 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.CAST_SPELL && event.getSourceId().equals(source.getSourceId())) {
Player controller = game.getPlayer(source.getControllerId());
// it can be cast on other players turn 1 - 3 if some effect let allow you to do this

View file

@ -29,11 +29,12 @@ package mage.sets.torment;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
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.ReturnToHandFromBattlefieldAllEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -80,7 +81,7 @@ public class LlawanCephalidEmpress extends CardImpl {
this.addAbility(new EntersBattlefieldTriggeredAbility(new ReturnToHandFromBattlefieldAllEffect(filter), false));
// Your opponents can't cast blue creature spells.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LlawanCephalidEmpressReplacementEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LlawanCephalidRuleModifyingEffect()));
}
public LlawanCephalidEmpress(final LlawanCephalidEmpress card) {
@ -94,7 +95,7 @@ public class LlawanCephalidEmpress extends CardImpl {
}
class LlawanCephalidEmpressReplacementEffect extends ReplacementEffectImpl {
class LlawanCephalidRuleModifyingEffect extends ContinuousRuleModifiyingEffectImpl {
private static final FilterCard filter = new FilterCard("blue creature spells");
@ -103,32 +104,36 @@ class LlawanCephalidEmpressReplacementEffect extends ReplacementEffectImpl {
filter.add(new CardTypePredicate(CardType.CREATURE));
}
public LlawanCephalidEmpressReplacementEffect() {
public LlawanCephalidRuleModifyingEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Your opponents can't cast blue creature spells";
}
public LlawanCephalidEmpressReplacementEffect(final LlawanCephalidEmpressReplacementEffect effect) {
public LlawanCephalidRuleModifyingEffect(final LlawanCephalidRuleModifyingEffect effect) {
super(effect);
}
@Override
public LlawanCephalidEmpressReplacementEffect copy() {
return new LlawanCephalidEmpressReplacementEffect(this);
public LlawanCephalidRuleModifyingEffect copy() {
return new LlawanCephalidRuleModifyingEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
public String getInfoMessage(Ability source, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
return "You can't cast blue creature spells (" + mageObject.getLogName() + " in play).";
}
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.CAST_SPELL) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && game.isOpponent(controller, event.getPlayerId())) {

View file

@ -31,6 +31,7 @@ package mage.abilities.effects.common.continious;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -46,7 +47,7 @@ import mage.watchers.common.CastSpellLastTurnWatcher;
* @author LevelX2
*/
public class CantCastMoreThanOneSpellEffect extends ReplacementEffectImpl {
public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifiyingEffectImpl {
private final TargetController targetController;
@ -71,18 +72,7 @@ public class CantCastMoreThanOneSpellEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
Player caster = game.getPlayer(event.getPlayerId());
if (mageObject != null && caster != null) {
game.informPlayer(caster, mageObject.getName() + ": You can't cast more than one spell each turn.");
}
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.CAST_SPELL) {
switch (targetController) {
case YOU: