SteamWar/BungeeCore
Archiviert
13
2

Add SchemElo
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Add UserElo
Remove Elo.java
Dieser Commit ist enthalten in:
yoyosource 2022-03-10 18:52:21 +01:00
Ursprung 1363ecced8
Commit 621cb64fb3
3 geänderte Dateien mit 109 neuen und 52 gelöschten Zeilen

Datei anzeigen

@ -1,52 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.sql;
public class Elo {
private static final Statement elo = new Statement("SELECT Elo FROM Elo WHERE UserID = ? AND GameMode = ? AND Season = ?");
private static final Statement place = new Statement("SELECT COUNT(*) AS Place FROM Elo WHERE GameMode = ? AND Elo > ? AND Season = ?");
private Elo(){}
public static int getElo(int userID, String gameMode){
return getElo(Season.getSeason(), userID, gameMode);
}
public static int getElo(int season, int userID, String gameMode){
return elo.select(rs -> {
if(rs.next())
return rs.getInt("Elo");
return 1000;
}, userID, gameMode, season);
}
public static int getPlacement(int elo, String gameMode){
return getPlacement(Season.getSeason(), elo, gameMode);
}
public static int getPlacement(int season, int elo, String gameMode){
return place.select(rs -> {
if(rs.next())
return rs.getInt("Place");
return -1;
}, gameMode, elo, season);
}
}

Datei anzeigen

@ -0,0 +1,48 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.sql;
public class SchemElo {
private SchemElo() {}
private static final Statement elo = new Statement("SELECT SchemElo FROM Elo WHERE SchemID = ? AND Season = ?");
private static final Statement setElo = new Statement("UPDATE SchemElo SET Elo = ? WHERE Season = ? AND SchemID = ?");
// private static final Statement place = new Statement("SELECT COUNT(*) AS Place FROM SchemElo WHERE Elo > ? AND Season = ?");
public static int getElo(int schemID) {
return getElo(Season.getSeason(), schemID);
}
public static int getElo(int season, int schemID) {
return elo.select(rs -> {
if (rs.next())
return rs.getInt("Elo");
return 1000;
}, schemID, season);
}
public static void setElo(int schemID, int elo) {
setElo(Season.getSeason(), schemID, elo);
}
public static void setElo(int season, int schemID, int elo) {
setElo.update(elo, season, schemID);
}
}

Datei anzeigen

@ -0,0 +1,61 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.sql;
public class UserElo {
private UserElo() {
}
private static final Statement elo = new Statement("SELECT UserElo FROM Elo WHERE UserID = ? AND GameMode = ? AND Season = ?");
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 = ?");
public static int getElo(int userID, String gameMode) {
return getElo(Season.getSeason(), userID, gameMode);
}
public static int getElo(int season, int userID, String gameMode) {
return elo.select(rs -> {
if (rs.next())
return rs.getInt("Elo");
return 1000;
}, userID, gameMode, season);
}
public static void setElo(int userId, String gameMode, int elo) {
setElo(Season.getSeason(), userId, gameMode, elo);
}
public static void setElo(int season, int userId, String gameMode, int elo) {
setElo.update(elo, season, userId, gameMode);
}
public static int getPlacement(int elo, String gameMode) {
return getPlacement(Season.getSeason(), elo, gameMode);
}
public static int getPlacement(int season, int elo, String gameMode) {
return place.select(rs -> {
if (rs.next())
return rs.getInt("Place");
return -1;
}, gameMode, elo, season);
}
}