Search in sources :

Example 6 with GlobalRating

use of com.faforever.server.entity.GlobalRating in project faf-java-server by FAForever.

the class RatingService method initGlobalRating.

public void initGlobalRating(com.faforever.server.entity.Player player) {
    Assert.state(player.getGlobalRating() == null, "Global rating has already been set for player: " + player);
    player.setGlobalRating(new GlobalRating(player, gameInfo.getInitialMean(), gameInfo.getInitialStandardDeviation()));
}
Also used : GlobalRating(com.faforever.server.entity.GlobalRating)

Example 7 with GlobalRating

use of com.faforever.server.entity.GlobalRating in project faf-java-server by FAForever.

the class RatingService method updateRating.

private void updateRating(RatingType ratingType, GamePlayerStats stats) {
    Rating rating;
    switch(ratingType) {
        case GLOBAL:
            rating = ofNullable(stats.getPlayer().getGlobalRating()).orElseGet(() -> {
                GlobalRating initial = new GlobalRating();
                stats.getPlayer().setGlobalRating(initial);
                return initial;
            });
            break;
        case LADDER_1V1:
            rating = ofNullable(stats.getPlayer().getLadder1v1Rating()).orElseGet(() -> {
                Ladder1v1Rating initial = new Ladder1v1Rating();
                stats.getPlayer().setLadder1v1Rating(initial);
                return initial;
            });
            break;
        default:
            throw new ProgrammingError("Uncovered rating type: " + ratingType);
    }
    rating.setMean(stats.getAfterMean());
    rating.setDeviation(stats.getAfterDeviation());
    log.debug("New '{}' rating for player '{}' is: {}", ratingType, stats.getPlayer(), rating);
}
Also used : Rating(com.faforever.server.entity.Rating) Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating) GlobalRating(com.faforever.server.entity.GlobalRating) GlobalRating(com.faforever.server.entity.GlobalRating) Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating) ProgrammingError(com.faforever.server.error.ProgrammingError)

Example 8 with GlobalRating

use of com.faforever.server.entity.GlobalRating in project faf-java-server by FAForever.

the class GameServiceTest method setUp.

@Before
public void setUp() throws Exception {
    MapVersion map = new MapVersion();
    map.setRanked(true);
    player1 = new Player();
    player1.setId(1);
    player1.setLogin(PLAYER_NAME_1);
    player2 = new Player();
    player2.setId(2);
    player2.setLogin(PLAYER_NAME_2);
    FeaturedMod fafFeaturedMod = new FeaturedMod();
    fafFeaturedMod.setTechnicalName(FAF_TECHNICAL_NAME);
    when(gameRepository.findMaxId()).thenReturn(Optional.empty());
    when(mapService.findMap(anyString())).thenReturn(Optional.empty());
    when(mapService.findMap(MAP_NAME)).thenReturn(Optional.of(map));
    when(modService.getFeaturedMod(FAF_TECHNICAL_NAME)).thenReturn(Optional.of(fafFeaturedMod));
    when(playerService.getOnlinePlayer(anyInt())).thenReturn(Optional.empty());
    doAnswer(invocation -> invocation.getArgumentAt(0, Player.class).setGlobalRating(new GlobalRating())).when(ratingService).initGlobalRating(any());
    serverProperties = new ServerProperties();
    serverProperties.getGame().setRankedMinTimeMultiplicator(-10000);
    instance = new GameService(gameRepository, counterService, clientService, mapService, modService, playerService, ratingService, serverProperties, divisionService, entityManager, armyStatisticsService);
    instance.onApplicationEvent(null);
}
Also used : Player(com.faforever.server.entity.Player) ServerProperties(com.faforever.server.config.ServerProperties) GlobalRating(com.faforever.server.entity.GlobalRating) MapVersion(com.faforever.server.entity.MapVersion) FeaturedMod(com.faforever.server.entity.FeaturedMod) Before(org.junit.Before)

Aggregations

GlobalRating (com.faforever.server.entity.GlobalRating)8 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)4 Test (org.junit.Test)3 AvatarAssociation (com.faforever.server.entity.AvatarAssociation)2 Player (com.faforever.server.entity.Player)2 Rating (com.faforever.server.entity.Rating)2 PlayerResponse (com.faforever.server.player.PlayerResponse)2 ServerProperties (com.faforever.server.config.ServerProperties)1 Avatar (com.faforever.server.entity.Avatar)1 Clan (com.faforever.server.entity.Clan)1 ClanMembership (com.faforever.server.entity.ClanMembership)1 FeaturedMod (com.faforever.server.entity.FeaturedMod)1 Game (com.faforever.server.entity.Game)1 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)1 MapVersion (com.faforever.server.entity.MapVersion)1 ProgrammingError (com.faforever.server.error.ProgrammingError)1 Rating (com.faforever.server.player.PlayerResponse.Player.Rating)1 Before (org.junit.Before)1