Search in sources :

Example 6 with GameView

use of mage.view.GameView in project mage by magefree.

the class CardIconsTest method test_CostX_MDFC.

@Test
public void test_CostX_MDFC() {
    // Agadeem's Awakening
    // Sorcery {X}{B}{B}{B}
    // Return from your graveyard to the battlefield any number of target creature cards that each have a different converted mana cost X or less.
    // 
    // Agadeem, the Undercrypt
    // Land
    // As Agadeem, the Undercrypt enters the battlefield, you may pay 3 life. If you don't, it enters the battlefield tapped.
    addCard(Zone.HAND, playerA, "Agadeem's Awakening", 2);
    addCard(Zone.BATTLEFIELD, playerA, "Swamp", 5);
    // hand (not visible)
    runCode("card icons in hand", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
        GameView gameView = getGameView(player);
        CardView cardView = gameView.getHand().values().stream().filter(c -> c.getName().equals("Agadeem's Awakening")).findFirst().orElse(null);
        Assert.assertEquals("main must have non x cost card icons in hand", 0, cardView.getCardIcons().size());
        Assert.assertEquals("right must have non x cost card icons in hand", 0, cardView.getSecondCardFace().getCardIcons().size());
    });
    // play spell and check X
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Agadeem's Awakening");
    setChoice(playerA, "X=2");
    addTarget(playerA, TestPlayer.TARGET_SKIP);
    // stack (spell - visible)
    runCode("card icons on stack (visible)", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
        GameView gameView = getGameView(player);
        Assert.assertEquals("must have 1 card in stack", 1, gameView.getStack().values().size());
        CardView cardView = gameView.getStack().values().stream().filter(c -> c.getName().equals("Agadeem's Awakening")).findFirst().orElse(null);
        Assert.assertEquals("main must have x cost card icons in stack", 1, cardView.getCardIcons().size());
        Assert.assertNull("right must be null in stack", cardView.getSecondCardFace());
    });
    waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
    // play land and check X
    playLand(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Agadeem, the Undercrypt");
    // not pay life
    setChoice(playerA, false);
    runCode("card icons in battlefield", 1, PhaseStep.PRECOMBAT_MAIN, playerA, (info, player, game) -> {
        GameView gameView = getGameView(player);
        PlayerView playerView = gameView.getPlayers().get(0);
        Assert.assertEquals("player", player.getName(), playerView.getName());
        CardView cardView = playerView.getBattlefield().values().stream().filter(p -> p.getName().equals("Agadeem, the Undercrypt")).findFirst().orElse(null);
        Assert.assertNotNull("must have Agadeem, the Undercrypt in battlefield", cardView);
        Assert.assertEquals("main must have not x cost card icons in battlefield", 0, cardView.getCardIcons().size());
        Assert.assertNull("second side must be null", cardView.getSecondCardFace());
    });
    setStrictChooseMode(true);
    setStopAt(1, PhaseStep.END_TURN);
    execute();
    assertAllCommandsUsed();
}
Also used : CardView(mage.view.CardView) PlayerView(mage.view.PlayerView) GameView(mage.view.GameView) Test(org.junit.Test)

Example 7 with GameView

use of mage.view.GameView in project mage by magefree.

the class ReplaySession method replay.

public void replay() {
    replay.start();
    managerFactory.userManager().getUser(userId).ifPresent(user -> user.fireCallback(new ClientCallback(ClientCallbackMethod.REPLAY_INIT, replay.getGame().getId(), new GameView(replay.next(), replay.getGame(), null, null))));
}
Also used : ClientCallback(mage.interfaces.callback.ClientCallback) GameView(mage.view.GameView)

Aggregations

GameView (mage.view.GameView)7 Test (org.junit.Test)5 CardView (mage.view.CardView)4 PlayerView (mage.view.PlayerView)4 PhaseStep (mage.constants.PhaseStep)1 Zone (mage.constants.Zone)1 ClientCallback (mage.interfaces.callback.ClientCallback)1 ZippedObjectImpl (mage.remote.traffic.ZippedObjectImpl)1 Assert (org.junit.Assert)1 TestPlayer (org.mage.test.player.TestPlayer)1 CardTestPlayerBase (org.mage.test.serverside.base.CardTestPlayerBase)1