From c0ade21efefbbb34ea43fe807e60002f6602deb5 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 13 Oct 2013 11:01:26 +0200 Subject: [PATCH] * Rampart Crawler, Juggernaut - Fixed can't be blocked by walls ability. --- .../sets/mercadianmasques/RampartCrawler.java | 61 +++-------------- Mage.Sets/src/mage/sets/tenth/Juggernaut.java | 68 ++++--------------- .../common/SimpleEvasionAbility.java | 59 ++++++++++++++++ 3 files changed, 85 insertions(+), 103 deletions(-) create mode 100644 Mage/src/mage/abilities/common/SimpleEvasionAbility.java diff --git a/Mage.Sets/src/mage/sets/mercadianmasques/RampartCrawler.java b/Mage.Sets/src/mage/sets/mercadianmasques/RampartCrawler.java index 6cb968fc38b..b6de3359cae 100644 --- a/Mage.Sets/src/mage/sets/mercadianmasques/RampartCrawler.java +++ b/Mage.Sets/src/mage/sets/mercadianmasques/RampartCrawler.java @@ -33,12 +33,12 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.EvasionAbility; -import mage.abilities.effects.common.combat.CantBlockSourceEffect; +import mage.abilities.common.SimpleEvasionAbility; +import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.constants.Zone; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; /** * @@ -46,6 +46,11 @@ import mage.game.permanent.Permanent; */ public class RampartCrawler extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Walls"); + static { + filter.add(new SubtypePredicate("Wall")); + } + public RampartCrawler(UUID ownerId) { super(ownerId, 156, "Rampart Crawler", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{B}"); this.expansionSetCode = "MMQ"; @@ -56,7 +61,7 @@ public class RampartCrawler extends CardImpl { this.toughness = new MageInt(1); // Rampart Crawler can't be blocked by Walls. - this.addAbility(new RampartCrawlerAbility()); + this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); } public RampartCrawler(final RampartCrawler card) { @@ -69,47 +74,3 @@ public class RampartCrawler extends CardImpl { } } - -class RampartCrawlerAbility extends EvasionAbility { - - public RampartCrawlerAbility() { - this.addEffect(new RampartCrawlerEffect()); - } - - public RampartCrawlerAbility(final RampartCrawlerAbility ability) { - super(ability); - } - - @Override - public String getRule() { - return "{this} can't be blocked by Walls."; - } - - @Override - public RampartCrawlerAbility copy() { - return new RampartCrawlerAbility(this); - } - -} - -class RampartCrawlerEffect extends CantBlockSourceEffect { - - public RampartCrawlerEffect() { - super(Duration.WhileOnBattlefield); - } - - public RampartCrawlerEffect(final RampartCrawlerEffect effect) { - super(effect); - } - - @Override - public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - return !blocker.hasSubtype("Wall"); - } - - @Override - public RampartCrawlerEffect copy() { - return new RampartCrawlerEffect(this); - } - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/tenth/Juggernaut.java b/Mage.Sets/src/mage/sets/tenth/Juggernaut.java index 5251e10ae60..34ef2dea784 100644 --- a/Mage.Sets/src/mage/sets/tenth/Juggernaut.java +++ b/Mage.Sets/src/mage/sets/tenth/Juggernaut.java @@ -29,17 +29,16 @@ package mage.sets.tenth; import java.util.UUID; +import mage.MageInt; +import mage.abilities.common.AttacksEachTurnStaticAbility; +import mage.abilities.common.SimpleEvasionAbility; +import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect; +import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Rarity; -import mage.MageInt; -import mage.abilities.Ability; -import mage.abilities.EvasionAbility; -import mage.abilities.common.AttacksEachTurnStaticAbility; -import mage.abilities.effects.common.combat.CantBlockSourceEffect; -import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.mageobject.SubtypePredicate; /** * @@ -47,6 +46,11 @@ import mage.game.permanent.Permanent; */ public class Juggernaut extends CardImpl { + private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Walls"); + static { + filter.add(new SubtypePredicate("Wall")); + } + public Juggernaut(UUID ownerId) { super(ownerId, 328, "Juggernaut", Rarity.UNCOMMON, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{4}"); this.expansionSetCode = "10E"; @@ -54,8 +58,10 @@ public class Juggernaut extends CardImpl { this.power = new MageInt(5); this.toughness = new MageInt(3); + // Juggernaut attacks each turn if able. this.addAbility(new AttacksEachTurnStaticAbility()); - this.addAbility(new JuggernautAbility()); + // Juggernaut can't be blocked by Walls. + this.addAbility(new SimpleEvasionAbility(new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield))); } public Juggernaut(final Juggernaut card) { @@ -68,47 +74,3 @@ public class Juggernaut extends CardImpl { } } - -class JuggernautAbility extends EvasionAbility { - - public JuggernautAbility() { - this.addEffect(new JuggernautEffect()); - } - - public JuggernautAbility(final JuggernautAbility ability) { - super(ability); - } - - @Override - public String getRule() { - return "{this} can't be blocked by Walls."; - } - - @Override - public JuggernautAbility copy() { - return new JuggernautAbility(this); - } - -} - -class JuggernautEffect extends CantBlockSourceEffect { - - public JuggernautEffect() { - super(Duration.WhileOnBattlefield); - } - - public JuggernautEffect(final JuggernautEffect effect) { - super(effect); - } - - @Override - public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { - return !blocker.hasSubtype("Wall"); - } - - @Override - public JuggernautEffect copy() { - return new JuggernautEffect(this); - } - -} diff --git a/Mage/src/mage/abilities/common/SimpleEvasionAbility.java b/Mage/src/mage/abilities/common/SimpleEvasionAbility.java new file mode 100644 index 00000000000..3d12ea68dc6 --- /dev/null +++ b/Mage/src/mage/abilities/common/SimpleEvasionAbility.java @@ -0,0 +1,59 @@ +/* +* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, are +* permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* The views and conclusions contained in the software and documentation are those of the +* authors and should not be interpreted as representing official policies, either expressed +* or implied, of BetaSteward_at_googlemail.com. +*/ + +package mage.abilities.common; + +import mage.abilities.EvasionAbility; +import mage.abilities.effects.Effect; +import mage.constants.Zone; + + + +/** + * + * @author BetaSteward_at_googlemail.com + */ +public class SimpleEvasionAbility extends EvasionAbility { + + public SimpleEvasionAbility(Effect effect) { + super(); + if (effect != null) { + this.addEffect(effect); + } + } + + public SimpleEvasionAbility(SimpleEvasionAbility ability) { + super(ability); + } + + @Override + public SimpleEvasionAbility copy() { + return new SimpleEvasionAbility(this); + } + +}