SteamWar/FightSystem
Archiviert
13
1

Update handleDeath method
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-10-08 17:07:05 +02:00
Ursprung b24e9a8b89
Commit f1e9dda0fa

Datei anzeigen

@ -32,13 +32,12 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Random;
import java.util.*;
public class WinconditionAmongUs extends Wincondition implements Listener {
private Map<FightTeam, FightPlayer> imposter = new HashMap<>();
private final Random random = new Random();
public WinconditionAmongUs() {
@ -47,6 +46,9 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
FightPlayer redPlayer = getRandomPlayer(Fight.getRedTeam().getPlayers());
FightPlayer bluePlayer = getRandomPlayer(Fight.getBlueTeam().getPlayers());
imposter.put(Fight.getRedTeam(), redPlayer);
imposter.put(Fight.getBlueTeam(), bluePlayer);
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", redPlayer.getPlayer());
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", bluePlayer.getPlayer());
});
@ -69,16 +71,15 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
}
private void handleDeath(Player player){
// TODO: Adapt this
FightTeam team = isTarget(player);
if(team == null)
return;
for(FightPlayer fp : team.getPlayers()) {
if(fp.isLiving() && fp.getPlayer() != player)
return;
FightPlayer current = team.getFightPlayer(player);
if (current == imposter.get(team)) {
// TODO: Add message that the imposter is dead and the same team won!
} else if (team.getPlayers().contains(current) && team.getPlayers().contains(imposter.get(team))) {
// TODO: Add message that the all except the imposter are dead and the other team won!
}
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
}
}