use of com.faforever.client.util.Rating in project downlords-faf-client by FAForever.
the class TeamCardControllerTest method setPlayersInTeam.
@Test
public void setPlayersInTeam() throws Exception {
instance.setPlayersInTeam("2", playerList, player -> new Rating(1000, 0), RatingType.ROUNDED);
verify(i18n).get("game.tooltip.teamTitle", 1, 1000);
}
use of com.faforever.client.util.Rating in project downlords-faf-client by FAForever.
the class TeamCardControllerTest method showRatingChange.
@Test
public void showRatingChange() throws Exception {
instance.setPlayersInTeam("2", playerList, player -> new Rating(1000, 0), RatingType.EXACT);
instance.showRatingChange(teams);
verify(ratingChangeLabelController).setRatingChange(playerStats);
}
use of com.faforever.client.util.Rating in project downlords-faf-client by FAForever.
the class ReplayDetailController method populateTeamsContainer.
private void populateTeamsContainer() {
if (!replay.getValidity().equals(Validity.VALID)) {
showRatingChangeButton.setDisable(true);
showRatingChangeButton.setText(i18n.get("game.notValid"));
} else if (!replayService.replayChangedRating(replay)) {
showRatingChangeButton.setDisable(true);
showRatingChangeButton.setText(i18n.get("game.notRatedYet"));
}
Map<Integer, PlayerStats> statsByPlayerId = teams.values().stream().flatMap(Collection::stream).collect(Collectors.toMap(PlayerStats::getPlayerId, Function.identity()));
Platform.runLater(() -> teams.forEach((team, value) -> {
List<Integer> playerIds = value.stream().map(PlayerStats::getPlayerId).collect(Collectors.toList());
TeamCardController controller = uiService.loadFxml("theme/team_card.fxml");
teamCardControllers.add(controller);
playerService.getPlayersByIds(playerIds).thenAccept(players -> controller.setPlayersInTeam(team, players, player -> {
PlayerStats playerStats = statsByPlayerId.get(player.getId());
return new Rating(playerStats.getBeforeMean(), playerStats.getBeforeDeviation());
}, RatingType.EXACT));
teamsContainer.getChildren().add(controller.getRoot());
}));
}
use of com.faforever.client.util.Rating in project downlords-faf-client by FAForever.
the class TeamCardController method createAndAdd.
/**
* Creates a new {@link TeamCardController} and adds its root to the specified {@code teamsPane}.
*
* @param teamsList a mapping of team name (e.g. "2") to a list of player names that are in that team
* @param playerService the service to use to look up players by name
*/
public static void createAndAdd(ObservableMap<? extends String, ? extends List<String>> teamsList, PlayerService playerService, UiService uiService, Pane teamsPane) {
for (Map.Entry<? extends String, ? extends List<String>> entry : teamsList.entrySet()) {
List<Player> players = entry.getValue().stream().map(playerService::getPlayerForUsername).collect(Collectors.toList());
TeamCardController teamCardController = uiService.loadFxml("theme/team_card.fxml");
teamCardController.setPlayersInTeam(entry.getKey(), players, player -> new Rating(player.getGlobalRatingMean(), player.getGlobalRatingDeviation()), RatingType.ROUNDED);
teamsPane.getChildren().add(teamCardController.getRoot());
}
}
Aggregations