SteamWar/BungeeCore
Archiviert
13
2

Fix Ranked calculation
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-03-16 20:02:16 +01:00
Ursprung 6489ae51cf
Commit 19de4fd1d8

Datei anzeigen

@ -69,16 +69,21 @@ public class FightEndsHandler implements SpigotHandler {
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
calculateEloOfTeam(fightEndsPacket.getBlueSchem(), blueSchemElo, redSchemElo, blueResult, fightEndsPacket.getBluePlayers(), fightEndsPacket.getGameMode());
calculateEloOfTeam(fightEndsPacket.getRedSchem(), redSchemElo, blueSchemElo, 1 - blueResult, fightEndsPacket.getRedPlayers(), fightEndsPacket.getGameMode());
int blueTeamElo = fightEndsPacket.getBluePlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
int redTeamElo = fightEndsPacket.getRedPlayers().stream().mapToInt(player -> UserElo.getEloOrDefault(player, fightEndsPacket.getGameMode())).sum();
calculateEloOfTeam(fightEndsPacket.getBlueSchem(), blueSchemElo, redSchemElo, blueTeamElo, redTeamElo, blueResult, fightEndsPacket.getBluePlayers(), fightEndsPacket.getGameMode());
calculateEloOfTeam(fightEndsPacket.getRedSchem(), redSchemElo, blueSchemElo, redTeamElo, blueTeamElo, 1 - blueResult, fightEndsPacket.getRedPlayers(), fightEndsPacket.getGameMode());
}
private void calculateEloOfTeam(int schemId, int eloOwn, int eloEnemy, double result, List<Integer> players, String gameMode) {
double winExpectation = 1 / (1 + Math.pow(10, (eloEnemy - eloOwn) / 600f));
SchemElo.setElo(schemId, (int) Math.round(eloOwn + K * (result - winExpectation)));
private void calculateEloOfTeam(int schemId, int eloSchemOwn, int eloSchemEnemy, int eloTeamOwn, int eloTeamEnemy, double result, List<Integer> players, String gameMode) {
double winSchemExpectation = 1 / (1 + Math.pow(10, (eloSchemEnemy - eloSchemOwn) / 600f));
SchemElo.setElo(schemId, (int) Math.round(eloSchemOwn + K * (result - winSchemExpectation)));
double winTeamExpectation = 1 / (1 + Math.pow(10, (eloTeamEnemy - eloTeamOwn) / 600f));
for (int player : players) {
int playerElo = UserElo.getEloOrDefault(player, gameMode);
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * (result - winExpectation)));
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * (result - winTeamExpectation)));
}
}
}