diff --git a/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java b/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java index 5705774db0..52a86e09fa 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/CavernOfSouls.java @@ -38,7 +38,6 @@ 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; import mage.abilities.mana.ConditionalAnyColorManaAbility; import mage.abilities.mana.builder.ConditionalManaBuilder; diff --git a/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java b/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java index a29af83ecf..bf572c9478 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java @@ -32,6 +32,7 @@ import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.CardImpl; import mage.constants.CardType; @@ -116,10 +117,10 @@ class SpiritOfTheLabyrinthWatcher extends Watcher { } -class SpiritOfTheLabyrinthEffect extends ReplacementEffectImpl { +class SpiritOfTheLabyrinthEffect extends ContinuousRuleModifiyingEffectImpl { public SpiritOfTheLabyrinthEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + super(Duration.WhileOnBattlefield, Outcome.Detriment, false, false); staticText = "Each player can't draw more than one card each turn"; } @@ -137,11 +138,6 @@ class SpiritOfTheLabyrinthEffect extends ReplacementEffectImpl { 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() == GameEvent.EventType.DRAW_CARD) { diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java b/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java index c7d0996471..fccbae3399 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/BoseijuWhoSheltersAll.java @@ -38,7 +38,6 @@ 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; import mage.constants.CardType; @@ -52,7 +51,6 @@ import mage.filter.common.FilterInstantOrSorceryCard; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.Spell; -import mage.players.Player; import mage.watchers.Watcher; /** diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/ShimatsuTheBloodcloaked.java b/Mage.Sets/src/mage/sets/championsofkamigawa/ShimatsuTheBloodcloaked.java index f12a97206a..d12185583c 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/ShimatsuTheBloodcloaked.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/ShimatsuTheBloodcloaked.java @@ -79,7 +79,7 @@ class ShimatsuTheBloodcloakedEffect extends ReplacementEffectImpl { public ShimatsuTheBloodcloakedEffect() { super(Duration.WhileOnBattlefield, Outcome.BoostCreature); - this.staticText = "As Shimatsu the Bloodcloaked enters the battlefield, sacrifice any number of permanents. Shimatsu enters the battlefield with that many +1/+1 counters on it"; + this.staticText = "As {this} enters the battlefield, sacrifice any number of permanents. {this} enters the battlefield with that many +1/+1 counters on it"; } public ShimatsuTheBloodcloakedEffect(final ShimatsuTheBloodcloakedEffect effect) { diff --git a/Mage.Sets/src/mage/sets/commander2013/IllusionistsGambit.java b/Mage.Sets/src/mage/sets/commander2013/IllusionistsGambit.java index 8083fbfc6e..85ab188a21 100644 --- a/Mage.Sets/src/mage/sets/commander2013/IllusionistsGambit.java +++ b/Mage.Sets/src/mage/sets/commander2013/IllusionistsGambit.java @@ -34,8 +34,8 @@ 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; +import mage.abilities.effects.RestrictionEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; @@ -143,7 +143,7 @@ class IllusionistsGambitRemoveFromCombatEffect extends OneShotEffect { game.getState().getTurnMods().add(new TurnMod(game.getActivePlayerId(), TurnPhase.COMBAT, null, false)); ContinuousEffect effect = new IllusionistsGambitRequirementEffect(attackers, phase); game.addEffect(effect, source); - effect = new IllusionistsGambitReplacementEffect(attackers, phase); + effect = new IllusionistsGambitRestrictionEffect(attackers, phase); game.addEffect(effect, source); } @@ -203,32 +203,27 @@ class IllusionistsGambitRequirementEffect extends RequirementEffect { } } -class IllusionistsGambitReplacementEffect extends ReplacementEffectImpl { +class IllusionistsGambitRestrictionEffect extends RestrictionEffect { private final List attackers; private final Phase phase; - IllusionistsGambitReplacementEffect(List attackers, Phase phase) { + public IllusionistsGambitRestrictionEffect(List attackers, Phase phase) { super(Duration.Custom, Outcome.Benefit); this.attackers = attackers; this.phase = phase; staticText = "They can't attack you or a planeswalker you control that combat"; } - IllusionistsGambitReplacementEffect(IllusionistsGambitReplacementEffect effect) { + public IllusionistsGambitRestrictionEffect(final IllusionistsGambitRestrictionEffect effect) { super(effect); this.attackers = effect.attackers; this.phase = effect.phase; } @Override - public boolean apply(Game game, Ability source) { - throw new UnsupportedOperationException("Not supported."); - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public boolean applies(Permanent permanent, Ability source, Game game) { + return attackers.contains(permanent.getId()); } @Override @@ -242,24 +237,37 @@ class IllusionistsGambitReplacementEffect extends ReplacementEffectImpl { } @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER && attackers.contains(event.getSourceId())) { - if (event.getTargetId().equals(source.getControllerId()) ) { - return true; - } - // planeswalker - Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) - && permanent.getCardType().contains(CardType.PLANESWALKER)) { - return true; - } - } + public boolean canAttack(Game game) { return false; } @Override - public IllusionistsGambitReplacementEffect copy() { - return new IllusionistsGambitReplacementEffect(this); + public boolean canAttack(UUID defenderId, Ability source, Game game) { + if (defenderId.equals(source.getControllerId()) ) { + return false; + } + // planeswalker + Permanent permanent = game.getPermanent(defenderId); + if (permanent != null && permanent.getControllerId().equals(source.getControllerId()) + && permanent.getCardType().contains(CardType.PLANESWALKER)) { + return false; + } + return true; + } + + @Override + public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + return false; + } + + @Override + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { + return false; + } + + @Override + public IllusionistsGambitRestrictionEffect copy() { + return new IllusionistsGambitRestrictionEffect(this); } } diff --git a/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java b/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java index 5073aef564..2ede8ab6a7 100644 --- a/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java +++ b/Mage.Sets/src/mage/sets/commander2013/MysticBarrier.java @@ -119,7 +119,7 @@ class MysticBarrierTriggeredAbility extends TriggeredAbilityImpl { class MysticBarrierChooseEffect extends OneShotEffect { public static final String[] SET_VALUES = new String[] { MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT }; - public static final Set CHOICES = new HashSet(Arrays.asList(SET_VALUES)); + public static final Set CHOICES = new HashSet<>(Arrays.asList(SET_VALUES)); final static Choice DIRECTION_CHOICE = new ChoiceImpl(true); static { DIRECTION_CHOICE.setChoices(CHOICES); diff --git a/Mage.Sets/src/mage/sets/conflux/Banefire.java b/Mage.Sets/src/mage/sets/conflux/Banefire.java index 4d54b8b731..5dc0938717 100644 --- a/Mage.Sets/src/mage/sets/conflux/Banefire.java +++ b/Mage.Sets/src/mage/sets/conflux/Banefire.java @@ -35,7 +35,6 @@ 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; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/darkascension/CurseOfExhaustion.java b/Mage.Sets/src/mage/sets/darkascension/CurseOfExhaustion.java index 5a87daad9e..2a520a5b32 100644 --- a/Mage.Sets/src/mage/sets/darkascension/CurseOfExhaustion.java +++ b/Mage.Sets/src/mage/sets/darkascension/CurseOfExhaustion.java @@ -33,7 +33,6 @@ 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; import mage.cards.CardImpl; diff --git a/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java b/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java index 094bc11bd8..0b89d6590d 100644 --- a/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java +++ b/Mage.Sets/src/mage/sets/divinevsdemonic/FaithsFetters.java @@ -38,6 +38,7 @@ import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffec import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.constants.CardType; +import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/KrasisIncubation.java b/Mage.Sets/src/mage/sets/dragonsmaze/KrasisIncubation.java index 80709a734e..a0bbcab8d7 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/KrasisIncubation.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/KrasisIncubation.java @@ -42,6 +42,7 @@ import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffec import mage.abilities.effects.common.counter.AddPlusOneCountersAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; +import mage.constants.Duration; import mage.constants.Outcome; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; diff --git a/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java b/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java index e02c614303..550d50c802 100644 --- a/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java +++ b/Mage.Sets/src/mage/sets/innistrad/FullMoonsRise.java @@ -89,7 +89,7 @@ public class FullMoonsRise extends CardImpl { class FullMoonsRiseEffect extends OneShotEffect { - private FilterPermanent filter; + private final FilterPermanent filter; public FullMoonsRiseEffect(FilterPermanent filter) { super(Outcome.Regenerate); diff --git a/Mage.Sets/src/mage/sets/innistrad/StonySilence.java b/Mage.Sets/src/mage/sets/innistrad/StonySilence.java index 6f7adc4047..dd50b27301 100644 --- a/Mage.Sets/src/mage/sets/innistrad/StonySilence.java +++ b/Mage.Sets/src/mage/sets/innistrad/StonySilence.java @@ -30,16 +30,13 @@ package mage.sets.innistrad; import java.util.UUID; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.cards.CardImpl; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -55,7 +52,7 @@ public class StonySilence extends CardImpl { this.color.setWhite(true); // Activated abilities of artifacts can't be activated. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StonySilenceEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StonySilenceCantActivateEffect())); } @@ -69,41 +66,30 @@ public class StonySilence extends CardImpl { } } -class StonySilenceEffect extends ReplacementEffectImpl { +class StonySilenceCantActivateEffect extends RestrictionEffect { - public StonySilenceEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + public StonySilenceCantActivateEffect() { + super(Duration.WhileOnBattlefield); staticText = "Activated abilities of artifacts can't be activated"; } - public StonySilenceEffect(final StonySilenceEffect effect) { + public StonySilenceCantActivateEffect(final StonySilenceCantActivateEffect effect) { super(effect); } @Override - public boolean apply(Game game, Ability source) { - return true; + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getCardType().contains(CardType.ARTIFACT); } @Override - public StonySilenceEffect copy() { - return new StonySilenceEffect(this); - } - - @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.ACTIVATE_ABILITY) { - Permanent artifact = game.getPermanent(event.getSourceId()); - if (artifact != null && artifact.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { return false; } + @Override + public StonySilenceCantActivateEffect copy() { + return new StonySilenceCantActivateEffect(this); + } + } diff --git a/Mage.Sets/src/mage/sets/magic2013/Encrust.java b/Mage.Sets/src/mage/sets/magic2013/Encrust.java index e88c8c9ccf..4c7f019723 100644 --- a/Mage.Sets/src/mage/sets/magic2013/Encrust.java +++ b/Mage.Sets/src/mage/sets/magic2013/Encrust.java @@ -32,8 +32,10 @@ import java.util.UUID; import mage.constants.*; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.Effect; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.CantActivateAbilitiesAttachedEffect; import mage.abilities.effects.common.SkipEnchantedUntapEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; @@ -74,8 +76,10 @@ public class Encrust extends CardImpl { this.addAbility(ability); // Enchanted permanent doesn't untap during its controller's untap step and its activated abilities can't be activated. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipEnchantedUntapEffect())); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EncrustEffect())); + ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipEnchantedUntapEffect()); + Effect effect = new CantActivateAbilitiesAttachedEffect(); + effect.setText("and its activated abilities can't be activated"); + this.addAbility(ability); } public Encrust(final Encrust card) { @@ -87,43 +91,3 @@ public class Encrust extends CardImpl { return new Encrust(this); } } - -class EncrustEffect extends ReplacementEffectImpl { - - public EncrustEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "Its activated abilities can't be activated"; - } - - public EncrustEffect(final EncrustEffect effect) { - super(effect); - } - - @Override - public EncrustEffect copy() { - return new EncrustEffect(this); - } - - @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() == GameEvent.EventType.ACTIVATE_ABILITY) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - Permanent enchanted = game.getPermanent(enchantment.getAttachedTo()); - if (event.getSourceId().equals(enchanted.getId())) { - return true; - } - } - return false; - } -} - diff --git a/Mage.Sets/src/mage/sets/magic2013/XathridGorgon.java b/Mage.Sets/src/mage/sets/magic2013/XathridGorgon.java index 7dc330e311..3bb960531e 100644 --- a/Mage.Sets/src/mage/sets/magic2013/XathridGorgon.java +++ b/Mage.Sets/src/mage/sets/magic2013/XathridGorgon.java @@ -35,7 +35,7 @@ import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.Effect; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.common.continious.AddCardTypeTargetEffect; import mage.abilities.effects.common.continious.GainAbilityTargetEffect; import mage.abilities.effects.common.continious.SetCardColorTargetEffect; @@ -45,12 +45,10 @@ import mage.abilities.keyword.DefenderAbility; 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.counters.CounterType; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; @@ -83,7 +81,7 @@ public class XathridGorgon extends CardImpl { effect.setText("and becomes a colorless artifact in addition to its other types"); ability.addEffect(effect); ability.addEffect(new SetCardColorTargetEffect(new ObjectColor(), Duration.Custom, "")); - ability.addEffect(new XathridGorgonEffect()); + ability.addEffect(new XathridGorgonCantActivateEffect()); this.addAbility(ability); } @@ -98,43 +96,36 @@ public class XathridGorgon extends CardImpl { } } -class XathridGorgonEffect extends ReplacementEffectImpl { +class XathridGorgonCantActivateEffect extends RestrictionEffect { - public XathridGorgonEffect() { - super(Duration.Custom, Outcome.Detriment); + public XathridGorgonCantActivateEffect() { + super(Duration.Custom); staticText = "Its activated abilities can't be activated"; } - public XathridGorgonEffect(final XathridGorgonEffect effect) { + public XathridGorgonCantActivateEffect(final XathridGorgonCantActivateEffect effect) { super(effect); } @Override - public XathridGorgonEffect copy() { - return new XathridGorgonEffect(this); - } - - @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().equals(GameEvent.EventType.ACTIVATE_ABILITY) && event.getSourceId().equals(targetPointer.getFirst(game, source))) { - Permanent target = game.getPermanent(targetPointer.getFirst(game, source)); - if (target != null) { - return true; - } else { - this.discard(); - } + public boolean applies(Permanent permanent, Ability source, Game game) { + Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (target != null) { + return true; + } else { + this.discard(); } return false; } + @Override + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { + return false; + } + + @Override + public XathridGorgonCantActivateEffect copy() { + return new XathridGorgonCantActivateEffect(this); + } + } diff --git a/Mage.Sets/src/mage/sets/mirage/CursedTotem.java b/Mage.Sets/src/mage/sets/mirage/CursedTotem.java index d155fe2580..4ccdc8a1c9 100644 --- a/Mage.Sets/src/mage/sets/mirage/CursedTotem.java +++ b/Mage.Sets/src/mage/sets/mirage/CursedTotem.java @@ -28,18 +28,15 @@ package mage.sets.mirage; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -53,7 +50,7 @@ public class CursedTotem extends CardImpl { this.expansionSetCode = "MIR"; // Activated abilities of creatures can't be activated. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CursedTotemEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CursedTotemCantActivateEffect())); } public CursedTotem(final CursedTotem card) { @@ -66,41 +63,30 @@ public class CursedTotem extends CardImpl { } } -class CursedTotemEffect extends ReplacementEffectImpl { +class CursedTotemCantActivateEffect extends RestrictionEffect { - public CursedTotemEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + public CursedTotemCantActivateEffect() { + super(Duration.WhileOnBattlefield); staticText = "Activated abilities of creatures can't be activated"; } - public CursedTotemEffect(final CursedTotemEffect effect) { + public CursedTotemCantActivateEffect(final CursedTotemCantActivateEffect effect) { super(effect); } @Override - public boolean apply(Game game, Ability source) { - return true; + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getCardType().contains(CardType.CREATURE); } @Override - public CursedTotemEffect copy() { - return new CursedTotemEffect(this); - } - - @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.ACTIVATE_ABILITY) { - Permanent creature = game.getPermanent(event.getSourceId()); - if (creature != null && creature.getCardType().contains(CardType.CREATURE)) { - return true; - } - } + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { return false; } + @Override + public CursedTotemCantActivateEffect copy() { + return new CursedTotemCantActivateEffect(this); + } + } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/mirrodin/Arrest.java b/Mage.Sets/src/mage/sets/mirrodin/Arrest.java index 6144910054..b36d77998a 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/Arrest.java +++ b/Mage.Sets/src/mage/sets/mirrodin/Arrest.java @@ -39,6 +39,7 @@ import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; +import mage.constants.Duration; import mage.constants.Outcome; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; diff --git a/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java b/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java index 1131f2d6ad..d42f1c5f7f 100644 --- a/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java +++ b/Mage.Sets/src/mage/sets/mirrodinbesieged/PhyrexianRevoker.java @@ -148,7 +148,7 @@ class PhyrexianRevokerEffect2 extends ContinuousRuleModifiyingEffectImpl { public String getInfoMessage(Ability source, GameEvent event, Game game) { MageObject mageObject = game.getObject(source.getSourceId()); if (mageObject != null) { - return "You can't activate sources with that name (" + mageObject.getLogName() + " in play)."; + return "You can't activate abilities of sources with that name (" + mageObject.getLogName() + " in play)."; } return null; } diff --git a/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java b/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java index b5ca0b94af..9727a1670a 100644 --- a/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java +++ b/Mage.Sets/src/mage/sets/odyssey/PardicMiner.java @@ -34,7 +34,6 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; -import mage.abilities.effects.ReplacementEffectImpl; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; diff --git a/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java b/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java index 9e8c94741c..0c33f9610a 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java +++ b/Mage.Sets/src/mage/sets/planarchaos/VoidstoneGargoyle.java @@ -37,7 +37,6 @@ 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; import mage.cards.CardImpl; import mage.cards.repository.CardRepository; @@ -45,6 +44,7 @@ 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; @@ -71,7 +71,7 @@ public class VoidstoneGargoyle extends CardImpl { // The named card can't be cast. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect1())); // Activated abilities of sources with the chosen name can't be activated. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect2())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleRuleModifyingEffect2())); } public VoidstoneGargoyle(final VoidstoneGargoyle card) { @@ -167,14 +167,14 @@ class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifiyingEffect } -class VoidstoneGargoyleReplacementEffect2 extends ReplacementEffectImpl { +class VoidstoneGargoyleRuleModifyingEffect2 extends ContinuousRuleModifiyingEffectImpl { - public VoidstoneGargoyleReplacementEffect2() { + public VoidstoneGargoyleRuleModifyingEffect2() { super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "Activated abilities of sources with the chosen name can't be activated."; + staticText = "Activated abilities of sources with the chosen name can't be activated"; } - public VoidstoneGargoyleReplacementEffect2(final VoidstoneGargoyleReplacementEffect2 effect) { + public VoidstoneGargoyleRuleModifyingEffect2(final VoidstoneGargoyleRuleModifyingEffect2 effect) { super(effect); } @@ -184,18 +184,22 @@ class VoidstoneGargoyleReplacementEffect2 extends ReplacementEffectImpl { } @Override - public VoidstoneGargoyleReplacementEffect2 copy() { - return new VoidstoneGargoyleReplacementEffect2(this); + public VoidstoneGargoyleRuleModifyingEffect2 copy() { + return new VoidstoneGargoyleRuleModifyingEffect2(this); } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public String getInfoMessage(Ability source, GameEvent event, Game game) { + MageObject mageObject = game.getObject(source.getSourceId()); + if (mageObject != null) { + return "You can't activate abilities of sources with that name (" + mageObject.getLogName() + " in play)."; + } + return null; } @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { + if (event.getType() == EventType.ACTIVATE_ABILITY) { MageObject object = game.getObject(event.getSourceId()); if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { return true; @@ -204,4 +208,4 @@ class VoidstoneGargoyleReplacementEffect2 extends ReplacementEffectImpl { return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/LinvalaKeeperOfSilence.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/LinvalaKeeperOfSilence.java index b470015560..c90deeb6ac 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/LinvalaKeeperOfSilence.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/LinvalaKeeperOfSilence.java @@ -29,23 +29,19 @@ package mage.sets.riseoftheeldrazi; import java.util.UUID; - -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Rarity; -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.RestrictionEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Rarity; +import mage.constants.Zone; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.Permanent; - /** * * @author Loki @@ -60,8 +56,10 @@ public class LinvalaKeeperOfSilence extends CardImpl { this.color.setWhite(true); this.power = new MageInt(3); this.toughness = new MageInt(4); + this.addAbility(FlyingAbility.getInstance()); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LinvalaKeeperOfSilenceEffect())); + + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LinvalaKeeperOfSilenceCantActivateEffect())); } public LinvalaKeeperOfSilence (final LinvalaKeeperOfSilence card) { @@ -74,39 +72,30 @@ public class LinvalaKeeperOfSilence extends CardImpl { } } -class LinvalaKeeperOfSilenceEffect extends ReplacementEffectImpl { - LinvalaKeeperOfSilenceEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); +class LinvalaKeeperOfSilenceCantActivateEffect extends RestrictionEffect { + + public LinvalaKeeperOfSilenceCantActivateEffect() { + super(Duration.WhileOnBattlefield); staticText = "Activated abilities of creatures your opponents control can't be activated"; } - LinvalaKeeperOfSilenceEffect(final LinvalaKeeperOfSilenceEffect effect) { + public LinvalaKeeperOfSilenceCantActivateEffect(final LinvalaKeeperOfSilenceCantActivateEffect effect) { super(effect); } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getCardType().contains(CardType.CREATURE) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId()); } @Override - public boolean applies(GameEvent event, Ability source, Game game) { - Permanent p = game.getPermanent(event.getSourceId()); - if ( event.getType() == GameEvent.EventType.ACTIVATE_ABILITY && game.getOpponents(source.getControllerId()).contains(event.getPlayerId()) - && p != null && p.getCardType().contains(CardType.CREATURE)) { - return true; - } + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { return false; } @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public LinvalaKeeperOfSilenceEffect copy() { - return new LinvalaKeeperOfSilenceEffect(this); + public LinvalaKeeperOfSilenceCantActivateEffect copy() { + return new LinvalaKeeperOfSilenceCantActivateEffect(this); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/PithingNeedle.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/PithingNeedle.java index 700ee9add6..6a1cfa82c1 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/PithingNeedle.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/PithingNeedle.java @@ -28,18 +28,22 @@ package mage.sets.saviorsofkamigawa; import java.util.UUID; - -import mage.constants.*; 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; import mage.choices.ChoiceImpl; +import mage.constants.AbilityType; +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.players.Player; @@ -108,7 +112,7 @@ class NameCard extends OneShotEffect { } -class PithingNeedleEffect extends ReplacementEffectImpl { +class PithingNeedleEffect extends ContinuousRuleModifiyingEffectImpl { public PithingNeedleEffect() { super(Duration.WhileOnBattlefield, Outcome.Detriment); @@ -129,11 +133,6 @@ class PithingNeedleEffect extends ReplacementEffectImpl { 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() == GameEvent.EventType.ACTIVATE_ABILITY) { diff --git a/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java b/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java index 63e87749d0..4f8e5592ad 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/VexingShusher.java @@ -35,7 +35,6 @@ 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; import mage.constants.Duration; diff --git a/Mage.Sets/src/mage/sets/theros/ShipbreakerKraken.java b/Mage.Sets/src/mage/sets/theros/ShipbreakerKraken.java index 32ed130560..39a92dc639 100644 --- a/Mage.Sets/src/mage/sets/theros/ShipbreakerKraken.java +++ b/Mage.Sets/src/mage/sets/theros/ShipbreakerKraken.java @@ -32,7 +32,6 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BecomesMonstrousSourceTriggeredAbility; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.keyword.MonstrosityAbility; import mage.cards.CardImpl; diff --git a/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java b/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java index 46d61621e2..fcf12ad5d3 100644 --- a/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java +++ b/Mage.Sets/src/mage/sets/theros/UnderworldCerberus.java @@ -33,7 +33,6 @@ 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; import mage.abilities.effects.common.combat.CantBeBlockedByOneEffect; diff --git a/Mage.Sets/src/mage/sets/timespiral/SerraAvenger.java b/Mage.Sets/src/mage/sets/timespiral/SerraAvenger.java index 597ce17147..b092ace125 100644 --- a/Mage.Sets/src/mage/sets/timespiral/SerraAvenger.java +++ b/Mage.Sets/src/mage/sets/timespiral/SerraAvenger.java @@ -37,7 +37,6 @@ 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; import mage.cards.CardImpl; diff --git a/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java b/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java index 3c8b223186..d5925dbc26 100644 --- a/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java +++ b/Mage.Sets/src/mage/sets/timespiral/TeferiMageOfZhalfir.java @@ -34,7 +34,6 @@ 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; import mage.cards.CardImpl; diff --git a/Mage.Sets/src/mage/sets/timespiral/Trickbind.java b/Mage.Sets/src/mage/sets/timespiral/Trickbind.java index adf4f63acb..475a43653b 100644 --- a/Mage.Sets/src/mage/sets/timespiral/Trickbind.java +++ b/Mage.Sets/src/mage/sets/timespiral/Trickbind.java @@ -28,17 +28,17 @@ package mage.sets.timespiral; import java.util.UUID; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.RestrictionEffect; +import mage.abilities.keyword.SplitSecondAbility; +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.OneShotEffect; -import mage.abilities.effects.ReplacementEffectImpl; -import mage.abilities.keyword.SplitSecondAbility; -import mage.cards.CardImpl; import mage.game.Game; -import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.game.stack.StackObject; import mage.target.common.TargetActivatedOrTriggeredAbility; import mage.target.targetpointer.FixedTarget; @@ -93,7 +93,7 @@ class TrickbindCounterEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); if(stackObject != null && game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) { - TrickbindReplacementEffect effect = new TrickbindReplacementEffect(); + TrickbindCantActivateEffect effect = new TrickbindCantActivateEffect(); effect.setTargetPointer(new FixedTarget(stackObject.getSourceId())); game.getContinuousEffects().addEffect(effect, source); return true; @@ -103,39 +103,33 @@ class TrickbindCounterEffect extends OneShotEffect { } -class TrickbindReplacementEffect extends ReplacementEffectImpl { +class TrickbindCantActivateEffect extends RestrictionEffect { - public TrickbindReplacementEffect() { - super(Duration.EndOfTurn, Outcome.LoseAbility); + public TrickbindCantActivateEffect() { + super(Duration.EndOfTurn); staticText = "Activated abilities of that permanent can't be activated this turn"; } - public TrickbindReplacementEffect(final TrickbindReplacementEffect effect) { + public TrickbindCantActivateEffect(final TrickbindCantActivateEffect effect) { super(effect); } @Override - public TrickbindReplacementEffect copy() { - return new TrickbindReplacementEffect(this); - } - - @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() == GameEvent.EventType.ACTIVATE_ABILITY) { - if (this.targetPointer.getFirst(game, source).equals(event.getSourceId())) { - return true; - } + public boolean applies(Permanent permanent, Ability source, Game game) { + if (getTargetPointer().getFirst(game, source).equals(permanent.getId())) { + return true; } return false; } -} + + @Override + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { + return false; + } + + @Override + public TrickbindCantActivateEffect copy() { + return new TrickbindCantActivateEffect(this); + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/weatherlight/NullRod.java b/Mage.Sets/src/mage/sets/weatherlight/NullRod.java index d26dcb7e17..994ef6fa84 100644 --- a/Mage.Sets/src/mage/sets/weatherlight/NullRod.java +++ b/Mage.Sets/src/mage/sets/weatherlight/NullRod.java @@ -30,15 +30,13 @@ package mage.sets.weatherlight; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; 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.permanent.Permanent; /** @@ -52,7 +50,7 @@ public class NullRod extends CardImpl { this.expansionSetCode = "WTH"; // Activated abilities of artifacts can't be activated. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantActivateAbilitiesEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NullRodCantActivateEffect())); } public NullRod(final NullRod card) { @@ -65,40 +63,30 @@ public class NullRod extends CardImpl { } } -class CantActivateAbilitiesEffect extends ReplacementEffectImpl { +class NullRodCantActivateEffect extends RestrictionEffect { - public CantActivateAbilitiesEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "Activated abilities of artifacts can't be activated."; + public NullRodCantActivateEffect() { + super(Duration.WhileOnBattlefield); + staticText = "Activated abilities of artifacts can't be activated"; } - public CantActivateAbilitiesEffect(final CantActivateAbilitiesEffect effect) { + public NullRodCantActivateEffect(final NullRodCantActivateEffect effect) { super(effect); } @Override - public CantActivateAbilitiesEffect copy() { - return new CantActivateAbilitiesEffect(this); + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getCardType().contains(CardType.ARTIFACT); } @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() == GameEvent.EventType.ACTIVATE_ABILITY) { - Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent.getCardType().contains(CardType.ARTIFACT)) { - return true; - } - } + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { return false; } -} + + @Override + public NullRodCantActivateEffect copy() { + return new NullRodCantActivateEffect(this); + } + +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/weatherlight/Peacekeeper.java b/Mage.Sets/src/mage/sets/weatherlight/Peacekeeper.java index 701a3115e3..9ab607e830 100644 --- a/Mage.Sets/src/mage/sets/weatherlight/Peacekeeper.java +++ b/Mage.Sets/src/mage/sets/weatherlight/Peacekeeper.java @@ -33,19 +33,17 @@ import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; +import mage.filter.FilterPermanent; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.players.Player; /** * @@ -79,38 +77,25 @@ public class Peacekeeper extends CardImpl { } } -class PeacekeeperCantAttackEffect extends ReplacementEffectImpl { +class PeacekeeperCantAttackEffect extends RestrictionEffect { - private static final String effectText = "Creatures can't attack"; - - PeacekeeperCantAttackEffect ( ) { - super(Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = effectText; + public PeacekeeperCantAttackEffect() { + super(Duration.WhileOnBattlefield); + staticText = "Creatures can't attack"; } - PeacekeeperCantAttackEffect (final PeacekeeperCantAttackEffect effect ) { + public PeacekeeperCantAttackEffect(final PeacekeeperCantAttackEffect effect) { super(effect); } @Override - public boolean apply(Game game, Ability source) { - throw new UnsupportedOperationException("Not supported."); + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getCardType().contains(CardType.CREATURE); } @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - Player atackingPlayer = game.getPlayer(event.getPlayerId()); - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - if (sourcePermanent != null && atackingPlayer != null) { - game.informPlayer(atackingPlayer, new StringBuilder(sourcePermanent.getName()).append(" prevents you from attacking with this creature.").toString()); - } - - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - return event.getType() == GameEvent.EventType.DECLARE_ATTACKER; + public boolean canAttack(Game game) { + return false; } @Override diff --git a/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java b/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java index 8409ddd074..4236fc9c3f 100644 --- a/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java +++ b/Mage.Sets/src/mage/sets/worldwake/AbyssalPersecutor.java @@ -36,7 +36,7 @@ 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.keyword.FlyingAbility; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; @@ -73,7 +73,7 @@ public class AbyssalPersecutor extends CardImpl { } } -class AbyssalPersecutorCannotWinEffect extends ReplacementEffectImpl { +class AbyssalPersecutorCannotWinEffect extends ContinuousRuleModifiyingEffectImpl { AbyssalPersecutorCannotWinEffect() { super(Duration.WhileOnBattlefield, Outcome.Detriment); @@ -93,16 +93,6 @@ class AbyssalPersecutorCannotWinEffect extends ReplacementEffectImpl { return false; } - @Override - public boolean apply(Game game, Ability source) { - return true; - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - return true; - } - @Override public AbyssalPersecutorCannotWinEffect copy() { return new AbyssalPersecutorCannotWinEffect(this); diff --git a/Mage.Sets/src/mage/sets/worldwake/OmnathLocusOfMana.java b/Mage.Sets/src/mage/sets/worldwake/OmnathLocusOfMana.java index 871bf4b8ba..422b7d3f7e 100644 --- a/Mage.Sets/src/mage/sets/worldwake/OmnathLocusOfMana.java +++ b/Mage.Sets/src/mage/sets/worldwake/OmnathLocusOfMana.java @@ -80,7 +80,7 @@ public class OmnathLocusOfMana extends CardImpl { class OmnathReplacementEffect extends ReplacementEffectImpl { - private static final List manaTypes = new ArrayList(); + private static final List manaTypes = new ArrayList<>(); static { manaTypes.add(ManaType.BLACK); manaTypes.add(ManaType.BLUE); diff --git a/Mage.Sets/src/mage/sets/worldwake/PermafrostTrap.java b/Mage.Sets/src/mage/sets/worldwake/PermafrostTrap.java index c6a388da38..3fde1e339c 100644 --- a/Mage.Sets/src/mage/sets/worldwake/PermafrostTrap.java +++ b/Mage.Sets/src/mage/sets/worldwake/PermafrostTrap.java @@ -35,14 +35,17 @@ import mage.ObjectColor; import mage.abilities.Ability; import mage.abilities.costs.AlternativeCostImpl; import mage.abilities.costs.mana.ColoredManaCost; +import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.SkipNextUntapTargetEffect; import mage.cards.CardImpl; import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; import mage.watchers.Watcher; /** @@ -158,11 +161,13 @@ class PermafrostTrapEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - for (UUID target : this.targetPointer.getTargets(game, source)) { - Permanent creature = game.getPermanent(target); + for (UUID targetId : this.targetPointer.getTargets(game, source)) { + Permanent creature = game.getPermanent(targetId); if (creature != null) { creature.tap(game); - game.addEffect(new PermafrostEffect2(creature.getId()), source); + SkipNextUntapTargetEffect effect = new SkipNextUntapTargetEffect(); + effect.setTargetPointer(new FixedTarget(targetId)); + game.addEffect(effect, source); } } return false; @@ -173,44 +178,3 @@ class PermafrostTrapEffect extends OneShotEffect { return new PermafrostTrapEffect(this); } } - -class PermafrostEffect2 extends ReplacementEffectImpl { - - protected UUID creatureId; - - public PermafrostEffect2(UUID creatureId) { - super(Duration.OneUse, Outcome.Detriment); - this.creatureId = creatureId; - } - - public PermafrostEffect2(final PermafrostEffect2 effect) { - super(effect); - creatureId = effect.creatureId; - } - - @Override - public PermafrostEffect2 copy() { - return new PermafrostEffect2(this); - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean replaceEvent(GameEvent event, Ability source, Game game) { - used = true; - return true; - } - - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - if (game.getTurn().getStepType() == PhaseStep.UNTAP - && event.getType() == GameEvent.EventType.UNTAP - && event.getTargetId().equals(creatureId)) { - return true; - } - return false; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/worldwake/WrexialTheRisenDeep.java b/Mage.Sets/src/mage/sets/worldwake/WrexialTheRisenDeep.java index 527c9833db..a34158a77e 100644 --- a/Mage.Sets/src/mage/sets/worldwake/WrexialTheRisenDeep.java +++ b/Mage.Sets/src/mage/sets/worldwake/WrexialTheRisenDeep.java @@ -137,7 +137,7 @@ class WrexialEffect extends OneShotEffect { class WrexialReplacementEffect extends ReplacementEffectImpl { - private UUID cardid; + private final UUID cardid; public WrexialReplacementEffect(UUID cardid) { super(Duration.EndOfTurn, Outcome.Exile); diff --git a/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java b/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java index 667995762f..032a7f6d73 100644 --- a/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java +++ b/Mage.Sets/src/mage/sets/zendikar/IonaShieldOfEmeria.java @@ -28,8 +28,6 @@ package mage.sets.zendikar; import java.util.UUID; - -import mage.constants.*; import mage.MageInt; import mage.MageObject; import mage.ObjectColor; @@ -38,11 +36,15 @@ 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; import mage.cards.Card; import mage.cards.CardImpl; import mage.choices.ChoiceColor; +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.permanent.Permanent; diff --git a/Mage/src/mage/abilities/effects/ContinuousRuleModifiyingEffectImpl.java b/Mage/src/mage/abilities/effects/ContinuousRuleModifiyingEffectImpl.java index 2c5cb86824..9d4f756bab 100644 --- a/Mage/src/mage/abilities/effects/ContinuousRuleModifiyingEffectImpl.java +++ b/Mage/src/mage/abilities/effects/ContinuousRuleModifiyingEffectImpl.java @@ -78,6 +78,11 @@ public abstract class ContinuousRuleModifiyingEffectImpl extends ContinuousEffec this.messageToGameLog = effect.messageToGameLog; } + @Override + public boolean apply(Game game, Ability source) { + return true; + } + @Override public String getInfoMessage(Ability source, GameEvent event, Game game) { if (infoMessage == null) { diff --git a/Mage/src/mage/abilities/effects/common/combat/CantAttackUnlessDefenderControllsPermanent.java b/Mage/src/mage/abilities/effects/common/combat/CantAttackUnlessDefenderControllsPermanent.java index 9003d753c6..4f512a1c63 100644 --- a/Mage/src/mage/abilities/effects/common/combat/CantAttackUnlessDefenderControllsPermanent.java +++ b/Mage/src/mage/abilities/effects/common/combat/CantAttackUnlessDefenderControllsPermanent.java @@ -28,25 +28,26 @@ package mage.abilities.effects.common.combat; +import java.util.UUID; import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.constants.Duration; -import mage.constants.Outcome; import mage.filter.FilterPermanent; import mage.game.Game; -import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.players.Player; /** * * @author LevelX2 */ -public class CantAttackUnlessDefenderControllsPermanent extends ReplacementEffectImpl { +public class CantAttackUnlessDefenderControllsPermanent extends RestrictionEffect { private final FilterPermanent filter; public CantAttackUnlessDefenderControllsPermanent(FilterPermanent filter) { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + super(Duration.WhileOnBattlefield); this.filter = filter; staticText = new StringBuilder("{this} can't attack unless defending player controls ").append(filter.getMessage()).toString(); } @@ -56,28 +57,37 @@ public class CantAttackUnlessDefenderControllsPermanent extends ReplacementEffec this.filter = effect.filter; } + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getId().equals(source.getSourceId()); + } + + @Override + public boolean canAttack(Game game) { + return false; + } + + @Override + public boolean canAttack(UUID defenderId, Ability source, Game game) { + UUID defendingPlayerId = null; + Player player = game.getPlayer(defenderId); + if (player == null) { + Permanent permanent = game.getPermanent(defenderId); + if (permanent != null) { + defendingPlayerId = permanent.getControllerId(); + } + } else { + defendingPlayerId = defenderId; + } + if (defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) == 0) { + return true; + } + return true; + } + @Override public CantAttackUnlessDefenderControllsPermanent copy() { return new CantAttackUnlessDefenderControllsPermanent(this); } - @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() == GameEvent.EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) { - if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) { - return true; - } - } - return false; - } } \ No newline at end of file diff --git a/Mage/src/mage/abilities/effects/common/combat/CantBlockAttackActivateAttachedEffect.java b/Mage/src/mage/abilities/effects/common/combat/CantBlockAttackActivateAttachedEffect.java index 8f827b9aad..57a6d1b7b4 100644 --- a/Mage/src/mage/abilities/effects/common/combat/CantBlockAttackActivateAttachedEffect.java +++ b/Mage/src/mage/abilities/effects/common/combat/CantBlockAttackActivateAttachedEffect.java @@ -27,23 +27,20 @@ */ package mage.abilities.effects.common.combat; -import mage.constants.Outcome; import mage.abilities.Ability; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.RestrictionEffect; import mage.constants.Duration; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.Permanent; /** * * @author LevelX2 */ - -public class CantBlockAttackActivateAttachedEffect extends ReplacementEffectImpl { +public class CantBlockAttackActivateAttachedEffect extends RestrictionEffect { public CantBlockAttackActivateAttachedEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); + super(Duration.WhileOnBattlefield); staticText = "Enchanted creature can't attack or block, and its activated abilities can't be activated"; } @@ -52,30 +49,34 @@ public class CantBlockAttackActivateAttachedEffect extends ReplacementEffectImpl } @Override - public CantBlockAttackActivateAttachedEffect copy() { - return new CantBlockAttackActivateAttachedEffect(this); - } - - @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() == GameEvent.EventType.DECLARE_ATTACKER || event.getType() == GameEvent.EventType.DECLARE_BLOCKER || event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { - Permanent enchantment = game.getPermanent(source.getSourceId()); - if (enchantment != null && enchantment.getAttachedTo() != null) { - if (event.getSourceId().equals(enchantment.getAttachedTo())) { - return true; - } + public boolean applies(Permanent permanent, Ability source, Game game) { + Permanent enchantment = game.getPermanent(source.getSourceId()); + if (enchantment != null && enchantment.getAttachedTo() != null) { + if (permanent.getId().equals(enchantment.getAttachedTo())) { + return true; } } return false; } + + @Override + public boolean canAttack(Game game) { + return false; + } + + @Override + public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) { + return false; + } + + @Override + public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) { + return false; + } + + @Override + public CantBlockAttackActivateAttachedEffect copy() { + return new CantBlockAttackActivateAttachedEffect(this); + } + } diff --git a/Mage/src/mage/abilities/effects/common/continious/CantCastMoreThanOneSpellEffect.java b/Mage/src/mage/abilities/effects/common/continious/CantCastMoreThanOneSpellEffect.java index f3594f6578..85c37b476d 100644 --- a/Mage/src/mage/abilities/effects/common/continious/CantCastMoreThanOneSpellEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/CantCastMoreThanOneSpellEffect.java @@ -28,18 +28,15 @@ 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; import mage.constants.TargetController; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.watchers.common.CastSpellLastTurnWatcher; /**