SteamWar/BungeeCore
Archiviert
13
2

Update FightEndsHandler
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Update UserElo
Dieser Commit ist enthalten in:
yoyosource 2022-03-11 16:45:00 +01:00
Ursprung 2923d249db
Commit 0d7ebc224c
2 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -85,7 +85,7 @@ public class FightEndsHandler implements SpigotHandler {
private void calculateEloOfTeam(List<Integer> team, String gameMode, double factor) {
for (int player : team) {
int playerElo = UserElo.getElo(player, gameMode).orElse(ELO_DEFAULT);
int playerElo = UserElo.getEloOrDefault(player, gameMode);
UserElo.setElo(player, gameMode, (int) Math.round(playerElo + K * factor));
}
}

Datei anzeigen

@ -41,6 +41,10 @@ public class UserElo {
private static final Statement maxElo = new Statement("SELECT MAX(Elo) AS MaxElo FROM UserElo WHERE Season = ? AND GameMode = ?");
private static final Statement fightsOfSeason = new Statement("SELECT COUNT(*) AS Fights FROM FightPlayer INNER JOIN Fight F on FightPlayer.FightID = F.FightID WHERE UserID = ? AND GameMode = ? AND UNIX_TIMESTAMP(StartTime) + Duration >= UNIX_TIMESTAMP(?)");
public static int getEloOrDefault(int userID, String gameMode) {
return getElo(userID, gameMode).orElse(ELO_DEFAULT);
}
public static Optional<Integer> getElo(int userID, String gameMode) {
return gameModeUserEloCache.computeIfAbsent(gameMode, gm -> {
return new HashMap<>();