mirror of
https://github.com/magefree/mage.git
synced 2026-01-10 21:02:08 -08:00
Merge origin/master
This commit is contained in:
commit
8afd51fa04
24 changed files with 246 additions and 289 deletions
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.continuous;
|
||||
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.AbilitiesImpl;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.permanent.Permanent;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author JayDi85
|
||||
*/
|
||||
public class BecomesCreatureAttachedTest extends CardTestPlayerBase {
|
||||
|
||||
// Dryad Arbor -- green creature land
|
||||
|
||||
@Test
|
||||
public void test_CreatureLandWithColor() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dryad Arbor", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Dryad Arbor", 1);
|
||||
assertPowerToughness(playerA, "Dryad Arbor", 1, 1);
|
||||
// land
|
||||
assertColor(playerA, "Forest", "WUBGR", false);
|
||||
// dryad
|
||||
assertColor(playerA, "Dryad Arbor", "G", true);
|
||||
assertColor(playerA, "Dryad Arbor", "WUBR", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AttachToLandWithColorReplace() {
|
||||
// Enchanted land is a 2/2 blue Elemental creature with flying. It’s still a land.
|
||||
addCard(Zone.HAND, playerA, "Wind Zendikon", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dryad Arbor", 1);
|
||||
|
||||
// attach to forest and check color changing
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Wind Zendikon", "Dryad Arbor");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Dryad Arbor", 1);
|
||||
assertPowerToughness(playerA, "Dryad Arbor", 2, 2);
|
||||
assertType("Dryad Arbor", CardType.CREATURE, true);
|
||||
assertType("Dryad Arbor", CardType.LAND, true);
|
||||
assertAbilities(playerA, "Dryad Arbor", new AbilitiesImpl<>(FlyingAbility.getInstance()));
|
||||
assertColor(playerA, "Dryad Arbor", "U", true);
|
||||
assertColor(playerA, "Dryad Arbor", "WBGR", false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_AttachToLandWithColorAdd() {
|
||||
// Enchanted land is a 2/2 blue Elemental creature with flying. It’s still a land.
|
||||
addCard(Zone.HAND, playerA, "Deep Freeze", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Island", 3);
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Dryad Arbor", 1);
|
||||
|
||||
// attach to forest and check color changing
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Deep Freeze", "Dryad Arbor");
|
||||
|
||||
setStopAt(1, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Dryad Arbor", 1);
|
||||
assertPowerToughness(playerA, "Dryad Arbor", 0, 4);
|
||||
assertType("Dryad Arbor", CardType.CREATURE, true);
|
||||
assertType("Dryad Arbor", CardType.LAND, true);
|
||||
assertType("Dryad Arbor", CardType.LAND, SubType.WALL);
|
||||
assertAbilities(playerA, "Dryad Arbor", new AbilitiesImpl<>(DefenderAbility.getInstance()));
|
||||
assertColor(playerA, "Dryad Arbor", "UG", true);
|
||||
assertColor(playerA, "Dryad Arbor", "WBR", false);
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue