From 21e2066bba6ea05fc7a97e998affa49f623fb0e4 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 8 Jun 2015 22:51:48 +0200 Subject: [PATCH] * Akron Legionnaire - Fixed not correct working restrict ability. --- .../java/mage/client/game/PlayAreaPanel.java | 2 +- .../mage/sets/legends/AkronLegionnaire.java | 31 +++----- .../mage/test/cards/mana/ManaFlareTest.java | 2 +- .../cards/restriction/CantAttackTest.java | 71 +++++++++++++++++++ 4 files changed, 82 insertions(+), 24 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/restriction/CantAttackTest.java diff --git a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java index 4ffc7cd5f8..8f5a31791f 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayAreaPanel.java @@ -89,6 +89,7 @@ public class PlayAreaPanel extends javax.swing.JPanel { * @param options */ public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime, GamePanel gamePanel, PlayAreaPanelOptions options) { + this.gamePanel = gamePanel; this.options = options; initComponents(); setOpaque(false); @@ -101,7 +102,6 @@ public class PlayAreaPanel extends javax.swing.JPanel { addPopupMenuWatcher(); } this.add(popupMenu); - this.gamePanel = gamePanel; init(player, bigCard, gameId, priorityTime); update(player); } diff --git a/Mage.Sets/src/mage/sets/legends/AkronLegionnaire.java b/Mage.Sets/src/mage/sets/legends/AkronLegionnaire.java index 2a9d35dc5c..307b1ff995 100644 --- a/Mage.Sets/src/mage/sets/legends/AkronLegionnaire.java +++ b/Mage.Sets/src/mage/sets/legends/AkronLegionnaire.java @@ -30,8 +30,8 @@ package mage.sets.legends; import java.util.UUID; import mage.MageInt; import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.Effect; import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect; -import mage.cards.Card; import mage.cards.CardImpl; import mage.constants.CardType; import mage.constants.Duration; @@ -39,9 +39,10 @@ import mage.constants.Rarity; import mage.constants.TargetController; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicate; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.permanent.ControllerPredicate; -import mage.game.Game; /** * @@ -53,7 +54,8 @@ public class AkronLegionnaire extends CardImpl { static { filter.add(new ControllerPredicate(TargetController.YOU)); - filter.add(new AkronLegionairePredicate()); + filter.add(Predicates.not(new NamePredicate("Akron Legionnaire"))); + filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT))); } public AkronLegionnaire(UUID ownerId) { @@ -65,7 +67,9 @@ public class AkronLegionnaire extends CardImpl { this.toughness = new MageInt(4); // Except for creatures named Akron Legionnaire and artifact creatures, creatures you control can't attack. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter))); + Effect effect = new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter); + effect.setText("Except for creatures named Akron Legionnaire and artifact creatures, creatures you control can't attack"); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect)); } @@ -78,20 +82,3 @@ public class AkronLegionnaire extends CardImpl { return new AkronLegionnaire(this); } } - -class AkronLegionairePredicate implements Predicate { - - public AkronLegionairePredicate() { - } - - @Override - public boolean apply(Card input, Game game) { - return !input.getCardType().contains(CardType.ARTIFACT) - || !input.getName().contains("Akron Legionaire"); - } - - @Override - public String toString() { - return ""; - } -} \ No newline at end of file diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/mana/ManaFlareTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/mana/ManaFlareTest.java index 823b579cce..f81242ffc2 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/mana/ManaFlareTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/mana/ManaFlareTest.java @@ -41,7 +41,7 @@ public class ManaFlareTest extends CardTestPlayerBase { @Test public void testIsland() { - // {T}: Add one mana of any color to your mana pool. Spend this mana only to cast a multicolored spell. + // Whenever a player taps a land for mana, that player adds one mana to his or her mana pool of any type that land produced. addCard(Zone.BATTLEFIELD, playerA, "Mana Flare", 1); addCard(Zone.BATTLEFIELD, playerA, "Island", 1); 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 new file mode 100644 index 0000000000..479e09910a --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/restriction/CantAttackTest.java @@ -0,0 +1,71 @@ +/* + * 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 org.mage.test.cards.restriction; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ + +public class CantAttackTest extends CardTestPlayerBase { + + /** + * Tests "If all other elves get the Forestwalk ability and can't be blockt from creatures whose controler has a forest in game" + */ + + @Test + public void testAttack() { + addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion"); // 2/2 + addCard(Zone.BATTLEFIELD, playerA, "Myr Enforcer"); // 4/4 + + addCard(Zone.BATTLEFIELD, playerB, "Akron Legionnaire"); // 8/4 + addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion"); // 2/2 + addCard(Zone.BATTLEFIELD, playerB, "Myr Enforcer"); // 4/4 + + attack(2, playerB, "Akron Legionnaire"); + attack(2, playerB, "Silvercoat Lion"); + attack(2, playerB, "Myr Enforcer"); + + attack(3, playerA, "Silvercoat Lion"); + attack(3, playerA, "Myr Enforcer"); + + setStopAt(3, PhaseStep.POSTCOMBAT_MAIN); + execute(); + + assertLife(playerA, 8); // 8 + 4 + assertLife(playerB, 14); // 4 + 2 + + } + +} +