use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method mutualDrawRequestedByAllPlayers.
@Test
public void mutualDrawRequestedByAllPlayers() throws Exception {
Game game = hostGame(player1);
instance.updatePlayerOption(player1, player1.getId(), OPTION_TEAM, 2);
instance.joinGame(game.getId(), game.getPassword(), player2);
instance.updatePlayerGameState(PlayerGameState.LOBBY, player2);
instance.updatePlayerOption(player1, player2.getId(), OPTION_TEAM, 3);
Player player3 = new Player();
player3.setId(3);
instance.joinGame(game.getId(), game.getPassword(), player3);
instance.updatePlayerGameState(PlayerGameState.LOBBY, player3);
instance.updatePlayerOption(player1, player3.getId(), OPTION_TEAM, GameService.OBSERVERS_TEAM_ID);
launchGame(game);
instance.mutuallyAgreeDraw(player1);
assertThat(game.isMutuallyAgreedDraw(), is(false));
instance.mutuallyAgreeDraw(player2);
assertThat(game.isMutuallyAgreedDraw(), is(true));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method endGameIfNoPlayerConnected.
@Test
public void endGameIfNoPlayerConnected() throws Exception {
Game game = hostGame(player1);
assertThat(game.getState(), is(GameState.OPEN));
addPlayer(game, player2);
assertThat(game.getState(), is(GameState.OPEN));
instance.updatePlayerGameState(PlayerGameState.CLOSED, player1);
assertThat(game.getState(), is(GameState.OPEN));
instance.updatePlayerGameState(PlayerGameState.CLOSED, player2);
assertThat(game.getState(), is(GameState.CLOSED));
assertThat(player1.getCurrentGame(), is(nullValue()));
assertThat(player1.getGameState(), is(PlayerGameState.NONE));
assertThat(player2.getCurrentGame(), is(nullValue()));
assertThat(player2.getGameState(), is(PlayerGameState.NONE));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method mutualDrawRequestedByPlayerWithoutGame.
@Test
public void mutualDrawRequestedByPlayerWithoutGame() throws Exception {
Game game = hostGame(player1);
launchGame(game);
expectedException.expect(requestExceptionWithCode(ErrorCode.NOT_IN_A_GAME));
instance.mutuallyAgreeDraw(player2);
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method simpleTwoPlayerGame.
@Test
@SuppressWarnings("unchecked")
public void simpleTwoPlayerGame() throws Exception {
Game game = hostGame(player1);
addPlayer(game, player2);
instance.updatePlayerOption(player1, player1.getId(), OPTION_ARMY, 1);
instance.updatePlayerOption(player1, player2.getId(), OPTION_ARMY, 2);
launchGame(game);
instance.reportArmyScore(player1, 1, 10);
instance.reportArmyScore(player1, 2, -1);
instance.reportArmyOutcome(player1, 1, Outcome.VICTORY);
instance.reportArmyOutcome(player1, 2, Outcome.DEFEAT);
instance.reportArmyScore(player2, 1, 10);
instance.reportArmyScore(player2, 2, -1);
instance.reportArmyOutcome(player2, 1, Outcome.VICTORY);
instance.reportArmyOutcome(player2, 2, Outcome.DEFEAT);
instance.updatePlayerGameState(PlayerGameState.ENDED, player1);
instance.updatePlayerGameState(PlayerGameState.ENDED, player2);
instance.updatePlayerGameState(PlayerGameState.CLOSED, player1);
verify(clientService).disconnectPlayerFromGame(eq(player1.getId()), (Collection<? extends ConnectionAware>) argThat(Matchers.contains(player2)));
instance.updatePlayerGameState(PlayerGameState.CLOSED, player2);
verify(clientService).disconnectPlayerFromGame(eq(player2.getId()), argThat(Matchers.empty()));
assertThat(game.getPlayerStats().values(), hasSize(2));
assertThat(game.getPlayerStats().get(player1.getId()).getScore(), is(10));
assertThat(game.getPlayerStats().get(player2.getId()).getScore(), is(-1));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method onGameEndedProcessesStatsIfGameStarted.
@Test
public void onGameEndedProcessesStatsIfGameStarted() throws Exception {
Game game = hostGame(player1);
launchGame(game);
instance.updatePlayerGameState(PlayerGameState.ENDED, player1);
assertThat(game.getState(), is(GameState.ENDED));
verify(armyStatisticsService).process(any(), eq(game), any());
verifyZeroInteractions(divisionService);
assertThat(player1.getCurrentGame(), is(game));
assertThat(player1.getGameState(), is(PlayerGameState.ENDED));
}
Aggregations