SteamWar/FightSystem
Archiviert
13
1
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
FightSystem/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java

41 Zeilen
1.3 KiB
Java

package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.countdown.TimeOverCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import java.util.EnumSet;
public class WinconditionPercentTimeout extends Wincondition {
private static final String WINDESCRIPTION = "PercentTimeout";
private TimeOverCountdown countdown;
public WinconditionPercentTimeout() {
super(Config.HeartRatioTimeout, EnumSet.of(FightState.RUNNING));
}
@Override
public void enable() {
countdown = new TimeOverCountdown(() -> {
double bluePercent = WinconditionPercentSystem.getBluePercent();
double redPercent = WinconditionPercentSystem.getRedPercent();
if(bluePercent > redPercent)
FightSystem.setSpectateState(Fight.getBlueTeam(), WINDESCRIPTION);
else if(bluePercent < redPercent)
FightSystem.setSpectateState(Fight.getRedTeam(), WINDESCRIPTION);
else
FightSystem.setSpectateState(null, WINDESCRIPTION);
});
}
@Override
public void disable(){
countdown.disable();
}
}