mirror of
https://github.com/magefree/mage.git
synced 2026-01-23 11:49:56 -08:00
[JUD] Wonder with tests
This commit is contained in:
parent
1cd94a2020
commit
12d597f17e
3 changed files with 216 additions and 0 deletions
|
|
@ -0,0 +1,92 @@
|
|||
package org.mage.test.cards.continuous;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.Card;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
* Wonder
|
||||
* As long as Wonder is in your graveyard and you control an Island, creatures you control have flying.
|
||||
*
|
||||
* @author magenoxx_at_gmail.com
|
||||
*/
|
||||
public class WonderTest extends CardTestPlayerBase {
|
||||
|
||||
/**
|
||||
* Tests creatures for Flying gained from Wonder ability when all conditions were met
|
||||
*/
|
||||
@Test
|
||||
public void testCardWithAllConditionsMet() {
|
||||
addCard(Constants.Zone.GRAVEYARD, playerA, "Wonder");
|
||||
addCard(Constants.Zone.GRAVEYARD, playerA, "Runeclaw Bear");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Corpse Traders");
|
||||
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerB, "Llanowar Elves");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), true);
|
||||
assertAbility(playerA, "Corpse Traders", FlyingAbility.getInstance(), true);
|
||||
assertAbility(playerB, "Llanowar Elves", FlyingAbility.getInstance(), false);
|
||||
|
||||
// check no flying in graveyard
|
||||
for (Card card : playerA.getGraveyard().getCards(currentGame)) {
|
||||
if (card.equals("Runeclaw Bear")) {
|
||||
Assert.assertFalse(card.getAbilities().contains(FlyingAbility.getInstance()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoIsland() {
|
||||
addCard(Constants.Zone.GRAVEYARD, playerA, "Wonder");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Swamp");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOtherZones() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Wonder");
|
||||
addCard(Constants.Zone.HAND, playerA, "Wonder");
|
||||
addCard(Constants.Zone.LIBRARY, playerA, "Wonder");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island");
|
||||
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDestroyIsland() {
|
||||
addCard(Constants.Zone.GRAVEYARD, playerA, "Wonder");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Island");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Mountain", 4);
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Elite Vanguard");
|
||||
addCard(Constants.Zone.HAND, playerA, "Demolish");
|
||||
|
||||
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Demolish", "Island");
|
||||
|
||||
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertAbility(playerA, "Elite Vanguard", FlyingAbility.getInstance(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -357,6 +357,39 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
* @param cardName
|
||||
* @param ability
|
||||
* @param flag true if creature should contain ability, false otherwise
|
||||
* @throws AssertionError
|
||||
*/
|
||||
public void assertAbility(Player player, String cardName, Ability ability, boolean flag) throws AssertionError {
|
||||
int count = 0;
|
||||
Permanent found = null;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
|
||||
if (permanent.getName().equals(cardName)) {
|
||||
found = permanent;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.assertNotNull("There is no such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, found);
|
||||
|
||||
Assert.assertTrue("There is more than one such permanent under player's control, player=" + player.getName() +
|
||||
", cardName=" + cardName, count == 1);
|
||||
|
||||
if (flag) {
|
||||
Assert.assertTrue("No such ability=" + ability.toString() + ", player=" + player.getName() +
|
||||
", cardName" + cardName, found.getAbilities().contains(ability));
|
||||
} else {
|
||||
Assert.assertFalse("Card shouldn't have such ability=" + ability.toString() + ", player=" + player.getName() +
|
||||
", cardName" + cardName, found.getAbilities().contains(ability));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert permanent count under player's control.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue