use of mage.game.match.MatchOptions in project mage by magefree.
the class LoadTest method playTwoAIGame.
public void playTwoAIGame(String gameName, String deckColors, String deckAllowedSets, LoadTestGameResult gameResult) {
Assert.assertFalse("need deck colors", deckColors.isEmpty());
Assert.assertFalse("need allowed sets", deckAllowedSets.isEmpty());
// monitor and game source
LoadPlayer monitor = new LoadPlayer("monitor", true);
// game by monitor
GameTypeView gameType = monitor.session.getGameTypes().get(0);
MatchOptions gameOptions = createSimpleGameOptionsForAI(gameType, monitor.session, gameName);
TableView game = monitor.session.createTable(monitor.roomID, gameOptions);
UUID tableId = game.getTableId();
DeckCardLists deckList = DeckTestUtils.buildRandomDeckAndInitCards(deckColors, false, deckAllowedSets);
Optional<TableView> checkGame;
// join AI
Assert.assertTrue(monitor.session.joinTable(monitor.roomID, tableId, "ai_1", PlayerType.COMPUTER_MAD, 5, deckList, ""));
Assert.assertTrue(monitor.session.joinTable(monitor.roomID, tableId, "ai_2", PlayerType.COMPUTER_MAD, 5, deckList, ""));
// match start
Assert.assertTrue(monitor.session.startMatch(monitor.roomID, tableId));
// playing until game over
gameResult.start();
boolean startToWatching = false;
while (true) {
GameView gameView = monitor.client.getLastGameView();
checkGame = monitor.getTable(tableId);
TableState state = checkGame.get().getTableState();
logger.warn(checkGame.get().getTableName() + (gameView != null ? ", turn " + gameView.getTurn() + ", " + gameView.getStep().toString() : "") + (gameView != null ? ", active " + gameView.getActivePlayerName() : "") + ", " + state);
if (state == TableState.FINISHED) {
gameResult.finish(gameView);
break;
}
if (!startToWatching && state == TableState.DUELING) {
Assert.assertTrue(monitor.session.watchGame(checkGame.get().getGames().iterator().next()));
startToWatching = true;
}
if (gameView != null) {
for (PlayerView p : gameView.getPlayers()) {
logger.info(p.getName() + " - Life=" + p.getLife() + "; Lib=" + p.getLibraryCount());
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
}
}
use of mage.game.match.MatchOptions in project mage by magefree.
the class CardTestPlayerAPIImpl method reset.
/**
* @throws GameException
* @throws FileNotFoundException
*/
@Before
public void reset() throws GameException, FileNotFoundException {
if (currentGame != null) {
logger.debug("Resetting previous game and creating new one!");
currentGame = null;
}
// prepare fake match (needs for testing some client-server code)
// always 4 seats
MatchOptions matchOptions = new MatchOptions("test match", "test game type", true, 4);
currentMatch = new FreeForAllMatch(matchOptions);
currentGame = createNewGameAndPlayers();
activePlayer = playerA;
stopOnTurn = 2;
stopAtStep = PhaseStep.UNTAP;
for (Player player : currentGame.getPlayers().values()) {
TestPlayer testPlayer = (TestPlayer) player;
getCommands(testPlayer).clear();
getLibraryCards(testPlayer).clear();
getHandCards(testPlayer).clear();
getBattlefieldCards(testPlayer).clear();
getGraveCards(testPlayer).clear();
// Reset the turn counter for tests
((TestPlayer) player).setInitialTurns(0);
}
gameOptions = new GameOptions();
rollbackBlock = 0;
rollbackBlockActive = false;
}
use of mage.game.match.MatchOptions in project mage by magefree.
the class FreeformUnlimitedCommanderMatchTest method test_getOptions_returnsOriginalOptions.
@Test
public void test_getOptions_returnsOriginalOptions() {
// Arrange
MatchOptions options = new MatchOptions("test name", "test match name", false, 2);
Match match = new FreeformUnlimitedCommanderMatch(options);
// Act
MatchOptions actual = match.getOptions();
// Assert
Assert.assertEquals(options, actual);
}
use of mage.game.match.MatchOptions in project mage by magefree.
the class FreeformUnlimitedCommanderMatchTest method test_getName_returnsTestName.
@Test
public void test_getName_returnsTestName() {
// Arrange
MatchOptions options = new MatchOptions("test name", "test match name", false, 2);
Match match = new FreeformUnlimitedCommanderMatch(options);
// Act
String actual = match.getName();
// Assert
Assert.assertEquals("test name", actual);
}
use of mage.game.match.MatchOptions in project mage by magefree.
the class FreeformUnlimitedCommanderMatchTest method test_construct_returnsFreeformPlusCommanderMatch.
@Test
public void test_construct_returnsFreeformPlusCommanderMatch() {
// Arrange
MatchOptions options = new MatchOptions("test name", "test match name", false, 2);
// Act
Match match = new FreeformUnlimitedCommanderMatch(options);
// Assert
Assert.assertEquals(FreeformUnlimitedCommanderMatch.class, match.getClass());
}
Aggregations