mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 12:02:01 -08:00
Added a test.
This commit is contained in:
parent
b169e7e6c7
commit
7d3ff0551d
6 changed files with 117 additions and 10 deletions
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* 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.planeswalker;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class UginTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testCard() {
|
||||
// +2: Ugin, the Spirit Dragon deals 3 damage to target creature or player.
|
||||
// -X: Exile each permanent with converted mana cost X or less that's one or more colors.
|
||||
// -10: You gain 7 life, draw 7 cards, then put up to seven permanent cards from your hand onto the battlefield.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Ugin, the Spirit Dragon"); // starts with 7 Loyality counters
|
||||
// Whenever a creature dies, you may put a quest counter on Quest for the Gravelord.
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Quest for the Gravelord");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
|
||||
|
||||
addCard(Zone.LIBRARY, playerB, "Forest", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Forest", 6);
|
||||
// When Nissa, Vastwood Seer enters the battlefield, you may search your library for a basic Forest card, reveal it, put it into your hand, then shuffle your library.
|
||||
// Whenever a land enters the battlefield under your control, if you control seven or more lands, exile Nissa, then return her to the battlefield transformed under her owner's control.
|
||||
// +1: Reveal the top card of your library. If it's a land card, put it onto the battlefield. Otherwise, put it into your hand.
|
||||
// -2: Put a legendary 4/4 green Elemental creature token named Ashaya, the Awoken World onto the battlefield.
|
||||
// -7: Untap up to six target lands. They become 6/6 Elemental creatures. They're still lands.
|
||||
addCard(Zone.HAND, playerB, "Nissa, Vastwood Seer");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+2: {source} deals 3 damage to target creature or player.", playerB);
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Nissa, Vastwood Seer");
|
||||
playLand(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Forest");
|
||||
activateAbility(2, PhaseStep.POSTCOMBAT_MAIN, playerB, "-2: Put a legendary 4/4 green Elemental creature token named Ashaya, the Awoken World onto the battlefield.");
|
||||
|
||||
attack(3, playerA, "Silvercoat Lion");
|
||||
block(3, playerB, "Ashaya, the Awoken World", "Silvercoat Lion");
|
||||
|
||||
activateAbility(3, PhaseStep.POSTCOMBAT_MAIN, playerA, "-X: Exile each permanent with converted mana cost X or less that's one or more colors");
|
||||
setChoice(playerA, "X=0");
|
||||
|
||||
setStopAt(3, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertPermanentCount(playerA, "Ugin, the Spirit Dragon", 1);
|
||||
assertCounterCount("Ugin, the Spirit Dragon", CounterType.LOYALTY, 9); // 7 + 2 - 0
|
||||
|
||||
assertGraveyardCount(playerA, "Silvercoat Lion", 1);
|
||||
assertPermanentCount(playerB, "Ashaya, the Awoken World", 0);
|
||||
|
||||
assertExileCount("Nissa, Vastwood Seer", 1);
|
||||
|
||||
assertCounterCount("Quest for the Gravelord", CounterType.QUEST, 1);
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 17);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -253,6 +253,9 @@ public class TestPlayer implements Player {
|
|||
int targetsSet = 0;
|
||||
for (Player player : game.getPlayers().values()) {
|
||||
if (player.getName().equals(target)) {
|
||||
if (ability.getTargets().isEmpty()) {
|
||||
throw new UnsupportedOperationException("Ability has no targets, but there is a player target set - " + ability.toString());
|
||||
}
|
||||
ability.getTargets().get(0).addTarget(player.getId(), ability, game);
|
||||
targetsSet++;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -219,6 +219,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
*
|
||||
* @param player {@link Player} to remove all library cards from.
|
||||
*/
|
||||
@Override
|
||||
public void removeAllCardsFromLibrary(TestPlayer player) {
|
||||
getCommands(player).put(Zone.LIBRARY, "clear");
|
||||
}
|
||||
|
|
@ -241,6 +242,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* playerB.
|
||||
* @param cardName Card name in string format.
|
||||
*/
|
||||
@Override
|
||||
public void addCard(Zone gameZone, TestPlayer player, String cardName) {
|
||||
addCard(gameZone, player, cardName, 1, false);
|
||||
}
|
||||
|
|
@ -254,6 +256,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param cardName Card name in string format.
|
||||
* @param count Amount of cards to be added.
|
||||
*/
|
||||
@Override
|
||||
public void addCard(Zone gameZone, TestPlayer player, String cardName, int count) {
|
||||
addCard(gameZone, player, cardName, count, false);
|
||||
}
|
||||
|
|
@ -270,6 +273,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* permanent should be tapped. In case gameZone is other than Battlefield,
|
||||
* {@link IllegalArgumentException} is thrown
|
||||
*/
|
||||
@Override
|
||||
public void addCard(Zone gameZone, TestPlayer player, String cardName, int count, boolean tapped) {
|
||||
|
||||
if (gameZone.equals(Zone.BATTLEFIELD)) {
|
||||
|
|
@ -324,6 +328,7 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
* @param player {@link Player} to set life count for.
|
||||
* @param life Life count to set.
|
||||
*/
|
||||
@Override
|
||||
public void setLife(TestPlayer player, int life) {
|
||||
getCommands(player).put(Zone.OUTSIDE, "life:" + String.valueOf(life));
|
||||
}
|
||||
|
|
@ -714,16 +719,16 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
/**
|
||||
* Assert whether X permanents of the same name are tapped or not.
|
||||
*
|
||||
* @param cardName Name of the permanent that should be checked.
|
||||
* @param tapped Whether the permanent is tapped or not
|
||||
* @param count The amount of this permanents that should be tapped
|
||||
* @param cardName Name of the permanent that should be checked.
|
||||
* @param tapped Whether the permanent is tapped or not
|
||||
* @param count The amount of this permanents that should be tapped
|
||||
*/
|
||||
public void assertTappedCount(String cardName, boolean tapped, int count) throws AssertionError {
|
||||
int tappedAmount = 0;
|
||||
Permanent found = null;
|
||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getName().equals(cardName)) {
|
||||
if(permanent.isTapped() == tapped) {
|
||||
if (permanent.isTapped() == tapped) {
|
||||
tappedAmount++;
|
||||
}
|
||||
found = permanent;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue