mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 22:42:03 -08:00
added test for continuous effects + modified tests to stop on specified turn and step
This commit is contained in:
parent
79be305eb9
commit
4fd59f9e8c
9 changed files with 101 additions and 6 deletions
|
|
@ -6,6 +6,7 @@ import mage.filter.Filter;
|
|||
import mage.players.Player;
|
||||
|
||||
import java.util.List;
|
||||
import mage.Constants.PhaseStep;
|
||||
|
||||
/**
|
||||
* Interface for all test initialization and assertion operations.
|
||||
|
|
@ -82,7 +83,12 @@ public interface CardTestAPI {
|
|||
*/
|
||||
void setStopOnTurn(int turn);
|
||||
|
||||
//******* ASSERT METHODS *******/
|
||||
/**
|
||||
* Define the turn number and step to stop the game on.
|
||||
*/
|
||||
void setStopAt(int turn, PhaseStep step);
|
||||
|
||||
//******* ASSERT METHODS *******/
|
||||
|
||||
/**
|
||||
* Assert turn number after test execution.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import org.mage.test.serverside.base.impl.CardTestAPIImpl;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import mage.Constants.PhaseStep;
|
||||
|
||||
/**
|
||||
* Base class for testing single cards and effects.
|
||||
|
|
@ -92,6 +93,7 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
|||
currentGame = game;
|
||||
|
||||
stopOnTurn = 2;
|
||||
stopAtStep = PhaseStep.UNTAP;
|
||||
handCardsA.clear();
|
||||
handCardsB.clear();
|
||||
battlefieldCardsA.clear();
|
||||
|
|
@ -176,6 +178,7 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
|||
GameOptions gameOptions = new GameOptions();
|
||||
gameOptions.testMode = true;
|
||||
gameOptions.stopOnTurn = stopOnTurn;
|
||||
gameOptions.stopAtStep = stopAtStep;
|
||||
currentGame.start(activePlayer.getId(), gameOptions);
|
||||
long t2 = System.nanoTime();
|
||||
logger.info("Winner: " + currentGame.getWinner());
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.io.FilenameFilter;
|
|||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import mage.Constants.PhaseStep;
|
||||
|
||||
/**
|
||||
* Base class for all tests.
|
||||
|
|
@ -69,6 +70,8 @@ public abstract class MageTestBase {
|
|||
protected static Player activePlayer = null;
|
||||
|
||||
protected Integer stopOnTurn;
|
||||
|
||||
protected PhaseStep stopAtStep = PhaseStep.UNTAP;
|
||||
|
||||
protected enum ParserState {
|
||||
INIT,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.mage.test.serverside.base.MageTestBase;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Constants.PhaseStep;
|
||||
|
||||
/**
|
||||
* API for test initialization and asserting the test results.
|
||||
|
|
@ -187,6 +188,15 @@ public abstract class CardTestAPIImpl extends MageTestBase implements CardTestAP
|
|||
*/
|
||||
public void setStopOnTurn(int turn) {
|
||||
stopOnTurn = turn == -1 ? null : Integer.valueOf(turn);
|
||||
stopAtStep = PhaseStep.UNTAP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define turn number and step to stop the game on.
|
||||
*/
|
||||
public void setStopAt(int turn, PhaseStep step) {
|
||||
stopOnTurn = turn == -1 ? null : Integer.valueOf(turn);
|
||||
stopAtStep = step;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.mage.test.serverside.cards.effects;
|
||||
|
||||
import mage.Constants;
|
||||
import mage.Constants.PhaseStep;
|
||||
import mage.filter.Filter;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
|
@ -21,4 +23,45 @@ public class BoostContinuousEffectTest extends CardTestBase {
|
|||
checkPermanentPT(playerA, "Tine Shrike", 3, 2, Filter.ComparisonScope.Any);
|
||||
checkPermanentPT(playerA, "Runeclaw Bear", 2, 2, Filter.ComparisonScope.Any);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHonorOfThePoor2() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Honor of the Pure");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "White Knight");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Black Knight");
|
||||
|
||||
setStopAt(1, PhaseStep.CLEANUP);
|
||||
execute();
|
||||
assertPowerToughness(playerA, "White Knight", 3, 3, Filter.ComparisonScope.Any);
|
||||
assertPowerToughness(playerA, "Black Knight", 2, 2, Filter.ComparisonScope.Any);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHonorOfThePoor3() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Honor of the Pure");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "White Knight");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Black Knight");
|
||||
|
||||
setStopAt(2, PhaseStep.CLEANUP);
|
||||
execute();
|
||||
assertPowerToughness(playerA, "White Knight", 3, 3, Filter.ComparisonScope.Any);
|
||||
assertPowerToughness(playerA, "Black Knight", 2, 2, Filter.ComparisonScope.Any);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGiantGrowth() {
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Forest");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "White Knight");
|
||||
addCard(Constants.Zone.BATTLEFIELD, playerA, "Black Knight");
|
||||
addCard(Constants.Zone.HAND, playerA, "Giant Growth");
|
||||
|
||||
castSpell(playerA, "Giant Growth");
|
||||
addFixedTarget(playerA, "Giant Growth", "White Knight");
|
||||
|
||||
setStopAt(1, PhaseStep.CLEANUP);
|
||||
execute();
|
||||
assertPowerToughness(playerA, "White Knight", 5, 5, Filter.ComparisonScope.Any);
|
||||
assertPowerToughness(playerA, "Black Knight", 2, 2, Filter.ComparisonScope.Any);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue