Search in sources :

Example 6 with Player

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

the class MatchMakerServiceTest method cancelSearch.

@Test
public void cancelSearch() throws Exception {
    Player player1 = (Player) new Player().setLogin(LOGIN_PLAYER_1).setId(1);
    Player player2 = (Player) new Player().setLogin(LOGIN_PLAYER_2).setId(2);
    instance.submitSearch(player1, Faction.CYBRAN, QUEUE_NAME);
    instance.submitSearch(player2, Faction.AEON, QUEUE_NAME);
    assertThat(instance.getSearchPools().get(QUEUE_NAME).keySet(), hasSize(2));
    instance.cancelSearch(QUEUE_NAME, player1);
    assertThat(instance.getSearchPools().get(QUEUE_NAME).keySet(), hasSize(1));
    instance.cancelSearch(QUEUE_NAME, player1);
    assertThat(instance.getSearchPools().get(QUEUE_NAME).keySet(), hasSize(1));
    instance.cancelSearch(QUEUE_NAME, player2);
    assertThat(instance.getSearchPools().get(QUEUE_NAME).keySet(), hasSize(0));
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 7 with Player

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

the class RatingServiceTest method initGlobalRating.

@Test
public void initGlobalRating() throws Exception {
    Player player = new Player();
    assertThat(player.getGlobalRating(), is(nullValue()));
    instance.initGlobalRating(player);
    assertThat(player.getGlobalRating(), is(notNullValue()));
    assertThat(player.getGlobalRating().getMean(), is(Matchers.greaterThan(0d)));
    assertThat(player.getGlobalRating().getDeviation(), is(Matchers.greaterThan(0d)));
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 8 with Player

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

the class RatingServiceTest method updateLadder1v1Ratings.

@Test
public void updateLadder1v1Ratings() throws Exception {
    Player player1 = (Player) new Player().setLadder1v1Rating((Ladder1v1Rating) new Ladder1v1Rating().setMean(1500d).setDeviation(500d)).setId(1);
    Player player2 = (Player) new Player().setLadder1v1Rating((Ladder1v1Rating) new Ladder1v1Rating().setMean(1500d).setDeviation(500d)).setId(2);
    List<GamePlayerStats> playerStats = Arrays.asList(new GamePlayerStats().setPlayer(player1).setTeam(NO_TEAM_ID).setMean(player1.getLadder1v1Rating().getMean()).setDeviation(player1.getLadder1v1Rating().getDeviation()).setScore(10), new GamePlayerStats().setPlayer(player2).setTeam(NO_TEAM_ID).setMean(player2.getLadder1v1Rating().getMean()).setDeviation(player2.getLadder1v1Rating().getDeviation()).setScore(-1));
    instance.updateRatings(playerStats, NO_TEAM_ID, RatingType.LADDER_1V1);
    assertThat(player1.getLadder1v1Rating().getMean(), is(1765.511882354831));
    assertThat(player1.getLadder1v1Rating().getDeviation(), is(429.1918779825801));
    assertThat(player2.getLadder1v1Rating().getMean(), is(1234.4881176451688));
    assertThat(player2.getLadder1v1Rating().getDeviation(), is(429.1918779825801));
    assertThat(player1.getGlobalRating(), is(nullValue()));
    assertThat(player2.getGlobalRating(), is(nullValue()));
}
Also used : Player(com.faforever.server.entity.Player) GamePlayerStats(com.faforever.server.entity.GamePlayerStats) Ladder1v1Rating(com.faforever.server.entity.Ladder1v1Rating) Test(org.junit.Test)

Example 9 with Player

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

the class RatingServiceTest method initLadder1v1Rating.

@Test
public void initLadder1v1Rating() throws Exception {
    Player player = new Player();
    assertThat(player.getLadder1v1Rating(), is(nullValue()));
    instance.initLadder1v1Rating(player);
    assertThat(player.getLadder1v1Rating(), is(notNullValue()));
    assertThat(player.getLadder1v1Rating().getMean(), is(Matchers.greaterThan(0d)));
    assertThat(player.getLadder1v1Rating().getDeviation(), is(Matchers.greaterThan(0d)));
}
Also used : Player(com.faforever.server.entity.Player) Test(org.junit.Test)

Example 10 with Player

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

the class RatingServiceTest method updateGlobalRatings.

@Test
public void updateGlobalRatings() throws Exception {
    Player player1 = (Player) new Player().setGlobalRating((GlobalRating) new GlobalRating().setMean(1500d).setDeviation(500d)).setId(1);
    Player player2 = (Player) new Player().setGlobalRating((GlobalRating) new GlobalRating().setMean(1500d).setDeviation(500d)).setId(2);
    List<GamePlayerStats> playerStats = Arrays.asList(new GamePlayerStats().setPlayer(player1).setTeam(NO_TEAM_ID).setMean(player1.getGlobalRating().getMean()).setDeviation(player1.getGlobalRating().getDeviation()).setScore(10), new GamePlayerStats().setPlayer(player2).setTeam(NO_TEAM_ID).setMean(player2.getGlobalRating().getMean()).setDeviation(player2.getGlobalRating().getDeviation()).setScore(-1));
    instance.updateRatings(playerStats, NO_TEAM_ID, RatingType.GLOBAL);
    assertThat(player1.getGlobalRating().getMean(), is(1765.511882354831));
    assertThat(player1.getGlobalRating().getDeviation(), is(429.1918779825801));
    assertThat(player2.getGlobalRating().getMean(), is(1234.4881176451688));
    assertThat(player2.getGlobalRating().getDeviation(), is(429.1918779825801));
    assertThat(player1.getLadder1v1Rating(), is(nullValue()));
    assertThat(player2.getLadder1v1Rating(), is(nullValue()));
}
Also used : Player(com.faforever.server.entity.Player) GamePlayerStats(com.faforever.server.entity.GamePlayerStats) GlobalRating(com.faforever.server.entity.GlobalRating) Test(org.junit.Test)

Aggregations

Player (com.faforever.server.entity.Player)73 Test (org.junit.Test)38 Game (com.faforever.server.entity.Game)25 Before (org.junit.Before)13 ServerProperties (com.faforever.server.config.ServerProperties)11 GamePlayerStats (com.faforever.server.entity.GamePlayerStats)11 PlayerOnlineEvent (com.faforever.server.player.PlayerOnlineEvent)11 List (java.util.List)11 Slf4j (lombok.extern.slf4j.Slf4j)11 Service (org.springframework.stereotype.Service)11 ClientService (com.faforever.server.client.ClientService)10 ConnectionAware (com.faforever.server.client.ConnectionAware)10 FeaturedMod (com.faforever.server.entity.FeaturedMod)10 Ladder1v1Rating (com.faforever.server.entity.Ladder1v1Rating)10 Optional (java.util.Optional)10 GlobalRating (com.faforever.server.entity.GlobalRating)9 ModService (com.faforever.server.mod.ModService)9 VisibleForTesting (com.google.common.annotations.VisibleForTesting)9 Duration (java.time.Duration)9 Map (java.util.Map)9