use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class CoopService method reportOperationComplete.
public void reportOperationComplete(Player player, boolean secondaryTargets, Duration duration) {
Game game = player.getCurrentGame();
Requests.verify(game != null, ErrorCode.COOP_CANT_REPORT_NOT_IN_GAME);
log.debug("Player '{}' reported coop result '{}' with secondary targets '{}' for game: {}", player, duration, secondaryTargets, game);
Optional<CoopMap> optional = coopMapRepository.findOneByFilenameLikeIgnoreCase(game.getMapName());
if (optional.isPresent()) {
CoopLeaderboardEntry coopLeaderboardEntry = new CoopLeaderboardEntry();
coopLeaderboardEntry.setGameId(game.getId());
coopLeaderboardEntry.setMission(optional.get());
coopLeaderboardEntry.setPlayerCount(game.getPlayerStats().size());
coopLeaderboardEntry.setSecondary(secondaryTargets);
coopLeaderboardEntry.setTime(new Time(duration.toMillis()));
coopLeaderboardRepository.save(coopLeaderboardEntry);
}
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class TeamKillServiceTest method reportTeamKillWhenKillerDoesntExist.
@Test
public void reportTeamKillWhenKillerDoesntExist() throws Exception {
Player player = new Player();
player.setCurrentGame(new Game());
player.setId(1);
when(playerService.getOnlinePlayer(player.getId())).thenReturn(Optional.of(player));
instance.reportTeamKill(player, Duration.ofMinutes(28), 991234, player.getId());
verifyZeroInteractions(teamKillRepository);
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class TeamKillServiceTest method reportTeamKill.
@Test
public void reportTeamKill() throws Exception {
Game game = new Game();
game.setId(10);
Player player = (Player) new Player().setCurrentGame(game).setId(1);
Player killer = (Player) new Player().setId(2);
when(playerService.getOnlinePlayer(player.getId())).thenReturn(Optional.of(player));
when(playerService.getOnlinePlayer(killer.getId())).thenReturn(Optional.of(killer));
instance.reportTeamKill(player, Duration.ofMinutes(28), killer.getId(), player.getId());
ArgumentCaptor<TeamKill> captor = ArgumentCaptor.forClass(TeamKill.class);
verify(teamKillRepository).save(captor.capture());
TeamKill teamKill = captor.getValue();
assertThat(teamKill.getGameId(), is(game.getId()));
assertThat(teamKill.getTeamKiller(), is(killer.getId()));
assertThat(teamKill.getVictim(), is(player.getId()));
assertThat(teamKill.getGameTime(), is((int) Duration.ofMinutes(28).getSeconds()));
assertThat(teamKill.getReportedAt().after(Timestamp.from(Instant.now().minusSeconds(10))), is(true));
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class TeamKillServiceTest method reportTeamKillWhenVictimIsntReported.
@Test
public void reportTeamKillWhenVictimIsntReported() throws Exception {
Player reporter = new Player();
reporter.setCurrentGame(new Game());
reporter.setId(1);
Player killer = (Player) new Player().setId(2);
Player victim = (Player) new Player().setId(2);
when(playerService.getOnlinePlayer(killer.getId())).thenReturn(Optional.of(killer));
instance.reportTeamKill(reporter, Duration.ofMinutes(28), killer.getId(), victim.getId());
verifyZeroInteractions(teamKillRepository);
}
use of com.faforever.server.entity.Game in project faf-java-server by FAForever.
the class ClientServiceTest method hostGame.
@Test
public void hostGame() throws Exception {
Game game = new Game().setId(1).setMapName("SCMP_001");
instance.hostGame(game, player);
ArgumentCaptor<HostGameResponse> captor = ArgumentCaptor.forClass(HostGameResponse.class);
verify(clientGateway).send(captor.capture(), any());
assertThat(captor.getValue().getMapFilename(), is("SCMP_001"));
}
Aggregations