SteamWar/BungeeCore
Archiviert
13
2

Add UserElo.getFightsOfSeason
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Add Season.getSeasonStart
Dieser Commit ist enthalten in:
yoyosource 2022-03-11 11:12:30 +01:00
Ursprung 3ee878f26e
Commit e26692fdd2
2 geänderte Dateien mit 14 neuen und 1 gelöschten Zeilen

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";
}
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);
}