diff --git a/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java b/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java index cbef2790095..aba8d9e873e 100644 --- a/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java +++ b/Mage.Sets/src/mage/sets/magic2011/HarborSerpent.java @@ -39,7 +39,6 @@ import mage.abilities.effects.RestrictionEffect; import mage.abilities.keyword.IslandwalkAbility; import mage.cards.CardImpl; import mage.filter.common.FilterLandPermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; import mage.game.permanent.Permanent; @@ -58,7 +57,10 @@ public class HarborSerpent extends CardImpl { this.power = new MageInt(5); this.toughness = new MageInt(5); + // Islandwalk (This creature is unblockable as long as defending player controls an Island.) this.addAbility(new IslandwalkAbility()); + + // Harbor Serpent can't attack unless there are five or more Islands on the battlefield. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HarborSerpentEffect())); } @@ -74,11 +76,10 @@ public class HarborSerpent extends CardImpl { class HarborSerpentEffect extends RestrictionEffect { - private final FilterLandPermanent filter = new FilterLandPermanent("Island"); + private static final FilterLandPermanent filter = new FilterLandPermanent("Island", "Island"); public HarborSerpentEffect() { super(Duration.WhileOnBattlefield); - filter.add(new SubtypePredicate("Island")); staticText = "{this} can't attack unless there are five or more Islands on the battlefield"; } @@ -97,10 +98,8 @@ class HarborSerpentEffect extends RestrictionEffect { } @Override - public boolean applies(Permanent permanent, Ability source, Game game) { - if (game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 5) { - return true; - } - return false; + public boolean applies(Permanent permanent, Ability source, Game game) { + return permanent.getId().equals(source.getSourceId()) && + game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game) < 5; } } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/restriction/CantAttackTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/restriction/CantAttackTest.java index 479e09910a9..a2d26ce8ee9 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/restriction/CantAttackTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/restriction/CantAttackTest.java @@ -66,6 +66,31 @@ public class CantAttackTest extends CardTestPlayerBase { assertLife(playerB, 14); // 4 + 2 } + + @Test + public void testAttackHarborSerpent() { + addCard(Zone.BATTLEFIELD, playerA, "Island", 2); + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // 2/2 + addCard(Zone.BATTLEFIELD, playerA, "Harbor Serpent"); // 5/5 + addCard(Zone.HAND, playerA, "Island"); + + addCard(Zone.BATTLEFIELD, playerB, "Island", 2); + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2 + addCard(Zone.BATTLEFIELD, playerB, "Harbor Serpent"); // 5/5 + + attack(2, playerB, "Harbor Serpent"); + attack(2, playerB, "Silvercoat Lion"); + playLand(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Island"); + attack(3, playerA, "Harbor Serpent"); + attack(3, playerA, "Silvercoat Lion"); + + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertLife(playerB, 13); + assertLife(playerA, 18); + } + }