More replacement effects switched to continuous rule modyfing effect.

This commit is contained in:
LevelX2 2014-07-26 00:47:29 +02:00
parent e25a60b312
commit e8edf39f51
31 changed files with 383 additions and 268 deletions

View file

@ -38,8 +38,8 @@ import mage.MageObject;
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.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
@ -47,7 +47,9 @@ import mage.choices.ChoiceImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -97,7 +99,8 @@ class MeddlingMageChooseCardEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
@ -107,8 +110,10 @@ class MeddlingMageChooseCardEffect extends OneShotEffect {
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("MeddlingMage, named card: [" + cardName + "]");
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"));
return true;
}
return false;
}
@ -120,7 +125,7 @@ class MeddlingMageChooseCardEffect extends OneShotEffect {
}
class MeddlingMageReplacementEffect extends ReplacementEffectImpl {
class MeddlingMageReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
public MeddlingMageReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -142,12 +147,16 @@ class MeddlingMageReplacementEffect 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 a card with that name (" + 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() == EventType.CAST_SPELL) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) {

View file

@ -28,13 +28,16 @@
package mage.sets.championsofkamigawa;
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;
@ -69,7 +72,8 @@ public class DosanTheFallingLeaf extends CardImpl {
}
}
class DosanTheFallingLeafEffect extends ReplacementEffectImpl {
class DosanTheFallingLeafEffect extends ContinuousRuleModifiyingEffectImpl {
DosanTheFallingLeafEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Players can cast spells only during their own turns";
@ -80,12 +84,7 @@ class DosanTheFallingLeafEffect 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) {
return event.getType() == GameEvent.EventType.CAST_SPELL && !game.getActivePlayerId().equals(event.getPlayerId());
}

View file

@ -28,24 +28,23 @@
package mage.sets.commander;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.common.combat.AttacksIfAbleTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
import mage.abilities.keyword.AttacksThisTurnMarkerAbility;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TurnPhase;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.target.common.TargetCreaturePermanent;
@ -91,7 +90,7 @@ public class BasandraBattleSeraph extends CardImpl {
}
}
class BasandraBattleSeraphEffect extends ReplacementEffectImpl {
class BasandraBattleSeraphEffect extends ContinuousRuleModifiyingEffectImpl {
public BasandraBattleSeraphEffect() {
super(Duration.EndOfTurn, Outcome.Neutral);
@ -113,12 +112,7 @@ class BasandraBattleSeraphEffect 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
&& game.getPhase().getType() == TurnPhase.COMBAT) {
return true;

View file

@ -32,6 +32,7 @@ import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.RequirementEffect;
@ -79,7 +80,7 @@ public class IllusionistsGambit extends CardImpl {
}
}
class IllusionistsGambitEffect extends ReplacementEffectImpl {
class IllusionistsGambitEffect extends ContinuousRuleModifiyingEffectImpl {
IllusionistsGambitEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast {this} only during the declare blockers step on an opponent's turn";
@ -90,12 +91,7 @@ class IllusionistsGambitEffect 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().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
if (game.getTurn().getStepType().equals(PhaseStep.DECLARE_BLOCKERS)) {
return !game.getOpponents(source.getControllerId()).contains(game.getActivePlayerId());
@ -209,8 +205,8 @@ class IllusionistsGambitRequirementEffect extends RequirementEffect {
class IllusionistsGambitReplacementEffect extends ReplacementEffectImpl {
private List attackers;
private Phase phase;
private final List attackers;
private final Phase phase;
IllusionistsGambitReplacementEffect(List attackers, Phase phase) {
super(Duration.Custom, Outcome.Benefit);

View file

@ -32,6 +32,7 @@ import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility;
@ -111,7 +112,7 @@ class CurseOfExhaustionWatcher extends Watcher {
}
class CurseOfExhaustionEffect extends ReplacementEffectImpl {
class CurseOfExhaustionEffect extends ContinuousRuleModifiyingEffectImpl {
public CurseOfExhaustionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
@ -133,12 +134,7 @@ class CurseOfExhaustionEffect 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) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {

View file

@ -40,9 +40,9 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
@ -53,6 +53,7 @@ import mage.constants.CostModificationType;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
@ -109,7 +110,8 @@ class CouncilOfTheAbsoluteChooseCardEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandAndNonCreatureNames());
cardChoice.clearChoice();
@ -119,8 +121,10 @@ class CouncilOfTheAbsoluteChooseCardEffect extends OneShotEffect {
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Council of the Absolute, named card: [" + cardName + "]");
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"));
return true;
}
return false;
}
@ -132,7 +136,7 @@ class CouncilOfTheAbsoluteChooseCardEffect extends OneShotEffect {
}
class CouncilOfTheAbsoluteReplacementEffect extends ReplacementEffectImpl {
class CouncilOfTheAbsoluteReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
public CouncilOfTheAbsoluteReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -154,12 +158,16 @@ class CouncilOfTheAbsoluteReplacementEffect 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 a card with that name (" + 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() == EventType.CAST_SPELL && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) {

View file

@ -29,16 +29,16 @@
package mage.sets.dragonsmaze;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.MulticoloredPredicate;
import mage.game.Game;
@ -116,7 +116,7 @@ class RenderSilentCounterEffect extends OneShotEffect {
}
class RenderSilentEffect extends ReplacementEffectImpl {
class RenderSilentEffect extends ContinuousRuleModifiyingEffectImpl {
public RenderSilentEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
@ -138,12 +138,16 @@ class RenderSilentEffect 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 spells this turn (" + 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())) {

View file

@ -28,17 +28,17 @@
package mage.sets.eventide;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.condition.common.ManaWasSpentCondition;
import mage.abilities.decorator.ConditionalReplacementEffect;
import mage.abilities.effects.ReplacementEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.decorator.ConditionalContinuousRuleModifyingEffect;
import mage.abilities.effects.ContinuousRuleModifiyingEffect;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.ColoredManaSymbol;
import mage.constants.Duration;
import mage.constants.ManaType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.game.Game;
@ -59,14 +59,14 @@ public class Moonhold extends CardImpl {
this.color.setWhite(true);
// Target player can't play land cards this turn if {R} was spent to cast Moonhold and can't play creature cards this turn if {W} was spent to cast it.
ReplacementEffect effect = new MoonholdEffect();
ReplacementEffect effect2 = new MoonholdEffect2();
ContinuousRuleModifiyingEffect effect = new MoonholdEffect();
ContinuousRuleModifiyingEffect effect2 = new MoonholdEffect2();
effect.setText("Target player can't play land cards this turn if {R} was spent to cast {this} ");
effect2.setText("and can't play creature cards this turn if {W} was spent to cast it.");
this.getSpellAbility().addEffect(new ConditionalReplacementEffect(
this.getSpellAbility().addEffect(new ConditionalContinuousRuleModifyingEffect(
effect,
new ManaWasSpentCondition(ColoredManaSymbol.R), false));
this.getSpellAbility().addEffect(new ConditionalReplacementEffect(
this.getSpellAbility().addEffect(new ConditionalContinuousRuleModifyingEffect(
effect2,
new ManaWasSpentCondition(ColoredManaSymbol.W), false));
this.getSpellAbility().addTarget(new TargetPlayer());
@ -83,7 +83,7 @@ public class Moonhold extends CardImpl {
}
}
class MoonholdEffect extends ReplacementEffectImpl {
class MoonholdEffect extends ContinuousRuleModifiyingEffectImpl {
public MoonholdEffect() {
super(Duration.EndOfTurn, Outcome.Detriment);
@ -104,12 +104,16 @@ class MoonholdEffect 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 play land cards this turn (" + 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.PLAY_LAND
&& event.getPlayerId().equals(source.getFirstTarget())) {
return true;
@ -118,7 +122,7 @@ class MoonholdEffect extends ReplacementEffectImpl {
}
}
class MoonholdEffect2 extends ReplacementEffectImpl {
class MoonholdEffect2 extends ContinuousRuleModifiyingEffectImpl {
public MoonholdEffect2() {
super(Duration.EndOfTurn, Outcome.Detriment);
@ -139,12 +143,16 @@ class MoonholdEffect2 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 play creature cards this turn (" + 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
&& event.getPlayerId().equals(source.getFirstTarget())) {
Card card = game.getCard(event.getSourceId());
@ -154,4 +162,4 @@ class MoonholdEffect2 extends ReplacementEffectImpl {
}
return false;
}
}
}

View file

@ -33,6 +33,7 @@ import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
@ -85,7 +86,7 @@ public class TalarasBattalion extends CardImpl {
}
}
class TalarasBattalionEffect extends ReplacementEffectImpl {
class TalarasBattalionEffect extends ContinuousRuleModifiyingEffectImpl {
TalarasBattalionEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
@ -97,12 +98,7 @@ class TalarasBattalionEffect 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())) {
CastGreenSpellThisTurnCondition condition = new CastGreenSpellThisTurnCondition();
@ -142,7 +138,7 @@ class TalarasBattalionWatcher extends Watcher {
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
private UUID cardId;
private final UUID cardId;
public TalarasBattalionWatcher(UUID cardId) {
super("TalarasBattalionWatcher", WatcherScope.PLAYER);

View file

@ -28,8 +28,10 @@
package mage.sets.eventide;
import java.util.UUID;
import mage.MageObject;
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;
@ -72,7 +74,7 @@ public class WardOfBones extends CardImpl {
}
}
class WardOfBonesEffect extends ReplacementEffectImpl {
class WardOfBonesEffect extends ContinuousRuleModifiyingEffectImpl {
public WardOfBonesEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit);
@ -94,12 +96,16 @@ class WardOfBonesEffect 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 play the land or cast the spell (" + 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.PLAY_LAND
|| event.getType() == GameEvent.EventType.CAST_SPELL
&& game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
@ -108,22 +114,22 @@ class WardOfBonesEffect extends ReplacementEffectImpl {
if (card == null || opponent == null) {
return false;
}
final int yourCreatures = game.getBattlefield().countAll(new FilterCreaturePermanent(), source.getControllerId(), game);
final int yourArtifacts = game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game);
final int yourEnchantments = game.getBattlefield().countAll(new FilterEnchantmentPermanent(), source.getControllerId(), game);
final int yourLands = game.getBattlefield().countAll(new FilterLandPermanent(), source.getControllerId(), game);
if (card.getCardType().contains(CardType.CREATURE)
&& game.getBattlefield().countAll(new FilterCreaturePermanent(), opponent.getId(), game) > yourCreatures) {
&& game.getBattlefield().countAll(new FilterCreaturePermanent(), opponent.getId(), game)
> game.getBattlefield().countAll(new FilterCreaturePermanent(), source.getControllerId(), game)) {
return true;
}
if (card.getCardType().contains(CardType.ARTIFACT)
&& game.getBattlefield().countAll(new FilterArtifactPermanent(), opponent.getId(), game) > yourArtifacts) {
&& game.getBattlefield().countAll(new FilterArtifactPermanent(), opponent.getId(), game)
> game.getBattlefield().countAll(new FilterArtifactPermanent(), source.getControllerId(), game)) {
return true;
}
if (card.getCardType().contains(CardType.ENCHANTMENT)
&& game.getBattlefield().countAll(new FilterEnchantmentPermanent(), opponent.getId(), game) > yourEnchantments) {
&& game.getBattlefield().countAll(new FilterEnchantmentPermanent(), opponent.getId(), game)
> game.getBattlefield().countAll(new FilterEnchantmentPermanent(), source.getControllerId(), game)) {
return true;
}
final int yourLands = game.getBattlefield().countAll(new FilterLandPermanent(), source.getControllerId(), game);
if (card.getCardType().contains(CardType.LAND)
&& game.getBattlefield().countAll(new FilterLandPermanent(), opponent.getId(), game) > yourLands) {
return true;

View file

@ -28,25 +28,27 @@
package mage.sets.innistrad;
import java.util.UUID;
import mage.MageObject;
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.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -77,6 +79,7 @@ public class Nevermore extends CardImpl {
}
}
class NevermoreEffect1 extends OneShotEffect {
public NevermoreEffect1() {
@ -91,7 +94,8 @@ class NevermoreEffect1 extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
@ -101,8 +105,10 @@ class NevermoreEffect1 extends OneShotEffect {
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("Nevermore, named card: [" + cardName + "]");
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"));
return true;
}
return false;
}
@ -114,7 +120,7 @@ class NevermoreEffect1 extends OneShotEffect {
}
class NevermoreEffect2 extends ReplacementEffectImpl {
class NevermoreEffect2 extends ContinuousRuleModifiyingEffectImpl {
public NevermoreEffect2() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -136,12 +142,7 @@ class NevermoreEffect2 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) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) {

View file

@ -32,9 +32,9 @@ import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.UntapTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
import mage.abilities.effects.common.continious.GainControlTargetEffect;
@ -97,7 +97,7 @@ public class SpinalEmbrace extends CardImpl {
}
}
class SpinalEmbraceEffect extends ReplacementEffectImpl {
class SpinalEmbraceEffect extends ContinuousRuleModifiyingEffectImpl {
SpinalEmbraceEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast {this} only during combat";
@ -108,12 +108,7 @@ class SpinalEmbraceEffect 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().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
return !game.getTurn().getPhaseType().equals(TurnPhase.COMBAT);
}

View file

@ -37,6 +37,7 @@ import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.continious.BoostEquippedEffect;
@ -82,7 +83,7 @@ public class Godsend extends CardImpl {
// Whenever equipped creature blocks or becomes blocked by one or more creatures, you may exile one of those creatures.
this.addAbility(new GodsendTriggeredAbility());
// Opponents can't cast cards with the same name as cards exiled with Godsend.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GodsendReplacementEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GodsendRuleModifyingEffect()));
// Equip {3}
this.addAbility(new EquipAbility(Outcome.BoostCreature, new GenericManaCost(3)));
}
@ -199,14 +200,14 @@ class GodsendExileEffect extends OneShotEffect {
}
}
class GodsendReplacementEffect extends ReplacementEffectImpl {
class GodsendRuleModifyingEffect extends ContinuousRuleModifiyingEffectImpl {
public GodsendReplacementEffect() {
public GodsendRuleModifyingEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Opponents can't cast cards with the same name as cards exiled with {this}";
}
public GodsendReplacementEffect(final GodsendReplacementEffect effect) {
public GodsendRuleModifyingEffect(final GodsendRuleModifyingEffect effect) {
super(effect);
}
@ -216,23 +217,21 @@ class GodsendReplacementEffect extends ReplacementEffectImpl {
}
@Override
public GodsendReplacementEffect copy() {
return new GodsendReplacementEffect(this);
public GodsendRuleModifyingEffect copy() {
return new GodsendRuleModifyingEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(event.getPlayerId());
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (player != null && sourcePermanent != null) {
game.informPlayer(player, new StringBuilder("You can't cast this spell because a card with the same name is exiled by ")
.append(sourcePermanent.getName()).append(".").toString());
public String getInfoMessage(Ability source, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
return "You can't cast this spell because a card with the same name is exiled by " + mageObject.getLogName() + ".";
}
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() == EventType.CAST_SPELL && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
MageObject object = game.getObject(event.getSourceId());
if (object != null) {

View file

@ -30,6 +30,7 @@ package mage.sets.legends;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.UntapAllLandsControllerEffect;
import mage.cards.CardImpl;
@ -72,7 +73,7 @@ public class Reset extends CardImpl {
}
}
class ResetReplacementEffect extends ReplacementEffectImpl {
class ResetReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
ResetReplacementEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast {this} only during an opponent's turn after his or her upkeep step";
@ -83,12 +84,7 @@ class ResetReplacementEffect 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().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
if (game.getTurn().getStepType().equals(PhaseStep.UNTAP)
|| game.getTurn().getStepType().equals(PhaseStep.UPKEEP)

View file

@ -33,9 +33,9 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.delayed.AtEndOfTurnDelayedTriggeredAbility;
import mage.abilities.dynamicvalue.common.StaticValue;
import mage.abilities.dynamicvalue.common.TargetPermanentPowerCount;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.continious.BoostTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
import mage.abilities.keyword.TrampleAbility;
@ -53,9 +53,7 @@ import mage.players.Player;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.Watcher;
import mage.watchers.Watchers;
import mage.watchers.common.AttackedThisTurnWatcher;
import mage.watchers.common.CastSpellLastTurnWatcher;
/**
*
@ -97,7 +95,7 @@ public class Berserk extends CardImpl {
}
}
class BerserkReplacementEffect extends ReplacementEffectImpl {
class BerserkReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
BerserkReplacementEffect() {
super(Duration.EndOfGame, Outcome.Detriment);
staticText = "Cast {this} only before the combat damage step";
@ -108,16 +106,7 @@ class BerserkReplacementEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
game.informPlayer(controller, "This spell can only be played before combat damage step.");
}
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().equals(GameEvent.EventType.CAST_SPELL) && event.getSourceId().equals(source.getSourceId())) {
CombatDamageStepStartedWatcher watcher = (CombatDamageStepStartedWatcher) game.getState().getWatchers().get("CombatDamageStepStarted");
return watcher == null || watcher.conditionMet();

View file

@ -28,14 +28,17 @@
package mage.sets.lorwyn;
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.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;
@ -73,7 +76,7 @@ public class GaddockTeeg extends CardImpl {
}
}
class GaddockTeegReplacementEffect4 extends ReplacementEffectImpl {
class GaddockTeegReplacementEffect4 extends ContinuousRuleModifiyingEffectImpl {
public GaddockTeegReplacementEffect4() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -95,12 +98,7 @@ class GaddockTeegReplacementEffect4 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 && !card.getCardType().contains(CardType.CREATURE) && card.getManaCost().convertedManaCost() >= 4) {
@ -112,7 +110,7 @@ class GaddockTeegReplacementEffect4 extends ReplacementEffectImpl {
}
class GaddockTeegReplacementEffectX extends ReplacementEffectImpl {
class GaddockTeegReplacementEffectX extends ContinuousRuleModifiyingEffectImpl {
public GaddockTeegReplacementEffectX() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -134,12 +132,7 @@ class GaddockTeegReplacementEffectX 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 && !card.getCardType().contains(CardType.CREATURE) && card.getManaCost().getText().contains("X")) {
@ -149,4 +142,4 @@ class GaddockTeegReplacementEffectX extends ReplacementEffectImpl {
return false;
}
}
}

View file

@ -29,13 +29,14 @@
package mage.sets.magic2010;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
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.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -63,7 +64,7 @@ public class Silence extends CardImpl {
}
}
class SilenceEffect extends ReplacementEffectImpl {
class SilenceEffect extends ContinuousRuleModifiyingEffectImpl {
public SilenceEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
@ -85,12 +86,16 @@ class SilenceEffect 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 spells this turn (" + 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() == EventType.CAST_SPELL && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) {
return true;
}

View file

@ -111,6 +111,7 @@ class PhyrexianRevokerEffect1 extends OneShotEffect {
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"));
return true;
}
return false;
}

View file

@ -108,7 +108,7 @@ class MoltenDisasterTriggeredAbility extends TriggeredAbilityImpl {
@Override
public String getRule() {
return "If Molten Disaster was kicked, it has split second <i>(As long as this spell is on the stack, players can't cast spells or activate abilities that aren't mana abilities.)</i>";
return "If {this} was kicked, it has split second <i>(As long as this spell is on the stack, players can't cast spells or activate abilities that aren't mana abilities.)</i>";
}
}

View file

@ -33,6 +33,7 @@ import mage.constants.*;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card;
@ -94,7 +95,7 @@ class ExclusionRitualImprintEffect extends OneShotEffect {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
if (sourcePermanent != null && targetPermanent != null) {
targetPermanent.moveToExile(getId(), "Exclusion Ritual (Imprint)", source.getSourceId(), game);
targetPermanent.moveToExile(getId(), sourcePermanent.getLogName() + " (Imprint)", source.getSourceId(), game);
sourcePermanent.imprint(targetPermanent.getId(), game);
}
return true;
@ -106,7 +107,7 @@ class ExclusionRitualImprintEffect extends OneShotEffect {
}
}
class ExclusionRitualReplacementEffect extends ReplacementEffectImpl {
class ExclusionRitualReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
ExclusionRitualReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Players can't cast spells with the same name as the exiled card";
@ -117,12 +118,7 @@ class ExclusionRitualReplacementEffect 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) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
Card card = game.getCard(event.getSourceId());

View file

@ -30,6 +30,7 @@ package mage.sets.odyssey;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.DrawCardSourceControllerEffect;
import mage.cards.CardImpl;
@ -74,7 +75,7 @@ public class CeaseFire extends CardImpl {
}
}
class CeaseFireEffect extends ReplacementEffectImpl {
class CeaseFireEffect extends ContinuousRuleModifiyingEffectImpl {
private static final FilterSpell filter = new FilterSpell();
static {
@ -83,7 +84,7 @@ class CeaseFireEffect extends ReplacementEffectImpl {
public CeaseFireEffect() {
super(Duration.EndOfTurn, Outcome.Detriment);
staticText = "Target player can't cast creature spells";
staticText = "Target player can't cast creature spells this turn";
}
public CeaseFireEffect(final CeaseFireEffect effect) {
@ -101,12 +102,16 @@ class CeaseFireEffect 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 creature spells this turn (" + 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 && event.getPlayerId().equals(source.getFirstTarget())) {
MageObject object = game.getObject(event.getSourceId());
if (filter.match((Spell) object, game)) {

View file

@ -35,6 +35,7 @@ import mage.MageObject;
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.keyword.FlyingAbility;
@ -44,7 +45,9 @@ import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -95,7 +98,8 @@ class VoidstoneGargoyleChooseCardEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent permanent = game.getPermanent(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
@ -105,8 +109,10 @@ class VoidstoneGargoyleChooseCardEffect extends OneShotEffect {
}
}
String cardName = cardChoice.getChoice();
game.informPlayers("VoidstoneGargoyle, named card: [" + cardName + "]");
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName +"]"));
return true;
}
return false;
}
@ -118,7 +124,7 @@ class VoidstoneGargoyleChooseCardEffect extends OneShotEffect {
}
class VoidstoneGargoyleReplacementEffect1 extends ReplacementEffectImpl {
class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifiyingEffectImpl {
public VoidstoneGargoyleReplacementEffect1() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -140,12 +146,16 @@ class VoidstoneGargoyleReplacementEffect1 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 a card with that name (" + 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) {
MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) {

View file

@ -33,6 +33,7 @@ import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.condition.LockedInCondition;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl;
@ -78,7 +79,7 @@ public class OrimsChant extends CardImpl {
}
class OrimsChantCantCastEffect extends ReplacementEffectImpl {
class OrimsChantCantCastEffect extends ContinuousRuleModifiyingEffectImpl {
public OrimsChantCantCastEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
@ -100,12 +101,7 @@ class OrimsChantCantCastEffect 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 ) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null && player.getId().equals(event.getPlayerId())) {
@ -118,7 +114,7 @@ class OrimsChantCantCastEffect extends ReplacementEffectImpl {
class OrimsChantCantAttackEffect extends ReplacementEffectImpl {
private static final String effectText = "If Orim's Chant was kicked, creatures can't attack this turn";
private static final String effectText = "If {this} was kicked, creatures can't attack this turn";
private Condition condition = new LockedInCondition(KickedCondition.getInstance());
OrimsChantCantAttackEffect ( ) {

View file

@ -50,7 +50,6 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import mage.util.CardUtil;
/**

View file

@ -31,8 +31,8 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -63,8 +63,7 @@ public class XantidSwarm extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever Xantid Swarm attacks, defending player can't cast spells this turn.
Ability ability = new XantidSwarmTriggeredAbility(new XantidSwarmReplacementEffect());
Ability ability = new XantidSwarmTriggeredAbility(new XantidSwarmReplacementEffect());
this.addAbility(ability);
}
@ -109,7 +108,7 @@ class XantidSwarmTriggeredAbility extends TriggeredAbilityImpl {
}
}
class XantidSwarmReplacementEffect extends ReplacementEffectImpl {
class XantidSwarmReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
public XantidSwarmReplacementEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
@ -131,12 +130,7 @@ class XantidSwarmReplacementEffect 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 ) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null && player.getId().equals(event.getPlayerId())) {

View file

@ -30,14 +30,18 @@ package mage.sets.shardsofalara;
import java.util.HashMap;
import java.util.Map;
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.Card;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.watchers.Watcher;
@ -75,7 +79,7 @@ public class EtherswornCanonist extends CardImpl {
class EtherswornCanonistWatcher extends Watcher {
private Map<UUID, Boolean> castNonartifactSpell = new HashMap<UUID, Boolean>();
private Map<UUID, Boolean> castNonartifactSpell = new HashMap<>();
public EtherswornCanonistWatcher() {
super("EtherswornCanonistWatcher", WatcherScope.GAME);
@ -119,7 +123,7 @@ class EtherswornCanonistWatcher extends Watcher {
}
class EtherswornCanonistReplacementEffect extends ReplacementEffectImpl {
class EtherswornCanonistReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
public EtherswornCanonistReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -141,12 +145,7 @@ class EtherswornCanonistReplacementEffect 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) {
EtherswornCanonistWatcher watcher = (EtherswornCanonistWatcher)game.getState().getWatchers().get("EtherswornCanonistWatcher");
Card card = game.getCard(event.getSourceId());

View file

@ -33,6 +33,7 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlashAbility;
import mage.cards.Card;
@ -133,7 +134,8 @@ class TeferiMageOfZhalfirAddFlashEffect extends ContinuousEffectImpl {
}
}
class TeferiMageOfZhalfirReplacementEffect extends ReplacementEffectImpl {
class TeferiMageOfZhalfirReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
TeferiMageOfZhalfirReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Each opponent can cast spells only any time he or she could cast a sorcery";
@ -144,17 +146,15 @@ class TeferiMageOfZhalfirReplacementEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
public String getInfoMessage(Ability source, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null && mageObject != null) {
game.informPlayer(opponent, "You can cast spells only any time you could cast a sorcery (" + mageObject.getName() +")");
if (mageObject != null) {
return "You can cast spells only any time you could cast a sorcery (" + mageObject.getLogName() + ").";
}
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.CAST_SPELL) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.hasOpponent(event.getPlayerId(), game)) {

View file

@ -31,10 +31,12 @@ import java.util.UUID;
import mage.constants.*;
import mage.MageInt;
import mage.MageObject;
import mage.ObjectColor;
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.keyword.FlyingAbility;
@ -45,6 +47,7 @@ import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
@ -102,7 +105,7 @@ class IonaShieldOfEmeriaChooseColorEffect extends OneShotEffect {
if (player.choose(Outcome.Detriment, colorChoice, game)) {
game.informPlayers(permanent.getName() + ": " + player.getName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(permanent.getId() + "_color", colorChoice.getColor());
permanent.addInfo("chosen color", new StringBuilder("<font color='blue'>Chosen color: ").append(colorChoice.getColor().getDescription()).append("</font>").toString());
permanent.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + colorChoice.getColor().getDescription()));
}
return true;
}
@ -115,7 +118,8 @@ class IonaShieldOfEmeriaChooseColorEffect extends OneShotEffect {
}
}
class IonaShieldOfEmeriaReplacementEffect extends ReplacementEffectImpl {
class IonaShieldOfEmeriaReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
IonaShieldOfEmeriaReplacementEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Your opponents can't cast spells of the chosen color";
@ -126,12 +130,17 @@ class IonaShieldOfEmeriaReplacementEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
public String getInfoMessage(Ability source, Game game) {
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null && chosenColor != null) {
return "You can't cast " + chosenColor.toString() +" spells (" + 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) {
if (game.getOpponents(source.getControllerId()).contains(event.getPlayerId()) ) {
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(source.getSourceId() + "_color");
@ -153,4 +162,4 @@ class IonaShieldOfEmeriaReplacementEffect extends ReplacementEffectImpl {
public IonaShieldOfEmeriaReplacementEffect copy() {
return new IonaShieldOfEmeriaReplacementEffect(this);
}
}
}

View file

@ -0,0 +1,112 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.abilities.decorator;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.condition.Condition;
import mage.abilities.condition.FixedCondition;
import mage.abilities.effects.ContinuousRuleModifiyingEffect;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.game.Game;
import mage.game.events.GameEvent;
/**
*
* @author LevelX2
*/
public class ConditionalContinuousRuleModifyingEffect extends ContinuousRuleModifiyingEffectImpl {
protected ContinuousRuleModifiyingEffect effect;
protected ContinuousRuleModifiyingEffect otherwiseEffect;
protected Condition condition;
protected boolean lockedInCondition;
protected boolean conditionState;
public ConditionalContinuousRuleModifyingEffect(ContinuousRuleModifiyingEffect effect, Condition condition, boolean lockedInCondition) {
this(effect, condition, null, lockedInCondition);
}
public ConditionalContinuousRuleModifyingEffect(ContinuousRuleModifiyingEffect effect, Condition condition, ContinuousRuleModifiyingEffect otherwiseEffect, boolean lockedInCondition) {
super(effect.getDuration(), effect.getOutcome());
this.effect = effect;
this.condition = condition;
this.otherwiseEffect = otherwiseEffect;
this.lockedInCondition = lockedInCondition;
}
public ConditionalContinuousRuleModifyingEffect(final ConditionalContinuousRuleModifyingEffect effect) {
super(effect);
this.effect = (ContinuousRuleModifiyingEffect) effect.effect.copy();
if (effect.otherwiseEffect != null) {
this.otherwiseEffect = (ContinuousRuleModifiyingEffect) effect.otherwiseEffect.copy();
}
this.condition = effect.condition;
this.lockedInCondition = effect.lockedInCondition;
this.conditionState = effect.conditionState;
}
@Override
public boolean isDiscarded() {
return effect.isDiscarded() || (otherwiseEffect != null && otherwiseEffect.isDiscarded());
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
if (lockedInCondition && !(condition instanceof FixedCondition)) {
condition = new FixedCondition(condition.apply(game, source));
}
conditionState = condition.apply(game, source);
if (conditionState) {
effect.setTargetPointer(this.targetPointer);
return effect.applies(event, source, checkPlayableMode, game);
} else if (otherwiseEffect != null) {
otherwiseEffect.setTargetPointer(this.targetPointer);
return otherwiseEffect.applies(event, source, checkPlayableMode, game);
}
return false;
}
@Override
public String getText(Mode mode) {
if (staticText == null || staticText.isEmpty() && this.effect != null) { // usefull for conditional night/day card abilities
return effect.getText(mode);
}
return staticText;
}
@Override
public ConditionalContinuousRuleModifyingEffect copy() {
return new ConditionalContinuousRuleModifyingEffect(this);
}
}

View file

@ -8,6 +8,7 @@ import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.delayed.AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
@ -79,7 +80,7 @@ public class EpicEffect extends OneShotEffect {
}
}
class EpicReplacementEffect extends ReplacementEffectImpl {
class EpicReplacementEffect extends ContinuousRuleModifiyingEffectImpl {
public EpicReplacementEffect() {
super(Duration.EndOfGame, Outcome.Neutral);
@ -101,17 +102,16 @@ class EpicReplacementEffect extends ReplacementEffectImpl {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
public String getInfoMessage(Ability source, Game game) {
MageObject mageObject = game.getObject(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && mageObject != null) {
game.informPlayer(controller, "For the rest of the game, you can't cast spells (Epic - " + mageObject.getName() +")");
if (mageObject != null) {
return "For the rest of the game, you can't cast spells (Epic - " + mageObject.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.CAST_SPELL
&& source.getControllerId() == event.getPlayerId()) {
MageObject object = game.getObject(event.getSourceId());

View file

@ -1,9 +1,8 @@
package mage.abilities.keyword;
import mage.abilities.Ability;
import mage.abilities.MageSingleton;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.mana.ManaAbility;
import mage.constants.Duration;
import mage.constants.Outcome;
@ -39,7 +38,8 @@ public class SplitSecondAbility extends SimpleStaticAbility {
}
}
class SplitSecondEffect extends ReplacementEffectImpl implements MageSingleton {
class SplitSecondEffect extends ContinuousRuleModifiyingEffectImpl {
SplitSecondEffect() {
super(Duration.WhileOnStack, Outcome.Detriment);
}
@ -49,7 +49,12 @@ class SplitSecondEffect extends ReplacementEffectImpl implements MageSingleton {
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
public String getInfoMessage(Ability source, Game game) {
return "You can't cast spells or activate abilities that aren't mana abilities (Split second).";
}
@Override
public boolean applies(GameEvent event, Ability source, boolean checkPlayableMode, Game game) {
if (event.getType() == GameEvent.EventType.CAST_SPELL) {
return true;
}
@ -62,11 +67,6 @@ class SplitSecondEffect extends ReplacementEffectImpl implements MageSingleton {
return false;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return false;