SteamWar/BungeeCore
Archiviert
13
2

Update FightEndsHandler
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-03-11 20:13:58 +01:00
Ursprung 2bd15d5c4f
Commit e015641086

Datei anzeigen

@ -69,22 +69,16 @@ public class FightEndsHandler implements SpigotHandler {
int blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
double blueWinExpectation = 1 / (1 + Math.pow(10, (redSchemElo - blueSchemElo) / 600f));
double redWinExpectation = 1 / (1 + Math.pow(10, (blueSchemElo - redSchemElo) / 600f));
SchemElo.setElo(fightEndsPacket.getBlueSchem(), (int) Math.round(blueSchemElo + K * (blueResult - blueWinExpectation)));
SchemElo.setElo(fightEndsPacket.getRedSchem(), (int) Math.round(redSchemElo + K * (1 - blueResult - redWinExpectation)));
if (!bluePublic) {
calculateEloOfTeam(fightEndsPacket.getBluePlayers(), fightEndsPacket.getGameMode(), blueResult - blueWinExpectation);
calculateEloOfTeam(fightEndsPacket.getRedPlayers(), fightEndsPacket.getGameMode(), 1 - blueResult - blueWinExpectation);
}
calculateEloOfTeam(fightEndsPacket.getBlueSchem(), blueSchemElo, redSchemElo, blueResult, fightEndsPacket.getBluePlayers(), fightEndsPacket.getGameMode());
calculateEloOfTeam(fightEndsPacket.getRedSchem(), redSchemElo, blueSchemElo, 1 - blueResult, fightEndsPacket.getRedPlayers(), fightEndsPacket.getGameMode());
}
private void calculateEloOfTeam(List<Integer> team, String gameMode, double factor) {
for (int player : team) {
private void calculateEloOfTeam(int schemId, int elo1, int elo2, double result, List<Integer> players, String gameMode) {
double winExpectation = 1 / (1 + Math.pow(10, (elo1 - elo2) / 600f));
SchemElo.setElo(schemId, (int) Math.round(elo1 + K * (result - winExpectation)));
for (int player : players) {
int playerElo = UserElo.getEloOrDefault(player, gameMode);
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * factor));
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * (result - winExpectation)));
}
}
}