SteamWar/FightSystem
Archiviert
13
1

Implementation of ELO-Based 1 vs 1 ranked games #172

Manuell gemergt
Lixfel hat 4 Commits von firstRanked nach master 2020-07-11 07:17:45 +02:00 zusammengeführt
2 geänderte Dateien mit 9 neuen und 6 gelöschten Zeilen
Nur Änderungen aus Commit b5bcea06b7 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -187,10 +187,6 @@ public class FightTeam implements IFightTeam{
} }
public void setLeader(FightPlayer leader) { public void setLeader(FightPlayer leader) {
this.leader = leader;
if(ready && leader != null)
setReady(false);
if (leader == null){ if (leader == null){
if(!players.isEmpty()) { if(!players.isEmpty()) {
setLeader(players.iterator().next()); setLeader(players.iterator().next());
@ -202,6 +198,9 @@ public class FightTeam implements IFightTeam{
} }
return; return;
} }
this.leader = leader;
if(ready)
setReady(false);
leader.setKit(KitManager.getKitByName(Config.LeaderDefault)); leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
Inventory inventory = leader.getPlayer().getInventory(); Inventory inventory = leader.getPlayer().getInventory();

Datei anzeigen

@ -52,8 +52,12 @@ public class FightStatistics {
int redElo = Elo.getElo(redLeader.getId(), gameMode); int redElo = Elo.getElo(redLeader.getId(), gameMode);
double blueWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f)); double blueWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
double redWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f)); double redWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
Elo.setElo(blueLeader.getId(), gameMode, (int) Math.round(blueElo + K * (blueResult - blueWinExpectation))); int newBlueElo = (int) Math.round(blueElo + K * (blueResult - blueWinExpectation));
Elo.setElo(redLeader.getId(), gameMode, (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation))); int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
Elo.setElo(blueLeader.getId(), gameMode, newBlueElo);
Elo.setElo(redLeader.getId(), gameMode, newRedElo);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getBlueTeam().getPrefix() + blueLeader.getUserName() + "§8: §7" + blueElo + "§8»§e" + newBlueElo);
Bukkit.broadcastMessage(FightSystem.PREFIX + "§7ELO von " + Fight.getRedTeam().getPrefix() + redLeader.getUserName() + "§8: §7" + redElo + "§8»§e" + newRedElo);
} }
} }