SteamWar/FightSystem
Archiviert
13
1

Fix relative wincondition

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-03-31 21:58:21 +02:00
Ursprung 68f4da0f4f
Commit 2937d65683

Datei anzeigen

@ -50,17 +50,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
super("RelativePercent", null);
teamMap.put(Fight.getBlueTeam(), new TeamPercent(Fight.getBlueTeam()));
teamMap.put(Fight.getRedTeam(), new TeamPercent(Fight.getRedTeam()));
new StateDependent(Winconditions.RELATIVE_PERCENT, FightState.Running){
@Override
public void enable() {
teamMap.values().forEach(TeamPercent::enable);
}
@Override
public void disable() {
teamMap.values().forEach(TeamPercent::disable);
}
}.register();
if(Config.ActiveWinconditions.contains(Winconditions.RELATIVE_PERCENT)){
printableWinconditions.add(this);
percentWincondition = this;
@ -77,7 +67,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
return team.getPrefix() + "Schaden: " + (Math.round(100.0 * getPercent(team)) / 100.0) + "%";
}
public static class TeamPercent {
public static class TeamPercent extends StateDependent {
private final FightTeam team;
private int blockCount;
@ -85,15 +75,19 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
private int currentBlocks;
public TeamPercent(FightTeam team){
super(Winconditions.RELATIVE_PERCENT, FightState.Running);
this.team = team;
this.currentBlocks = 1;
register();
}
@Override
public void enable(){
blockCount = currentBlocks();
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::check, 400, 400);
}
@Override
public void disable(){
task.cancel();
}
@ -122,7 +116,7 @@ public class WinconditionRelativePercent extends Wincondition implements Printab
private int currentBlocks(){
// Entern active
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Config.TimeoutTime - Wincondition.getTimeOverCountdown().getTimeLeft())
if(!Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft())
return currentBlocks;
currentBlocks = 0;