Search in sources :

Example 1 with Rating

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);
}
Also used : Rating(com.faforever.client.util.Rating) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 2 with Rating

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);
}
Also used : Rating(com.faforever.client.util.Rating) Test(org.junit.Test) AbstractPlainJavaFxTest(com.faforever.client.test.AbstractPlainJavaFxTest)

Example 3 with Rating

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());
    }));
}
Also used : Button(javafx.scene.control.Button) UiService(com.faforever.client.theme.UiService) Rating(com.faforever.client.util.Rating) TimeService(com.faforever.client.util.TimeService) ScrollPane(javafx.scene.control.ScrollPane) Duration(java.time.Duration) Map(java.util.Map) TableView(javafx.scene.control.TableView) PlayerService(com.faforever.client.player.PlayerService) Pane(javafx.scene.layout.Pane) ClientProperties(com.faforever.client.config.ClientProperties) TextField(javafx.scene.control.TextField) Collection(java.util.Collection) ObservableMap(javafx.collections.ObservableMap) MapBean(com.faforever.client.map.MapBean) Collectors(java.util.stream.Collectors) Bytes(com.faforever.commons.io.Bytes) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) Optional(java.util.Optional) ClipboardContent(javafx.scene.input.ClipboardContent) Temporal(java.time.temporal.Temporal) Setter(lombok.Setter) PreviewSize(com.faforever.client.map.MapServiceImpl.PreviewSize) MouseEvent(javafx.scene.input.MouseEvent) GameOption(com.faforever.client.replay.Replay.GameOption) Function(java.util.function.Function) Scope(org.springframework.context.annotation.Scope) ChatMessage(com.faforever.client.replay.Replay.ChatMessage) TableColumn(javafx.scene.control.TableColumn) ArrayList(java.util.ArrayList) TeamCardController(com.faforever.client.game.TeamCardController) ReviewsController(com.faforever.client.vault.review.ReviewsController) StringCell(com.faforever.client.fx.StringCell) RatingUtil(com.faforever.client.util.RatingUtil) Label(javafx.scene.control.Label) Controller(com.faforever.client.fx.Controller) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Node(javafx.scene.Node) RatingType(com.faforever.client.game.RatingType) Component(org.springframework.stereotype.Component) PlayerStats(com.faforever.client.replay.Replay.PlayerStats) ImageView(javafx.scene.image.ImageView) ReviewService(com.faforever.client.vault.review.ReviewService) RatingService(com.faforever.client.rating.RatingService) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) Validity(com.faforever.client.api.dto.Validity) Image(javafx.scene.image.Image) Review(com.faforever.client.vault.review.Review) Assert(org.springframework.util.Assert) Rating(com.faforever.client.util.Rating) List(java.util.List) ArrayList(java.util.ArrayList) PlayerStats(com.faforever.client.replay.Replay.PlayerStats) TeamCardController(com.faforever.client.game.TeamCardController)

Example 4 with Rating

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());
    }
}
Also used : Player(com.faforever.client.player.Player) Rating(com.faforever.client.util.Rating) HashMap(java.util.HashMap) ObservableMap(javafx.collections.ObservableMap) Map(java.util.Map)

Aggregations

Rating (com.faforever.client.util.Rating)4 Player (com.faforever.client.player.Player)2 AbstractPlainJavaFxTest (com.faforever.client.test.AbstractPlainJavaFxTest)2 Map (java.util.Map)2 ObservableMap (javafx.collections.ObservableMap)2 Validity (com.faforever.client.api.dto.Validity)1 ClientProperties (com.faforever.client.config.ClientProperties)1 Controller (com.faforever.client.fx.Controller)1 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)1 StringCell (com.faforever.client.fx.StringCell)1 RatingType (com.faforever.client.game.RatingType)1 TeamCardController (com.faforever.client.game.TeamCardController)1 I18n (com.faforever.client.i18n.I18n)1 MapBean (com.faforever.client.map.MapBean)1 MapService (com.faforever.client.map.MapService)1 PreviewSize (com.faforever.client.map.MapServiceImpl.PreviewSize)1 PlayerService (com.faforever.client.player.PlayerService)1 RatingService (com.faforever.client.rating.RatingService)1 ChatMessage (com.faforever.client.replay.Replay.ChatMessage)1 GameOption (com.faforever.client.replay.Replay.GameOption)1