Search in sources :

Example 81 with Game

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));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 82 with Game

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);
}
Also used : Game(com.faforever.server.entity.Game) Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating) Test(org.junit.Test)

Example 83 with Game

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));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 84 with 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));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Example 85 with Game

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));
}
Also used : Game(com.faforever.server.entity.Game) Test(org.junit.Test)

Aggregations

Game (com.faforever.server.entity.Game)96 Test (org.junit.Test)71 Player (com.faforever.server.entity.Player)26 FeaturedMod (com.faforever.server.entity.FeaturedMod)15 ModVersion (com.faforever.server.entity.ModVersion)12 ConnectionAware (com.faforever.server.client.ConnectionAware)11 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)11 List (java.util.List)11 ClientService (com.faforever.server.client.ClientService)10 ServerProperties (com.faforever.server.config.ServerProperties)10 RequestException (com.faforever.server.error.RequestException)10 ModService (com.faforever.server.mod.ModService)10 VisibleForTesting (com.google.common.annotations.VisibleForTesting)10 Duration (java.time.Duration)10 Map (java.util.Map)10 Optional (java.util.Optional)10 Slf4j (lombok.extern.slf4j.Slf4j)10 Service (org.springframework.stereotype.Service)10 ArmyResult (com.faforever.server.entity.ArmyResult)9 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)9