Archiviert
1
0

Update FightEndsHandler

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 blueSchemElo = SchemElo.getElo(fightEndsPacket.getBlueSchem());
int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem()); int redSchemElo = SchemElo.getElo(fightEndsPacket.getRedSchem());
double blueWinExpectation = 1 / (1 + Math.pow(10, (redSchemElo - blueSchemElo) / 600f)); calculateEloOfTeam(fightEndsPacket.getBlueSchem(), blueSchemElo, redSchemElo, blueResult, fightEndsPacket.getBluePlayers(), fightEndsPacket.getGameMode());
double redWinExpectation = 1 / (1 + Math.pow(10, (blueSchemElo - redSchemElo) / 600f)); calculateEloOfTeam(fightEndsPacket.getRedSchem(), redSchemElo, blueSchemElo, 1 - blueResult, fightEndsPacket.getRedPlayers(), fightEndsPacket.getGameMode());
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);
}
} }
private void calculateEloOfTeam(List<Integer> team, String gameMode, double factor) { private void calculateEloOfTeam(int schemId, int elo1, int elo2, double result, List<Integer> players, String gameMode) {
for (int player : team) { 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); 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)));
} }
} }
} }