use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method updateGameValidityTooManyDesyncs.
@Test
public void updateGameValidityTooManyDesyncs() throws Exception {
Game game = hostGame(player1);
game.getDesyncCounter().set(5);
launchGame(game);
instance.updateGameValidity(game);
assertThat(game.getValidity(), is(Validity.TOO_MANY_DESYNCS));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method onLadder1v1GameEndedProcessedStats.
@Test
public void onLadder1v1GameEndedProcessedStats() throws Exception {
when(modService.isLadder1v1(any())).thenReturn(true);
player1.setLadder1v1Rating(mock(Ladder1v1Rating.class));
player2.setLadder1v1Rating(mock(Ladder1v1Rating.class));
Game game = hostGame(player1);
addPlayer(game, player2);
launchGame(game);
Stream.of(player1, player2).forEach(player -> {
instance.reportArmyOutcome(player, 1, Outcome.VICTORY);
instance.reportArmyScore(player, 1, 10);
instance.reportArmyOutcome(player, 2, Outcome.DEFEAT);
instance.reportArmyScore(player, 2, -1);
});
assertThat(game.getValidity(), is(Validity.VALID));
verify(divisionService).postResult(player1, player2, player1);
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method joinGameWithPassword.
@Test
public void joinGameWithPassword() throws Exception {
Game game = hostGame(player1);
game.setPassword("pw");
instance.joinGame(game.getId(), "pw", player2);
verify(clientService).startGameProcess(game, player2);
assertThat(player2.getCurrentGame(), is(game));
assertThat(player2.getGameState(), is(PlayerGameState.INITIALIZING));
instance.updatePlayerGameState(PlayerGameState.LOBBY, player2);
assertThat(player2.getCurrentGame(), is(game));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method updatePlayerOption.
@Test
public void updatePlayerOption() throws Exception {
Game game = hostGame(player1);
instance.updatePlayerOption(player1, player1.getId(), OPTION_FACTION, 1);
assertThat(game.getPlayerOptions().get(player1.getId()).get(OPTION_FACTION), is(1));
instance.updatePlayerOption(player1, player1.getId(), OPTION_FACTION, 2);
assertThat(game.getPlayerOptions().get(player1.getId()).get(OPTION_FACTION), is(2));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class GameServiceTest method reportArmyScore.
@Test
public void reportArmyScore() 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);
instance.reportArmyScore(player1, 1, 10);
instance.reportArmyScore(player1, 2, -1);
instance.reportArmyScore(player2, 1, 10);
instance.reportArmyScore(player2, 2, -1);
assertThat(game.getReportedArmyResults().values(), hasSize(2));
assertThat(game.getReportedArmyResults().get(player1.getId()).values(), hasSize(2));
assertThat(game.getReportedArmyResults().get(player2.getId()).values(), hasSize(2));
}
Aggregations