SteamWar/FightSystem
Archiviert
13
1

Add ranked rework #336

Zusammengeführt
Lixfel hat 6 Commits von Ranked nach master 2022-03-10 12:07:24 +01:00 zusammengeführt
7 geänderte Dateien mit 26 neuen und 144 gelöschten Zeilen

Datei anzeigen

@ -25,7 +25,6 @@ import java.util.Set;
public enum ArenaMode { public enum ArenaMode {
NORMAL, NORMAL,
RANKED,
EVENT, EVENT,
TEST, TEST,
CHECK, CHECK,
@ -38,7 +37,6 @@ public enum ArenaMode {
public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK)); public static final Set<ArenaMode> Check = Collections.unmodifiableSet(EnumSet.of(CHECK));
public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT)); public static final Set<ArenaMode> Event = Collections.unmodifiableSet(EnumSet.of(EVENT));
public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK)); public static final Set<ArenaMode> Test = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
public static final Set<ArenaMode> Ranked = Collections.unmodifiableSet(EnumSet.of(RANKED));
public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE)); public static final Set<ArenaMode> Prepare = Collections.unmodifiableSet(EnumSet.of(PREPARE));
public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST)); public static final Set<ArenaMode> Replay = Collections.unmodifiableSet(EnumSet.of(REPLAY, TEST));
@ -46,9 +44,9 @@ public enum ArenaMode {
public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK))); public static final Set<ArenaMode> AntiTest = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK)));
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT))); public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE))); public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(RANKED, EVENT, REPLAY))); public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(RANKED, EVENT, REPLAY)); public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, RANKED)); public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL));
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY)); public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE)); public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY))); public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));

Datei anzeigen

@ -92,7 +92,6 @@ public class Config {
public static final String TeamChatDetection; public static final String TeamChatDetection;
public static final UUID BlueLeader; public static final UUID BlueLeader;
public static final UUID RedLeader; public static final UUID RedLeader;
public static final boolean Ranked;
//Active win conditions //Active win conditions
public static final Set<Winconditions> ActiveWinconditions; public static final Set<Winconditions> ActiveWinconditions;
@ -370,12 +369,9 @@ public class Config {
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0")); CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0")); PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
Ranked = Boolean.parseBoolean(System.getProperty("ranked", "false"));
ReplayID = Integer.parseInt(System.getProperty("replay", "0")); ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
if(Ranked){ if(CheckSchemID != 0){
mode = ArenaMode.RANKED;
}else if(CheckSchemID != 0){
mode = ArenaMode.CHECK; mode = ArenaMode.CHECK;
}else if(PrepareSchemID != 0){ }else if(PrepareSchemID != 0){
mode = ArenaMode.PREPARE; mode = ArenaMode.PREPARE;

Datei anzeigen

@ -87,7 +87,6 @@ public class FightSystem extends JavaPlugin {
new PrepareSchem(); new PrepareSchem();
new TestJoin(); new TestJoin();
new NormalJoin(); new NormalJoin();
new RankedJoin();
new RunningWorldInteraction(); new RunningWorldInteraction();
new PersonalKitCreator(); new PersonalKitCreator();
new ArrowStopper(); new ArrowStopper();
@ -114,7 +113,6 @@ public class FightSystem extends JavaPlugin {
new WinconditionHeartRatioTimeout(); new WinconditionHeartRatioTimeout();
new WinconditionTimeTechKO(); new WinconditionTimeTechKO();
new EventTeamOffWincondition(); new EventTeamOffWincondition();
new RankedPlayerLeftWincondition();
new WinconditionPercentTimeout(); new WinconditionPercentTimeout();
new HellsBells(); new HellsBells();

Datei anzeigen

@ -180,7 +180,6 @@ UI_PLAYER_LEAVES=
UI_LEADER_JOINS=§a§l» {0}Leader {1} UI_LEADER_JOINS=§a§l» {0}Leader {1}
UI_PLAYER_DEATH={0}{1} §7ist gestorben UI_PLAYER_DEATH={0}{1} §7ist gestorben
UI_PLAYER_LEAVE={0}{1} §7hat den Kampf verlassen UI_PLAYER_LEAVE={0}{1} §7hat den Kampf verlassen
UI_ELO=§7ELO von {0}{1}§8: §7{2}§8»§e{3}
UI_WIN={0}Sieg {1} UI_WIN={0}Sieg {1}
UI_DRAW=§7Unentschieden UI_DRAW=§7Unentschieden
@ -232,7 +231,6 @@ WIN_FIGHTLEADER=
WIN_PERCENT={0} §7zu beschädigt WIN_PERCENT={0} §7zu beschädigt
WIN_OFFLINE_BOTH=§7Beide Teams offline WIN_OFFLINE_BOTH=§7Beide Teams offline
WIN_OFFLINE={0} §7offline WIN_OFFLINE={0} §7offline
WIN_RANKED_LEFT={0} §7hat den Kampf verlassen
WIN_ALL_DEAD={0}Alle Spieler kampfunfähig WIN_ALL_DEAD={0}Alle Spieler kampfunfähig
WIN_LEADER_DEAD={0} kampfunfähig WIN_LEADER_DEAD={0} kampfunfähig
WIN_TIME_OVER=§7Zeit abgelaufen WIN_TIME_OVER=§7Zeit abgelaufen

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.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class RankedJoin implements Listener {
public RankedJoin() {
new StateDependentListener(ArenaMode.Ranked, FightState.PreLeaderSetup, this);
}
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if (fightTeam == null) {
if(!player.getUniqueId().equals(Config.RedLeader) && Fight.getBlueTeam().canbeLeader(player)) {
Fight.getBlueTeam().addMember(player);
}else if(Fight.getRedTeam().canbeLeader(player)) {
Fight.getRedTeam().addMember(player);
}
}
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.utils; package de.steamwar.fightsystem.utils;
import de.steamwar.comms.packets.FightEndsPacket;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
@ -30,16 +31,17 @@ import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.winconditions.Wincondition; import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.sql.Elo;
import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.Instant; import java.time.Instant;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors;
import static de.steamwar.sql.Fight.create; import static de.steamwar.sql.Fight.create;
import static de.steamwar.sql.Fight.setReplay; import static de.steamwar.sql.Fight.setReplay;
@ -136,17 +138,9 @@ public class FightStatistics {
} }
replayLock = false; replayLock = false;
if(Config.Ranked){ if (!Bukkit.getOnlinePlayers().isEmpty()) {
int blueElo = Elo.getElo(blueLeader, gameMode); Player p = Bukkit.getOnlinePlayers().iterator().next();
int redElo = Elo.getElo(redLeader, gameMode); new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(SteamwarUser::get).map(SteamwarUser::getId).collect(Collectors.toList())).send(p);
double redWinExpectation = 1 / (1 + Math.pow(10, (blueElo - redElo) / 400f));
double blueWinExpectation = 1 / (1 + Math.pow(10, (redElo - blueElo) / 400f));
int newBlueElo = (int) Math.round(blueElo + K * (blueResult - blueWinExpectation));
int newRedElo = (int) Math.round(redElo + K * (1 - blueResult - redWinExpectation));
Elo.setElo(blueLeader, gameMode, newBlueElo);
Elo.setElo(redLeader, gameMode, newRedElo);
FightSystem.broadcast("UI_ELO", Fight.getBlueTeam().getPrefix(), SteamwarUser.get(blueLeader).getUserName(), blueElo, newBlueElo);
FightSystem.broadcast("UI_ELO", Fight.getRedTeam().getPrefix(), SteamwarUser.get(redLeader).getUserName(), redElo, newRedElo);
} }
} }

Datei anzeigen

@ -1,50 +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.fightsystem.winconditions;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
public class RankedPlayerLeftWincondition extends Wincondition implements Listener {
public RankedPlayerLeftWincondition(){
super("LeaderQuit");
new StateDependentListener(ArenaMode.Ranked, FightState.Setup, this);
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
FightTeam team = isTarget(player);
if(team == null)
return;
if(team.isPlayerLeader(player)) {
win(Fight.getOpposite(team), "WIN_RANKED_LEFT", team.getPrefix() + team.getLeader().getPlayer().getName());
}
}
}