Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackYps committed Oct 23, 2023
1 parent 9ab725e commit 9ef6f6b
Showing 1 changed file with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,23 +469,25 @@ private List<TeamCardController> createTeamCardControllers(Map<String, List<Game
return controller;
}).toList();
}

private GameOutcome calculateGameResult(Map<PlayerBean, GamePlayerStatsBean> statsByPlayer) {
Map<GameOutcome, Long> outcomeCounts = statsByPlayer.values()
.stream()
.map(GamePlayerStatsBean::getResult)
.filter(Objects::nonNull)
.map(gameOutcome -> (gameOutcome == GameOutcome.CONFLICTING) ? GameOutcome.UNKNOWN : gameOutcome)
.map(gameOutcome -> (gameOutcome == GameOutcome.MUTUAL_DRAW) ? GameOutcome.DRAW : gameOutcome)
.collect(Collectors.groupingBy(gameOutcome -> gameOutcome, Collectors.counting()));

if (outcomeCounts.containsKey(GameOutcome.VICTORY)) {
return GameOutcome.VICTORY;
}
// Game outcomes are saved since 2020, so this should suffice for the
// vast majority of replays that people will realistically look up.
Map<GameOutcome, Long> outcomeCounts = statsByPlayer.values()
.stream()
.map(GamePlayerStatsBean::getResult)
.filter(Objects::nonNull)
.map(gameOutcome -> (gameOutcome == GameOutcome.CONFLICTING) ? GameOutcome.UNKNOWN : gameOutcome)
.map(gameOutcome -> (gameOutcome == GameOutcome.MUTUAL_DRAW) ? GameOutcome.DRAW : gameOutcome)
.collect(Collectors.groupingBy(gameOutcome -> gameOutcome, Collectors.counting()));

if (outcomeCounts.containsKey(GameOutcome.VICTORY)) {
return GameOutcome.VICTORY;
}

return outcomeCounts.entrySet()
.stream()
.max(Entry.comparingByValue()).map(Entry::getKey).orElse(GameOutcome.UNKNOWN);
return outcomeCounts.entrySet()
.stream()
.max(Entry.comparingByValue()).map(Entry::getKey).orElse(GameOutcome.UNKNOWN);

Check warning on line 490 in src/main/java/com/faforever/client/replay/ReplayDetailController.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/com/faforever/client/replay/ReplayDetailController.java#L488-L490

Added lines #L488 - L490 were not covered by tests
}

private Faction getPlayerFaction(PlayerBean player, Map<PlayerBean, GamePlayerStatsBean> statsByPlayerId) {
Expand Down

0 comments on commit 9ef6f6b

Please sign in to comment.