diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java index d405956f83..24f6e7cce9 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/base/impl/CardTestPlayerAPIImpl.java @@ -1,6 +1,7 @@ package org.mage.test.serverside.base.impl; import mage.Mana; +import mage.ObjectColor; import mage.abilities.Ability; import mage.cards.Card; import mage.cards.decks.Deck; @@ -516,20 +517,20 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement } } - public void assertAbility(Player player, String cardName, Ability ability, boolean flag) throws AssertionError { - assertAbility(player, cardName, ability, flag, 1); + public void assertAbility(Player player, String cardName, Ability ability, boolean mustHave) throws AssertionError { + assertAbility(player, cardName, ability, mustHave, 1); } /** * @param player * @param cardName * @param ability - * @param flag true if creature should contain ability, false if it should + * @param mustHave true if creature should contain ability, false if it should * NOT contain it instead * @param count number of permanents with that ability * @throws AssertionError */ - public void assertAbility(Player player, String cardName, Ability ability, boolean flag, int count) throws AssertionError { + public void assertAbility(Player player, String cardName, Ability ability, boolean mustHave, int count) throws AssertionError { int foundCount = 0; Permanent found = null; for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) { @@ -545,7 +546,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement Assert.assertTrue("There is another number (" + foundCount + ") as defined (" + count + ") of such permanents under player's control, player=" + player.getName() + ", cardName=" + cardName, count == foundCount); - if (flag) { + if (mustHave) { Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName() + ", cardName" + cardName, found.getAbilities(currentGame).containsRule(ability)); } else { @@ -682,9 +683,9 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement * * @param cardName Name of the permanent that should be checked. * @param type A type to test for - * @param flag true if creature should have type, false if it should not + * @param mustHave true if creature should have type, false if it should not */ - public void assertType(String cardName, CardType type, boolean flag) throws AssertionError { + public void assertType(String cardName, CardType type, boolean mustHave) throws AssertionError { Permanent found = null; for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) { if (permanent.getName().equals(cardName)) { @@ -695,7 +696,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found); - Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', (found.getCardType().contains(type) == flag)); + Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', (found.getCardType().contains(type) == mustHave)); } @@ -738,6 +739,42 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement } } + /** + * Assert permanent color + * + * @param player player to check + * @param cardName card name on battlefield from player + * @param searchColors colors list with searchable values + * @param mustHave must or not must have that colors + */ + public void assertColor(Player player, String cardName, ObjectColor searchColors, boolean mustHave) { + Assert.assertNotEquals("must setup colors to search", 0, searchColors.getColorCount()); + + Permanent card = getPermanent(cardName, player); + ObjectColor cardColor = card.getColor(currentGame); + + List<ObjectColor> colorsHave = new ArrayList<>(); + List<ObjectColor> colorsDontHave = new ArrayList<>(); + + for (ObjectColor searchColor : searchColors.getColors()) { + if (cardColor.shares(searchColor)) { + colorsHave.add(searchColor); + } else { + colorsDontHave.add(searchColor); + } + } + + if (mustHave) { + Assert.assertEquals("must contain colors [" + searchColors.toString() + "] but found only [" + cardColor.toString() + "]", 0, colorsDontHave.size()); + } else { + Assert.assertEquals("must not contain colors [" + searchColors.toString() + "] but found [" + cardColor.toString() + "]", 0, colorsHave.size()); + } + } + + public void assertColor(Player player, String cardName, String searchColors, boolean mustHave) { + assertColor(player, cardName, new ObjectColor(searchColors), mustHave); + } + /** * Assert whether a permanent is tapped or not *