Search in sources :

Example 1 with TestPlayer

use of org.mage.test.player.TestPlayer in project mage by magefree.

the class GoadTest method assertAttacking.

private void assertAttacking(String attacker, TestPlayer... players) {
    Assert.assertTrue("At least one player should be provided", players.length > 0);
    Permanent permanent = getPermanent(attacker);
    Assert.assertTrue("Creature should be tapped", permanent.isTapped());
    Assert.assertTrue("Creature should be attacking", permanent.isAttacking());
    UUID defenderId = currentGame.getCombat().getDefenderId(permanent.getId());
    Assert.assertTrue("Creature should be attacking one the following players: " + Arrays.stream(players).map(Player::getName).reduce((a, b) -> a + ", " + b).orElse(""), Arrays.stream(players).map(TestPlayer::getId).anyMatch(defenderId::equals));
}
Also used : TestPlayer(org.mage.test.player.TestPlayer) Arrays(java.util.Arrays) Zone(mage.constants.Zone) RangeOfInfluence(mage.constants.RangeOfInfluence) MultiplayerAttackOption(mage.constants.MultiplayerAttackOption) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Player(mage.players.Player) FileNotFoundException(java.io.FileNotFoundException) FreeForAll(mage.game.FreeForAll) CardTestMultiPlayerBase(org.mage.test.serverside.base.CardTestMultiPlayerBase) Game(mage.game.Game) MulliganType(mage.game.mulligan.MulliganType) Permanent(mage.game.permanent.Permanent) PhaseStep(mage.constants.PhaseStep) Assert(org.junit.Assert) GameException(mage.game.GameException) TestPlayer(org.mage.test.player.TestPlayer) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TestPlayer(org.mage.test.player.TestPlayer) UUID(java.util.UUID)

Example 2 with TestPlayer

use of org.mage.test.player.TestPlayer in project mage by magefree.

the class CardTestPlayerAPIImpl method assertAllCommandsUsed.

/**
 * Raise error on any unused commands, choices or targets If you want to
 * test that ability can't be activated then use call checkPlayableAbility()
 *
 * @throws AssertionError
 */
public void assertAllCommandsUsed() throws AssertionError {
    for (Player player : currentGame.getPlayers().values()) {
        TestPlayer testPlayer = (TestPlayer) player;
        assertActionsMustBeEmpty(testPlayer);
        assertChoicesCount(testPlayer, 0);
        assertTargetsCount(testPlayer, 0);
    }
}
Also used : Player(mage.players.Player) TestPlayer(org.mage.test.player.TestPlayer) GameSessionPlayer(mage.server.game.GameSessionPlayer) TestPlayer(org.mage.test.player.TestPlayer)

Example 3 with TestPlayer

use of org.mage.test.player.TestPlayer in project mage by magefree.

the class CardTestPlayerBaseWithMonteCarloAIHelps method createPlayer.

@Override
protected TestPlayer createPlayer(String name, RangeOfInfluence rangeOfInfluence) {
    TestPlayer testPlayer = new TestPlayer(new TestComputerPlayerMonteCarlo(name, RangeOfInfluence.ONE, 6));
    // AI can't play it by itself, use AI commands
    testPlayer.setAIPlayer(false);
    return testPlayer;
}
Also used : TestPlayer(org.mage.test.player.TestPlayer) TestComputerPlayerMonteCarlo(org.mage.test.player.TestComputerPlayerMonteCarlo)

Example 4 with TestPlayer

use of org.mage.test.player.TestPlayer in project mage by magefree.

the class CardTestCommander4PlayersWithAIHelps method createPlayer.

@Override
protected TestPlayer createPlayer(String name, RangeOfInfluence rangeOfInfluence) {
    // use same RangeOfInfluence.ALL as CardTestCommander4Players do
    TestPlayer testPlayer = new TestPlayer(new TestComputerPlayer7(name, RangeOfInfluence.ALL, 6));
    // AI can't play it by itself, use AI commands
    testPlayer.setAIPlayer(false);
    return testPlayer;
}
Also used : TestPlayer(org.mage.test.player.TestPlayer) TestComputerPlayer7(org.mage.test.player.TestComputerPlayer7)

Example 5 with TestPlayer

use of org.mage.test.player.TestPlayer in project mage by magefree.

the class CardTestPlayerBaseWithAIHelps method createPlayer.

@Override
protected TestPlayer createPlayer(String name, RangeOfInfluence rangeOfInfluence) {
    TestPlayer testPlayer = new TestPlayer(new TestComputerPlayer7(name, RangeOfInfluence.ONE, 6));
    // AI can't play it by itself, use AI commands
    testPlayer.setAIPlayer(false);
    return testPlayer;
}
Also used : TestPlayer(org.mage.test.player.TestPlayer) TestComputerPlayer7(org.mage.test.player.TestComputerPlayer7)

Aggregations

TestPlayer (org.mage.test.player.TestPlayer)9 Player (mage.players.Player)5 GameSessionPlayer (mage.server.game.GameSessionPlayer)3 TestComputerPlayer7 (org.mage.test.player.TestComputerPlayer7)3 FileNotFoundException (java.io.FileNotFoundException)2 Arrays (java.util.Arrays)2 UUID (java.util.UUID)2 Collectors (java.util.stream.Collectors)2 MultiplayerAttackOption (mage.constants.MultiplayerAttackOption)2 PhaseStep (mage.constants.PhaseStep)2 RangeOfInfluence (mage.constants.RangeOfInfluence)2 Zone (mage.constants.Zone)2 FreeForAll (mage.game.FreeForAll)2 Game (mage.game.Game)2 GameException (mage.game.GameException)2 MulliganType (mage.game.mulligan.MulliganType)2 Permanent (mage.game.permanent.Permanent)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2 CardTestMultiPlayerBase (org.mage.test.serverside.base.CardTestMultiPlayerBase)2