use of com.faforever.server.entity.Player in project faf-java-server by FAForever.
the class GameServiceTest method reportArmyScoreWithCheater.
/**
* Tests whether the service correctly chooses the scores reported by the majority of connected players and ignores
* the results reported by a "cheater" (that is, someone who reports different results).
*/
@Test
public void reportArmyScoreWithCheater() throws Exception {
Game game = hostGame(player1);
Player player3 = (Player) new Player().setId(3);
addPlayer(game, player2);
addPlayer(game, player3);
instance.updatePlayerOption(player1, player1.getId(), OPTION_ARMY, 1);
instance.updatePlayerOption(player1, player2.getId(), OPTION_ARMY, 2);
instance.updatePlayerOption(player1, player3.getId(), OPTION_ARMY, 3);
launchGame(game);
instance.reportArmyScore(player1, 1, 10);
instance.reportArmyScore(player1, 2, -1);
instance.reportArmyScore(player1, 3, -1);
instance.reportArmyOutcome(player1, 1, Outcome.VICTORY);
instance.reportArmyOutcome(player1, 2, Outcome.DEFEAT);
instance.reportArmyOutcome(player1, 3, Outcome.DEFEAT);
instance.reportArmyScore(player2, 1, 10);
instance.reportArmyScore(player2, 2, -1);
instance.reportArmyScore(player2, 3, -1);
instance.reportArmyOutcome(player2, 1, Outcome.VICTORY);
instance.reportArmyOutcome(player2, 2, Outcome.DEFEAT);
instance.reportArmyOutcome(player2, 3, Outcome.DEFEAT);
instance.reportArmyScore(player3, 1, -1);
instance.reportArmyScore(player3, 2, -1);
instance.reportArmyScore(player3, 3, 10);
instance.reportArmyOutcome(player3, 1, Outcome.DEFEAT);
instance.reportArmyOutcome(player3, 2, Outcome.DEFEAT);
instance.reportArmyOutcome(player3, 3, Outcome.VICTORY);
instance.updatePlayerGameState(PlayerGameState.ENDED, player1);
instance.updatePlayerGameState(PlayerGameState.ENDED, player2);
instance.updatePlayerGameState(PlayerGameState.ENDED, player3);
assertThat(game.getPlayerStats().values(), hasSize(3));
assertThat(game.getPlayerStats().get(player1.getId()).getScore(), is(10));
assertThat(game.getPlayerStats().get(player2.getId()).getScore(), is(-1));
assertThat(game.getPlayerStats().get(player3.getId()).getScore(), is(-1));
}
use of com.faforever.server.entity.Player 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.Player in project faf-java-server by FAForever.
the class LegacyServicesActivatorsTest method setUp.
@Before
public void setUp() throws Exception {
clientConnection = new ClientConnection("1", Protocol.V1_LEGACY_UTF_16, mock(InetAddress.class));
player = new Player();
player.setClientConnection(clientConnection);
when(geoIpService.lookupCountryCode(any())).thenReturn(Optional.empty());
instance = new LegacyServicesActivators(authenticationManager, clientService, uniqueIdService, geoIpService, playerService, chatService, counterService);
}
use of com.faforever.server.entity.Player in project faf-java-server by FAForever.
the class GameServiceTest method updateGameValidityUnevenTeams.
@Test
public void updateGameValidityUnevenTeams() throws Exception {
Player player3 = (Player) new Player().setId(3);
Game game = hostGame(player1);
addPlayer(game, player2);
addPlayer(game, player3);
instance.updatePlayerOption(player1, player1.getId(), OPTION_TEAM, 2);
instance.updatePlayerOption(player1, player2.getId(), OPTION_TEAM, 2);
instance.updatePlayerOption(player1, player3.getId(), OPTION_TEAM, 3);
launchGame(game);
instance.updateGameValidity(game);
assertThat(game.getValidity(), is(Validity.UNEVEN_TEAMS));
}
use of com.faforever.server.entity.Player in project faf-java-server by FAForever.
the class AvatarServiceActivatorTest method setUp.
@Before
public void setUp() throws Exception {
player = new Player();
authentication = new TestingAuthenticationToken(new FafUserDetails((User) new User().setPlayer(player).setPassword("pw").setLogin("JUnit")), null);
instance = new AvatarServiceActivator(avatarService);
}
Aggregations