Implementation of ELO-Based 1 vs 1 ranked games #172
@ -211,19 +211,15 @@ public class FightSystem extends JavaPlugin {
|
|||||||
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
Bukkit.broadcastMessage(PREFIX + "§aKein Team hat gewonnen!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.event()){
|
if(Config.event()) {
|
||||||
if(winFightTeam == null)
|
if (winFightTeam == null)
|
||||||
getEventFight().setErgebnis(0);
|
getEventFight().setErgebnis(0);
|
||||||
else if(winFightTeam.isBlue())
|
else if (winFightTeam.isBlue())
|
||||||
getEventFight().setErgebnis(1);
|
getEventFight().setErgebnis(1);
|
||||||
else
|
else
|
||||||
getEventFight().setErgebnis(2);
|
getEventFight().setErgebnis(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.Ranked){
|
|
||||||
//TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!Config.test()){
|
if(!Config.test()){
|
||||||
new SpectateOverCountdown();
|
new SpectateOverCountdown();
|
||||||
FightStatistics.saveStats(winFightTeam, windescription);
|
FightStatistics.saveStats(winFightTeam, windescription);
|
||||||
|
@ -5,6 +5,7 @@ import de.steamwar.fightsystem.FightSystem;
|
|||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
|
import de.steamwar.sql.Elo;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
@ -17,26 +18,43 @@ public class FightStatistics {
|
|||||||
private FightStatistics(){}
|
private FightStatistics(){}
|
||||||
|
|
||||||
private static Timestamp starttime = Timestamp.from(Instant.now());
|
private static Timestamp starttime = Timestamp.from(Instant.now());
|
||||||
|
private static int K = 20;
|
||||||
|
|
||||||
public static void start(){
|
public static void start(){
|
||||||
starttime = Timestamp.from(Instant.now());
|
starttime = Timestamp.from(Instant.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveStats(FightTeam winner, String windescription){
|
public static void saveStats(FightTeam winner, String windescription){
|
||||||
|
String gameMode = Config.SchematicType.toDB();
|
||||||
SteamwarUser blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId());
|
SteamwarUser blueLeader = SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId());
|
||||||
SteamwarUser redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId());
|
SteamwarUser redLeader = SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId());
|
||||||
int win = 0;
|
int win = 0;
|
||||||
if(winner == Fight.getBlueTeam())
|
double blueResult;
|
||||||
|
if(winner == Fight.getBlueTeam()) {
|
||||||
win = 1;
|
win = 1;
|
||||||
else if(winner == Fight.getRedTeam())
|
blueResult = 1;
|
||||||
|
}else if(winner == Fight.getRedTeam()) {
|
||||||
win = 2;
|
win = 2;
|
||||||
int fightId = create(Config.SchematicType.toDB(), Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
|
blueResult = 0;
|
||||||
|
}else{
|
||||||
|
blueResult = 0.5;
|
||||||
|
}
|
||||||
|
int fightId = create(gameMode, Bukkit.getWorlds().get(0).getName(), starttime, Config.TimeoutTime - FightSystem.getFightTime(),
|
||||||
blueLeader.getId(), redLeader.getId(), Fight.getBlueTeam().getSchematic().getSchemID(), Fight.getRedTeam().getSchematic().getSchemID(), win, windescription);
|
blueLeader.getId(), redLeader.getId(), Fight.getBlueTeam().getSchematic().getSchemID(), Fight.getRedTeam().getSchematic().getSchemID(), win, windescription);
|
||||||
|
|
||||||
for(FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
for(FightPlayer fp : Fight.getBlueTeam().getPlayers())
|
||||||
savePlayerStats(fp, fightId);
|
savePlayerStats(fp, fightId);
|
||||||
for(FightPlayer fp : Fight.getRedTeam().getPlayers())
|
for(FightPlayer fp : Fight.getRedTeam().getPlayers())
|
||||||
savePlayerStats(fp, fightId);
|
savePlayerStats(fp, fightId);
|
||||||
|
|
||||||
|
if(Config.Ranked && !Config.event()){
|
||||||
|
int blueElo = Elo.getElo(blueLeader.getId(), gameMode);
|
||||||
|
int redElo = Elo.getElo(redLeader.getId(), gameMode);
|
||||||
|
double blueWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
|
||||||
|
double redWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
|
||||||
|
Elo.setElo(blueLeader.getId(), gameMode, (int) Math.round(blueElo + K * (blueResult - blueWinExpectation)));
|
||||||
|
Elo.setElo(redLeader.getId(), gameMode, (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void savePlayerStats(FightPlayer fp, int fightId){
|
private static void savePlayerStats(FightPlayer fp, int fightId){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren