2021-03-10 22:45:17 +01:00
/ *
This file is a part of the SteamWar software .
2021-03-10 17:12:24 +01:00
2021-03-10 22:45:17 +01:00
Copyright ( C ) 2020 SteamWar . de - Serverteam
2021-03-10 17:12:24 +01:00
2021-03-10 22:45:17 +01:00
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 .
2021-03-10 17:12:24 +01:00
2021-03-10 22:45:17 +01:00
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 .
2021-03-10 17:12:24 +01:00
2021-03-10 22:45:17 +01:00
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/>.
* /
2021-03-10 17:12:24 +01:00
2021-03-10 22:45:17 +01:00
package de.steamwar.fightsystem.winconditions ;
2021-03-10 17:12:24 +01:00
2021-03-12 15:43:32 +01:00
import de.steamwar.fightsystem.countdown.TimeOverCountdown ;
2021-03-10 22:45:17 +01:00
import de.steamwar.fightsystem.fight.Fight ;
import de.steamwar.fightsystem.fight.FightTeam ;
2021-03-12 15:43:32 +01:00
import de.steamwar.fightsystem.states.FightState ;
import de.steamwar.fightsystem.states.StateDependentCountdown ;
2021-03-10 17:12:24 +01:00
2021-03-12 15:43:32 +01:00
public class WinconditionPercentTimeout extends Wincondition {
2021-03-10 22:45:17 +01:00
public WinconditionPercentTimeout ( ) {
2021-03-12 15:43:32 +01:00
super ( " PercentTimeout " , " §cDie Zeit ist abgelaufen, und Team " , " §chatte weniger Schaden erlitten! " , " §cDie Zeit ist abgelaufen, und beide Teams hatten gleichen Schaden! " ) ;
timeOverCountdown = new StateDependentCountdown ( Winconditions . PERCENT_TIMEOUT , FightState . Running , new TimeOverCountdown ( this : : timeOver ) ) ;
2021-03-10 17:12:24 +01:00
}
2021-03-10 22:45:17 +01:00
protected void timeOver ( ) {
double bluePercent = Wincondition . percentWincondition . getPercent ( Fight . getBlueTeam ( ) ) ;
double redPercent = Wincondition . percentWincondition . getPercent ( Fight . getRedTeam ( ) ) ;
FightTeam team = null ;
if ( bluePercent > redPercent )
team = Fight . getRedTeam ( ) ;
else if ( bluePercent < redPercent )
team = Fight . getBlueTeam ( ) ;
2021-03-12 15:43:32 +01:00
win ( team ) ;
2021-03-10 17:12:24 +01:00
}
}