SteamWar/SpigotCore
Archiviert
13
0

Update stuff
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-03-09 20:24:28 +01:00
Ursprung 74b219994b
Commit 42c95f0ee8
3 geänderte Dateien mit 4 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -39,26 +39,7 @@ public interface Provider {
List<CheckedSchematic> getLastDeclinedOfNode(int node);
List<CheckedSchematic> getLastDelined(int schemOwner);
int getCurrentSeason(); // returns -1 is in standalone mode
default String convertSeasonNumberToString(int season) {
if (season == -1) return "";
int yearSeason = season % 3;
int year = (season - yearSeason) / 3;
return String.format("%d-%d", year, yearSeason);
}
default int convertSeasonStringToNumber(String season) {
if (season.isEmpty()) return -1;
String[] split = season.split("-");
try {
return Integer.parseInt(split[0]) * 3 + Integer.parseInt(split[1]);
} catch (NumberFormatException e) {
return -1;
}
}
default int getElo(int userId, String gameMode) {
return getElo(getCurrentSeason(), userId, gameMode);
}
int getElo(int season, int userId, String gameMode);
int getElo(int userId, String gameMode);
void setElo(int userId, String gameMode, int elo);
Event getEvent(int eventID);

Datei anzeigen

@ -78,7 +78,6 @@ public class SQLProvider implements Provider {
return new CheckedSchematic(rs.getInt("NodeId"), rs.getInt("Validator"), rs.getTimestamp("StartTime"), rs.getTimestamp("EndTime"), rs.getString("DeclineReason"));
}
@Override
public int getCurrentSeason() {
Calendar calendar = Calendar.getInstance();
int yearIndex = calendar.get(Calendar.MONTH) / 3;
@ -87,12 +86,12 @@ public class SQLProvider implements Provider {
private static final Statement getElo = new Statement("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ? AND Season = ?");
@Override
public int getElo(int season, int userId, String gameMode) {
public int getElo(int userId, String gameMode) {
return getElo.select(rs -> {
if(rs.next())
return rs.getInt("Elo");
return 1000;
}, userId, gameMode, season);
}, userId, gameMode, getCurrentSeason());
}
private static final Statement setElo = new Statement("UPDATE Elo SET Elo = ? WHERE Season = ? AND UserID = ? AND GameMode = ?");

Datei anzeigen

@ -65,12 +65,7 @@ public class StandaloneProvider implements Provider {
}
@Override
public int getCurrentSeason() {
return -1;
}
@Override
public int getElo(int season, int userId, String gameMode) {
public int getElo(int userId, String gameMode) {
return 1000;
}