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(); } }