|
|
|
@ -43,21 +43,23 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
|
|
|
|
|
public WinconditionAmongUs() {
|
|
|
|
|
super("AmongUs");
|
|
|
|
|
new OneShotStateDependent(Winconditions.AMONG_US, FightState.Ingame, () -> {
|
|
|
|
|
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());
|
|
|
|
|
imposter.put(Fight.getRedTeam(), sendMessageAndReturnImposter(Fight.getRedTeam().getPlayers()));
|
|
|
|
|
imposter.put(Fight.getBlueTeam(), sendMessageAndReturnImposter(Fight.getBlueTeam().getPlayers()));
|
|
|
|
|
});
|
|
|
|
|
new StateDependentListener(Winconditions.AMONG_US, FightState.Ingame, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private FightPlayer getRandomPlayer(Collection<FightPlayer> fightPlayers) {
|
|
|
|
|
private FightPlayer sendMessageAndReturnImposter(Collection<FightPlayer> fightPlayers) {
|
|
|
|
|
List<FightPlayer> fightPlayerList = new ArrayList<>(fightPlayers);
|
|
|
|
|
return fightPlayerList.get(random.nextInt(fightPlayerList.size()));
|
|
|
|
|
FightPlayer imposter = fightPlayerList.get(random.nextInt(fightPlayerList.size()));
|
|
|
|
|
for (FightPlayer fightPlayer : fightPlayerList) {
|
|
|
|
|
if (fightPlayer == imposter) {
|
|
|
|
|
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", fightPlayer.getPlayer());
|
|
|
|
|
} else {
|
|
|
|
|
FightSystem.getMessage().send("AMONG_US_IMPOSTER_AMONG_MESSAGE", fightPlayer.getPlayer());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return imposter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
@ -77,9 +79,9 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
|
|
|
|
|
|
|
|
|
|
FightPlayer current = team.getFightPlayer(player);
|
|
|
|
|
if (current == imposter.get(team)) {
|
|
|
|
|
// TODO: Add message that the imposter is dead and the same team won!
|
|
|
|
|
win(team, "WIN_IMPOSTER_DEAD", team.getPrefix());
|
|
|
|
|
} 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_CREWMATE_DEAD", Fight.getOpposite(team).getPrefix());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|