Adding new HeartRatioTimeoutWincondition
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
9901c4edb8
Commit
80005a73b6
@ -77,6 +77,7 @@ public class Config {
|
|||||||
|
|
||||||
//Active win conditions
|
//Active win conditions
|
||||||
public static final boolean Timeout;
|
public static final boolean Timeout;
|
||||||
|
public static final boolean HeartRatioTimeout;
|
||||||
public static final boolean AllDead;
|
public static final boolean AllDead;
|
||||||
public static final boolean CaptainDead;
|
public static final boolean CaptainDead;
|
||||||
public static final boolean PercentSystem;
|
public static final boolean PercentSystem;
|
||||||
@ -155,6 +156,7 @@ public class Config {
|
|||||||
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
TeamChatDetection = config.getString("Output.TeamChatDetection");
|
||||||
|
|
||||||
Timeout = config.getBoolean("WinConditions.Timeout");
|
Timeout = config.getBoolean("WinConditions.Timeout");
|
||||||
|
HeartRatioTimeout = config.getBoolean("WinConditions.HeartRatioTimeout");
|
||||||
AllDead = config.getBoolean("WinConditions.AllDead");
|
AllDead = config.getBoolean("WinConditions.AllDead");
|
||||||
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
CaptainDead = config.getBoolean("WinConditions.CaptainDead");
|
||||||
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
PercentSystem = config.getBoolean("WinConditions.PercentSystem");
|
||||||
|
@ -37,6 +37,7 @@ Output:
|
|||||||
TeamChatDetection: +
|
TeamChatDetection: +
|
||||||
WinConditions:
|
WinConditions:
|
||||||
Timeout: boolean
|
Timeout: boolean
|
||||||
|
HeartRatioTimeout: boolean
|
||||||
AllDead: boolean
|
AllDead: boolean
|
||||||
CaptainDead: boolean
|
CaptainDead: boolean
|
||||||
PercentSystem: boolean
|
PercentSystem: boolean
|
||||||
@ -53,10 +54,6 @@ WinConditionParams:
|
|||||||
- WATER
|
- WATER
|
||||||
- TNT
|
- TNT
|
||||||
- OBSIDIAN
|
- OBSIDIAN
|
||||||
Money:
|
|
||||||
Win: 0
|
|
||||||
Lose: 0
|
|
||||||
Draw: 0
|
|
||||||
Kits:
|
Kits:
|
||||||
MemberDefault: default
|
MemberDefault: default
|
||||||
LeaderDefault: default
|
LeaderDefault: default
|
||||||
|
@ -131,6 +131,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
setAllPlayersGM(GameMode.SURVIVAL);
|
setAllPlayersGM(GameMode.SURVIVAL);
|
||||||
|
|
||||||
new WinconditionTimeout();
|
new WinconditionTimeout();
|
||||||
|
new WinconditionHeartRatioTimeout();
|
||||||
new WinconditionEntern();
|
new WinconditionEntern();
|
||||||
new WinconditionTechKO();
|
new WinconditionTechKO();
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
else
|
else
|
||||||
team = FightScoreboard.getScoreboard().getTeam(name);
|
team = FightScoreboard.getScoreboard().getTeam(name);
|
||||||
setTeamColor(team, color);
|
setTeamColor(team, color);
|
||||||
|
assert team != null;
|
||||||
team.setAllowFriendlyFire(false);
|
team.setAllowFriendlyFire(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +320,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replaceSync(boolean replace, Material target, Material replacement) {
|
void replaceSync(boolean replace, Material target, Material replacement) {
|
||||||
if(!replace)
|
if(!replace)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -362,4 +363,19 @@ public class FightTeam implements IFightTeam{
|
|||||||
public Location getSpawn() {
|
public Location getSpawn() {
|
||||||
return spawn;
|
return spawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getHeartRatio(){
|
||||||
|
int maximumHearts = 0;
|
||||||
|
double currentHearts = 0;
|
||||||
|
for(FightPlayer fightPlayer : players){
|
||||||
|
maximumHearts += 20;
|
||||||
|
if(!fightPlayer.isLiving())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
currentHearts += fightPlayer.getPlayer().getHealth();
|
||||||
|
}
|
||||||
|
|
||||||
|
assert maximumHearts != 0;
|
||||||
|
return currentHearts / maximumHearts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
public class WinconditionHeartRatioTimeout {
|
||||||
|
|
||||||
|
public WinconditionHeartRatioTimeout() {
|
||||||
|
if(!Config.HeartRatioTimeout)
|
||||||
|
return;
|
||||||
|
|
||||||
|
new TimeOverCountdown(() -> {
|
||||||
|
double blueHeartRatio = Fight.getBlueTeam().getHeartRatio();
|
||||||
|
double redHeartRatio = Fight.getRedTeam().getHeartRatio();
|
||||||
|
|
||||||
|
if(blueHeartRatio > redHeartRatio)
|
||||||
|
FightSystem.setSpectateState(Fight.getBlueTeam());
|
||||||
|
else if(blueHeartRatio < redHeartRatio)
|
||||||
|
FightSystem.setSpectateState(Fight.getRedTeam());
|
||||||
|
else
|
||||||
|
FightSystem.setSpectateState(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren