Search in sources :

Example 6 with Ladder1v1Rating

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

the class RatingService method initLadder1v1Rating.

public void initLadder1v1Rating(com.faforever.server.entity.Player player) {
    Assert.state(player.getLadder1v1Rating() == null, "Ladder1v1 rating has already been set for player: " + player);
    player.setLadder1v1Rating(new Ladder1v1Rating(player, gameInfo.getInitialMean(), gameInfo.getInitialStandardDeviation()));
}
Also used : Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating)

Example 7 with Ladder1v1Rating

use of com.faforever.server.entity.Ladder1v1Rating 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)

Aggregations

Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)7 GlobalRating (com.faforever.server.entity.GlobalRating)3 Player (com.faforever.server.entity.Player)3 Test (org.junit.Test)3 Game (com.faforever.server.entity.Game)2 ClientService (com.faforever.server.client.ClientService)1 ConnectionAware (com.faforever.server.client.ConnectionAware)1 ServerProperties (com.faforever.server.config.ServerProperties)1 Avatar (com.faforever.server.entity.Avatar)1 AvatarAssociation (com.faforever.server.entity.AvatarAssociation)1 Clan (com.faforever.server.entity.Clan)1 ClanMembership (com.faforever.server.entity.ClanMembership)1 FeaturedMod (com.faforever.server.entity.FeaturedMod)1 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)1 MapVersion (com.faforever.server.entity.MapVersion)1 Rating (com.faforever.server.entity.Rating)1 ErrorCode (com.faforever.server.error.ErrorCode)1 ProgrammingError (com.faforever.server.error.ProgrammingError)1 RequestException (com.faforever.server.error.RequestException)1 Requests (com.faforever.server.error.Requests)1