From 3940cd4b95efe1f7145fc67ec2f638401469e890 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 29 Dec 2014 16:32:50 +0100 Subject: [PATCH] Some minor rework. --- .../sets/bornofthegods/FloodtideSerpent.java | 9 +++- .../bornofthegods/SpiritOfTheLabyrinth.java | 1 - .../sets/commander2014/ContainmentPriest.java | 9 +++- .../mage/sets/fifthdawn/MycosynthGolem.java | 5 ++ .../src/mage/sets/fifthedition/Dandan.java | 51 ++---------------- .../journeyintonyx/DictateOfTheTwinGods.java | 16 ++++-- .../src/mage/sets/journeyintonyx/Godsend.java | 1 - .../journeyintonyx/KruphixGodOfHorizons.java | 7 ++- .../sets/journeyintonyx/OppressiveRays.java | 11 ++++ .../sets/khansoftarkir/HardenedScales.java | 8 ++- .../sets/khansoftarkir/KheruLichLord.java | 5 ++ .../mage/sets/khansoftarkir/UginsNexus.java | 7 ++- .../mage/sets/limitedalpha/PirateShip.java | 47 ++-------------- .../magic2010/SerpentOfTheEndlessSea.java | 50 ++--------------- .../mage/sets/magic2015/AggressiveMining.java | 1 - .../mage/sets/magic2015/ChiefEngineer.java | 5 ++ .../sets/modernmasters/DoublingSeason.java | 13 +++-- .../sets/modernmasters/PyromancersSwath.java | 26 +++++---- .../src/mage/sets/odyssey/Dreamwinder.java | 13 ++--- .../src/mage/sets/tempest/SeaMonster.java | 54 ++----------------- .../src/mage/sets/theros/SealockMonster.java | 50 ++--------------- .../src/mage/sets/theros/WhipOfErebos.java | 10 ++-- .../filter/common/FilterLandPermanent.java | 7 +++ 23 files changed, 131 insertions(+), 275 deletions(-) diff --git a/Mage.Sets/src/mage/sets/bornofthegods/FloodtideSerpent.java b/Mage.Sets/src/mage/sets/bornofthegods/FloodtideSerpent.java index 9770502208..3fbea0866e 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/FloodtideSerpent.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/FloodtideSerpent.java @@ -43,6 +43,7 @@ import mage.filter.common.FilterControlledPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; import mage.players.Player; import mage.target.common.TargetControlledPermanent; @@ -116,9 +117,15 @@ class FloodtideSerpentReplacementEffect extends ReplacementEffectImpl { return false; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == EventType.DECLARE_ATTACKER; + } + + @Override public boolean applies(GameEvent event, Ability source, Game game) { - return event.getType() == GameEvent.EventType.DECLARE_ATTACKER && event.getSourceId().equals(source.getSourceId()); + return event.getSourceId().equals(source.getSourceId()); } @Override diff --git a/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java b/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java index bf572c9478..6614ba2dc9 100644 --- a/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java +++ b/Mage.Sets/src/mage/sets/bornofthegods/SpiritOfTheLabyrinth.java @@ -33,7 +33,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.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; diff --git a/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java b/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java index f94d5bc97c..119ebc74eb 100644 --- a/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java +++ b/Mage.Sets/src/mage/sets/commander2014/ContainmentPriest.java @@ -127,11 +127,16 @@ class ContainmentPriestReplacementEffect extends ReplacementEffectImpl { } return false; } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE - && ((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) { + if (((ZoneChangeEvent) event).getToZone() == Zone.BATTLEFIELD) { Card card = game.getCard(event.getTargetId()); if (card.getCardType().contains(CardType.CREATURE)) { // TODO: Bestow Card cast as Enchantment probably not handled correctly CreatureCastWatcher watcher = (CreatureCastWatcher) game.getState().getWatchers().get("CreatureWasCast"); diff --git a/Mage.Sets/src/mage/sets/fifthdawn/MycosynthGolem.java b/Mage.Sets/src/mage/sets/fifthdawn/MycosynthGolem.java index f36778f94e..8f746dd82e 100644 --- a/Mage.Sets/src/mage/sets/fifthdawn/MycosynthGolem.java +++ b/Mage.Sets/src/mage/sets/fifthdawn/MycosynthGolem.java @@ -110,6 +110,11 @@ class MycosynthGolemEffect extends ReplacementEffectImpl { } return false; } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CAST_SPELL; + } @Override public boolean applies(GameEvent event, Ability source, Game game) { diff --git a/Mage.Sets/src/mage/sets/fifthedition/Dandan.java b/Mage.Sets/src/mage/sets/fifthedition/Dandan.java index c554f4b47c..e4bdaeb606 100644 --- a/Mage.Sets/src/mage/sets/fifthedition/Dandan.java +++ b/Mage.Sets/src/mage/sets/fifthedition/Dandan.java @@ -29,15 +29,13 @@ package mage.sets.fifthedition; import java.util.UUID; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.StateTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.SacrificeSourceEffect; +import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.cards.CardImpl; import mage.constants.*; -import mage.filter.FilterPermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.permanent.ControllerControlsIslandPredicate; import mage.game.Game; import mage.game.events.GameEvent; @@ -59,7 +57,8 @@ public class Dandan extends CardImpl { this.toughness = new MageInt(1); // Dandan can't attack unless defending player controls an Island. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DandanEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); + // When you control no Islands, sacrifice Dandan. this.addAbility(new DandanTriggeredAbility()); } @@ -74,46 +73,6 @@ public class Dandan extends CardImpl { } } -class DandanEffect extends ReplacementEffectImpl { - - public DandanEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "{this} can't attack unless defending player controls an Island"; - } - - public DandanEffect(final DandanEffect effect) { - super(effect); - } - - @Override - public DandanEffect copy() { - return new DandanEffect(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())) { - FilterPermanent filter = new FilterPermanent(); - filter.add(new SubtypePredicate("Island")); - - if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) { - return true; - } - } - return false; - } -} - class DandanTriggeredAbility extends StateTriggeredAbility { public DandanTriggeredAbility() { @@ -136,6 +95,6 @@ class DandanTriggeredAbility extends StateTriggeredAbility { @Override public String getRule() { - return "When you control no islands, sacrifice {this}."; + return "When you control no Islands, sacrifice {this}."; } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfTheTwinGods.java b/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfTheTwinGods.java index 86a938d6b9..adeedcc96a 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfTheTwinGods.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/DictateOfTheTwinGods.java @@ -92,15 +92,21 @@ class DictateOfTheTwinGodsEffect extends ReplacementEffectImpl { return new DictateOfTheTwinGodsEffect(this); } - @Override - public boolean applies(GameEvent event, Ability source, Game game) { - switch (event.getType()) { - case DAMAGE_PLAYER: + @Override + public boolean checksEventType(GameEvent event, Game game) { + switch(event.getType()) { case DAMAGE_CREATURE: + case DAMAGE_PLAYER: case DAMAGE_PLANESWALKER: return true; + default: + return false; } - return false; + } + + @Override + public boolean applies(GameEvent event, Ability source, Game game) { + return true; } @Override diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/Godsend.java b/Mage.Sets/src/mage/sets/journeyintonyx/Godsend.java index e8e64dee96..e6952a3c52 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/Godsend.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/Godsend.java @@ -39,7 +39,6 @@ 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; import mage.abilities.keyword.EquipAbility; import mage.cards.Card; diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/KruphixGodOfHorizons.java b/Mage.Sets/src/mage/sets/journeyintonyx/KruphixGodOfHorizons.java index 8484d18233..1a6c3c3533 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/KruphixGodOfHorizons.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/KruphixGodOfHorizons.java @@ -115,8 +115,13 @@ class KruphixGodOfHorizonsEffect extends ReplacementEffectImpl { return true; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.EMPTY_MANA_POOL; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - return event.getType() == GameEvent.EventType.EMPTY_MANA_POOL && event.getPlayerId().equals(source.getControllerId()); + return event.getPlayerId().equals(source.getControllerId()); } } \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/OppressiveRays.java b/Mage.Sets/src/mage/sets/journeyintonyx/OppressiveRays.java index 5984401af4..56b325b77f 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/OppressiveRays.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/OppressiveRays.java @@ -129,6 +129,17 @@ class OppressiveRaysEffect extends ReplacementEffectImpl { return false; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + switch(event.getType()) { + case DECLARE_ATTACKER: + case DECLARE_BLOCKER: + return true; + default: + return false; + } + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType().equals(GameEvent.EventType.DECLARE_ATTACKER)) { diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/HardenedScales.java b/Mage.Sets/src/mage/sets/khansoftarkir/HardenedScales.java index 7d77dc2189..fc97f22659 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/HardenedScales.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/HardenedScales.java @@ -40,6 +40,7 @@ import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -86,9 +87,14 @@ class HardenedScalesEffect extends ReplacementEffectImpl { return false; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == EventType.ADD_COUNTERS; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.ADD_COUNTERS && event.getData().equals(CounterType.P1P1.getName())) { + if (event.getData().equals(CounterType.P1P1.getName())) { Permanent target = game.getPermanent(event.getTargetId()); if (target != null && target.getControllerId().equals(source.getControllerId()) && target.getCardType().contains(CardType.CREATURE)) { diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java b/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java index bcbd847eb3..050d830558 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/KheruLichLord.java @@ -185,6 +185,11 @@ class KheruLichLordReplacementEffect extends ReplacementEffectImpl { return true; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == GameEvent.EventType.ZONE_CHANGE diff --git a/Mage.Sets/src/mage/sets/khansoftarkir/UginsNexus.java b/Mage.Sets/src/mage/sets/khansoftarkir/UginsNexus.java index ad0c08dd4b..a42e7fcc9c 100644 --- a/Mage.Sets/src/mage/sets/khansoftarkir/UginsNexus.java +++ b/Mage.Sets/src/mage/sets/khansoftarkir/UginsNexus.java @@ -143,7 +143,12 @@ class UginsNexusExileEffect extends ReplacementEffectImpl { } return false; } - + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == EventType.ZONE_CHANGE; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getType() == EventType.ZONE_CHANGE && event.getTargetId().equals(source.getSourceId())) { diff --git a/Mage.Sets/src/mage/sets/limitedalpha/PirateShip.java b/Mage.Sets/src/mage/sets/limitedalpha/PirateShip.java index bf2c3aa644..6276a4f570 100644 --- a/Mage.Sets/src/mage/sets/limitedalpha/PirateShip.java +++ b/Mage.Sets/src/mage/sets/limitedalpha/PirateShip.java @@ -34,14 +34,13 @@ import mage.abilities.StateTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.TapSourceCost; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.DamageTargetEffect; import mage.abilities.effects.common.SacrificeSourceEffect; +import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.cards.CardImpl; import mage.constants.*; -import mage.filter.FilterPermanent; +import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.permanent.ControllerControlsIslandPredicate; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.game.events.GameEvent; import mage.target.common.TargetCreatureOrPlayer; @@ -64,7 +63,7 @@ public class PirateShip extends CardImpl { this.toughness = new MageInt(3); // Pirate Ship can't attack unless defending player controls an Island. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PirateShipEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); // {tap}: Pirate Ship deals 1 damage to target creature or player. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new TapSourceCost()); ability.addTarget(new TargetCreatureOrPlayer()); @@ -83,46 +82,6 @@ public class PirateShip extends CardImpl { } } -class PirateShipEffect extends ReplacementEffectImpl { - - public PirateShipEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "{this} can't attack unless defending player controls an Island"; - } - - public PirateShipEffect(final PirateShipEffect effect) { - super(effect); - } - - @Override - public PirateShipEffect copy() { - return new PirateShipEffect(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())) { - FilterPermanent filter = new FilterPermanent(); - filter.add(new SubtypePredicate("Island")); - - if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) { - return true; - } - } - return false; - } -} - class PirateShipTriggeredAbility extends StateTriggeredAbility { public PirateShipTriggeredAbility() { diff --git a/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java b/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java index 2dbf701221..211a59e95f 100644 --- a/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java +++ b/Mage.Sets/src/mage/sets/magic2010/SerpentOfTheEndlessSea.java @@ -30,21 +30,17 @@ package mage.sets.magic2010; 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.dynamicvalue.common.PermanentsOnBattlefieldCount; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.effects.common.continious.SetPowerToughnessSourceEffect; import mage.cards.CardImpl; -import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledPermanent; +import mage.filter.common.FilterLandPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.game.events.GameEvent; /** * @@ -70,7 +66,7 @@ public class SerpentOfTheEndlessSea extends CardImpl { // Serpent of the Endless Sea's power and toughness are each equal to the number of Islands you control. this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(filter), Duration.EndOfGame))); // Serpent of the Endless Sea can't attack unless defending player controls an Island. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SerpentOfTheEndlessSeaEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); } public SerpentOfTheEndlessSea(final SerpentOfTheEndlessSea card) { @@ -82,43 +78,3 @@ public class SerpentOfTheEndlessSea extends CardImpl { return new SerpentOfTheEndlessSea(this); } } - -class SerpentOfTheEndlessSeaEffect extends ReplacementEffectImpl { - - public SerpentOfTheEndlessSeaEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "{this} can't attack unless defending player controls an Island"; - } - - public SerpentOfTheEndlessSeaEffect(final SerpentOfTheEndlessSeaEffect effect) { - super(effect); - } - - @Override - public SerpentOfTheEndlessSeaEffect copy() { - return new SerpentOfTheEndlessSeaEffect(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())) { - FilterPermanent filter = new FilterPermanent(); - filter.add(new SubtypePredicate("Island")); - - if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) { - return true; - } - } - return false; - } -} diff --git a/Mage.Sets/src/mage/sets/magic2015/AggressiveMining.java b/Mage.Sets/src/mage/sets/magic2015/AggressiveMining.java index 62293b09ce..3c909a8378 100644 --- a/Mage.Sets/src/mage/sets/magic2015/AggressiveMining.java +++ b/Mage.Sets/src/mage/sets/magic2015/AggressiveMining.java @@ -34,7 +34,6 @@ import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.Cost; import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; -import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.DrawCardSourceControllerEffect; import mage.cards.CardImpl; import mage.constants.CardType; diff --git a/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java b/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java index ffb27619d8..a0b23f2619 100644 --- a/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java +++ b/Mage.Sets/src/mage/sets/magic2015/ChiefEngineer.java @@ -108,6 +108,11 @@ class ChiefEngineerEffect extends ReplacementEffectImpl { } return false; } + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.CAST_SPELL; + } @Override public boolean applies(GameEvent event, Ability source, Game game) { diff --git a/Mage.Sets/src/mage/sets/modernmasters/DoublingSeason.java b/Mage.Sets/src/mage/sets/modernmasters/DoublingSeason.java index 5899913389..44583eddf5 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/DoublingSeason.java +++ b/Mage.Sets/src/mage/sets/modernmasters/DoublingSeason.java @@ -130,13 +130,16 @@ class DoublingSeasonCounterEffect extends ReplacementEffectImpl { return false; } + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ADD_COUNTERS; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.ADD_COUNTERS) { - Permanent target = game.getPermanent(event.getTargetId()); - if (target != null && target.getControllerId().equals(source.getControllerId())) { - return true; - } + Permanent target = game.getPermanent(event.getTargetId()); + if (target != null && target.getControllerId().equals(source.getControllerId())) { + return true; } return false; } diff --git a/Mage.Sets/src/mage/sets/modernmasters/PyromancersSwath.java b/Mage.Sets/src/mage/sets/modernmasters/PyromancersSwath.java index c10cad77ca..b1f71a9606 100644 --- a/Mage.Sets/src/mage/sets/modernmasters/PyromancersSwath.java +++ b/Mage.Sets/src/mage/sets/modernmasters/PyromancersSwath.java @@ -86,17 +86,25 @@ class PyromancersSwathReplacementEffect extends ReplacementEffectImpl { super(effect); } + @Override + public boolean checksEventType(GameEvent event, Game game) { + switch(event.getType()) { + case DAMAGE_CREATURE: + case DAMAGE_PLAYER: + return true; + default: + return false; + } + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER) - || event.getType().equals(GameEvent.EventType.DAMAGE_CREATURE)) { - MageObject object = game.getObject(event.getSourceId()); - if (object != null && object instanceof Spell) { - if (((Spell) object).getControllerId().equals(source.getControllerId()) - && (object.getCardType().contains(CardType.INSTANT) - || object.getCardType().contains(CardType.SORCERY))){ - return true; - } + MageObject object = game.getObject(event.getSourceId()); + if (object != null && object instanceof Spell) { + if (((Spell) object).getControllerId().equals(source.getControllerId()) + && (object.getCardType().contains(CardType.INSTANT) + || object.getCardType().contains(CardType.SORCERY))){ + return true; } } return false; diff --git a/Mage.Sets/src/mage/sets/odyssey/Dreamwinder.java b/Mage.Sets/src/mage/sets/odyssey/Dreamwinder.java index fb43abf91c..d9a583d09a 100644 --- a/Mage.Sets/src/mage/sets/odyssey/Dreamwinder.java +++ b/Mage.Sets/src/mage/sets/odyssey/Dreamwinder.java @@ -42,7 +42,6 @@ import mage.constants.Duration; import mage.constants.Rarity; import mage.constants.Zone; import mage.filter.common.FilterLandPermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.target.Target; import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetLandPermanent; @@ -52,13 +51,7 @@ import mage.target.common.TargetLandPermanent; * @author cbt33, LevelX2 (Walk the Aeons), KholdFuzion (Dandan) */ public class Dreamwinder extends CardImpl { - - private static final FilterLandPermanent filter = new FilterLandPermanent("an Island"); - - static { - filter.add(new SubtypePredicate("Island")); - } - + public Dreamwinder(UUID ownerId) { super(ownerId, 83, "Dreamwinder", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{3}{U}"); this.expansionSetCode = "ODY"; @@ -69,12 +62,12 @@ public class Dreamwinder extends CardImpl { this.toughness = new MageInt(3); // Dreamwinder can't attack unless defending player controls an Island. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(filter))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); // {U}, Sacrifice an Island: Target land becomes an Island until end of turn. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new BecomesBasicLandTargetEffect(Duration.EndOfTurn, "Island"), new ManaCostsImpl("{U}")); Target target = new TargetLandPermanent(); ability.addTarget(target); - ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, filter, true))); + ability.addCost(new SacrificeTargetCost(new TargetControlledPermanent(1, 1, new FilterLandPermanent("Island","an Island"), true))); this.addAbility(ability); } diff --git a/Mage.Sets/src/mage/sets/tempest/SeaMonster.java b/Mage.Sets/src/mage/sets/tempest/SeaMonster.java index 59bca7b48c..1b19dbf315 100644 --- a/Mage.Sets/src/mage/sets/tempest/SeaMonster.java +++ b/Mage.Sets/src/mage/sets/tempest/SeaMonster.java @@ -29,26 +29,20 @@ package mage.sets.tempest; 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.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.cards.CardImpl; -import mage.filter.FilterPermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; -import mage.game.Game; -import mage.game.events.GameEvent; +import mage.filter.common.FilterLandPermanent; /** * * @author Plopman */ public class SeaMonster extends CardImpl { - + public SeaMonster(UUID ownerId) { super(ownerId, 85, "Sea Monster", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{4}{U}{U}"); this.expansionSetCode = "TMP"; @@ -59,7 +53,7 @@ import mage.game.events.GameEvent; this.toughness = new MageInt(6); // Sea Monster can't attack unless defending player controls an Island. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SeaMonsterEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); } public SeaMonster(final SeaMonster card) { @@ -71,43 +65,3 @@ import mage.game.events.GameEvent; return new SeaMonster(this); } } - -class SeaMonsterEffect extends ReplacementEffectImpl { - - public SeaMonsterEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "{this} can't attack unless defending player controls an Island"; - } - - public SeaMonsterEffect(final SeaMonsterEffect effect) { - super(effect); - } - - @Override - public SeaMonsterEffect copy() { - return new SeaMonsterEffect(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())) { - FilterPermanent filter = new FilterPermanent(); - filter.add(new SubtypePredicate("Island")); - - if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) { - return true; - } - } - return false; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/theros/SealockMonster.java b/Mage.Sets/src/mage/sets/theros/SealockMonster.java index c03050b2b6..59cf68779c 100644 --- a/Mage.Sets/src/mage/sets/theros/SealockMonster.java +++ b/Mage.Sets/src/mage/sets/theros/SealockMonster.java @@ -33,7 +33,7 @@ import mage.abilities.Ability; import mage.abilities.common.BecomesMonstrousSourceTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousEffectImpl; -import mage.abilities.effects.ReplacementEffectImpl; +import mage.abilities.effects.common.combat.CantAttackUnlessDefenderControllsPermanent; import mage.abilities.keyword.MonstrosityAbility; import mage.abilities.mana.BlueManaAbility; import mage.cards.CardImpl; @@ -44,10 +44,8 @@ import mage.constants.Outcome; import mage.constants.Rarity; import mage.constants.SubLayer; import mage.constants.Zone; -import mage.filter.FilterPermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; +import mage.filter.common.FilterLandPermanent; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.Target; import mage.target.common.TargetLandPermanent; @@ -68,7 +66,7 @@ public class SealockMonster extends CardImpl { this.toughness = new MageInt(5); // Sealock Monster can't attack unless defending player controls an Island. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SealockMonsterCantAttackEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackUnlessDefenderControllsPermanent(new FilterLandPermanent("Island","an Island")))); // {5}{U}{U}: Monstrosity 3. this.addAbility(new MonstrosityAbility("{5}{U}{U}",3)); // When Sealock Monster becomes monstrous, target land becomes an island in addition to its other types. @@ -89,48 +87,6 @@ public class SealockMonster extends CardImpl { } } -class SealockMonsterCantAttackEffect extends ReplacementEffectImpl { - - private static final FilterPermanent filter = new FilterPermanent();; - static { - filter.add(new SubtypePredicate("Island")); - } - - public SealockMonsterCantAttackEffect() { - super(Duration.WhileOnBattlefield, Outcome.Detriment); - staticText = "{this} can't attack unless defending player controls an Island"; - } - - public SealockMonsterCantAttackEffect(final SealockMonsterCantAttackEffect effect) { - super(effect); - } - - @Override - public SealockMonsterCantAttackEffect copy() { - return new SealockMonsterCantAttackEffect(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; - } -} - class SealockMonsterBecomesIslandTargetEffect extends ContinuousEffectImpl { private static Ability islandAbility = new BlueManaAbility(); diff --git a/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java b/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java index bcf0cebff6..e9146fd50e 100644 --- a/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java +++ b/Mage.Sets/src/mage/sets/theros/WhipOfErebos.java @@ -161,11 +161,15 @@ class WhipOfErebosReplacementEffect extends ReplacementEffectImpl { } return true; } - + + @Override + public boolean checksEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE; + } + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.ZONE_CHANGE - && event.getTargetId().equals(source.getFirstTarget()) + if (event.getTargetId().equals(source.getFirstTarget()) && ((ZoneChangeEvent) event).getFromZone().equals(Zone.BATTLEFIELD) && !((ZoneChangeEvent) event).getToZone().equals(Zone.EXILED)) { return true; diff --git a/Mage/src/mage/filter/common/FilterLandPermanent.java b/Mage/src/mage/filter/common/FilterLandPermanent.java index 15c674f41b..1fa06da6f1 100644 --- a/Mage/src/mage/filter/common/FilterLandPermanent.java +++ b/Mage/src/mage/filter/common/FilterLandPermanent.java @@ -31,6 +31,7 @@ package mage.filter.common; import mage.constants.CardType; import mage.filter.FilterPermanent; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.SubtypePredicate; /** * @@ -47,6 +48,12 @@ public class FilterLandPermanent extends FilterPermanent { this.add(new CardTypePredicate(CardType.LAND)); } + public FilterLandPermanent(String subtype, String name) { + super(name); + this.add(new CardTypePredicate(CardType.LAND)); + this.add(new SubtypePredicate(subtype)); + } + public FilterLandPermanent(final FilterLandPermanent filter) { super(filter); }