SteamWar/BungeeCore
Archiviert
13
2

Ranked #306

Zusammengeführt
Lixfel hat 25 Commits von Ranked nach master 2022-03-13 20:26:16 +01:00 zusammengeführt
2 geänderte Dateien mit 14 neuen und 1 gelöschten Zeilen
Nur Änderungen aus Commit e26692fdd2 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -30,6 +30,11 @@ public class Season {
return (calendar.get(Calendar.YEAR) * 3 + yearIndex);
}
public static String getSeasonStart() {
Calendar calendar = Calendar.getInstance();
return calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) / 3 * 3 + 1) + "-1";
YoyoNow markierte diese Unterhaltung als gelöst
Review

Das 2022-1-1 Formatting frisst die DB?

Das 2022-1-1 Formatting frisst die DB?
Review

Scheint so.

Scheint so.
}
public static String convertSeasonToString(int season){
if (season == -1) return "";
int yearSeason = season % 3;

Datei anzeigen

@ -45,6 +45,7 @@ public class UserElo {
private static final Statement setElo = new Statement("UPDATE UserELo SET Elo = ? WHERE Season = ? AND UserID = ? AND GameMode = ?");
private static final Statement place = new Statement("SELECT COUNT(*) AS Place FROM UserElo WHERE GameMode = ? AND Elo > ? AND Season = ?");
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(?)");
private static void clearCacheIfNeeded(int season) {
int currentSeason = Season.getSeason();
@ -55,7 +56,6 @@ public class UserElo {
clearCache();
cachedSeason = currentSeason;
}
return;
}
public static Optional<Integer> getElo(int userID, String gameMode) {
@ -81,6 +81,14 @@ public class UserElo {
}, userID, gameMode, season);
}
public static int getFightsOfSeason(int userID, String gameMode) {
return fightsOfSeason.select(rs -> {
if (rs.next())
return rs.getInt("Fights");
return 0;
}, userID, gameMode, Season.getSeasonStart());
}
public static int getMaxElo(String gameMode) {
return getMaxElo(Season.getSeason(), gameMode);
}