SteamWar/FightSystem
Archiviert
13
1

AmongUS #367

Zusammengeführt
Lixfel hat 9 Commits von AmongUS nach master 2022-10-08 18:30:11 +02:00 zusammengeführt
Nur Änderungen aus Commit f1e9dda0fa werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -32,13 +32,12 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
import java.util.Random;
public class WinconditionAmongUs extends Wincondition implements Listener { public class WinconditionAmongUs extends Wincondition implements Listener {
private Map<FightTeam, FightPlayer> imposter = new HashMap<>();
private final Random random = new Random(); private final Random random = new Random();
public WinconditionAmongUs() { public WinconditionAmongUs() {
@ -47,6 +46,9 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
FightPlayer redPlayer = getRandomPlayer(Fight.getRedTeam().getPlayers()); FightPlayer redPlayer = getRandomPlayer(Fight.getRedTeam().getPlayers());
FightPlayer bluePlayer = getRandomPlayer(Fight.getBlueTeam().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", redPlayer.getPlayer());
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", bluePlayer.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){ private void handleDeath(Player player){
// TODO: Adapt this
FightTeam team = isTarget(player); FightTeam team = isTarget(player);
if(team == null) if(team == null)
return; return;
for(FightPlayer fp : team.getPlayers()) { FightPlayer current = team.getFightPlayer(player);
if(fp.isLiving() && fp.getPlayer() != player) if (current == imposter.get(team)) {
return; // 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());
} }
} }