make sure hider leaving doesnt create win condition

This commit is contained in:
Tyler Murphy 2022-05-11 22:27:50 -04:00
parent 7eb687a26c
commit 7979185753
3 changed files with 17 additions and 6 deletions

View file

@ -342,6 +342,9 @@ public class Game {
}
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
else Game.broadcastMessage(messagePrefix + message("GAME_LEAVE").addPlayer(player));
if(Board.isHider(player) && status != Status.ENDING && status != Status.STANDBY){
checkWinConditions(true);
}
Board.removeBoard(player);
Board.remove(player);
player.getInventory().clear();
@ -394,7 +397,7 @@ public class Game {
}
private static void whileStarting(){
checkWinConditions();
checkWinConditions(false);
}
private static void whilePlaying() {
@ -436,14 +439,20 @@ public class Game {
if(tauntEnabled) taunt.update();
if (glowEnabled) glow.update();
}
checkWinConditions();
checkWinConditions(false);
}
private static void checkWinConditions(){
private static void checkWinConditions(boolean hiderLeave){
if(Board.sizeHider() < 1) {
if(hiderLeave){
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT"));
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_QUIT"));
end(WinType.NONE);
} else {
if (announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND"));
end(WinType.SEEKER_WIN);
}
} else if(Board.sizeSeeker() < 1) {
if(announceMessagesToNonPlayers) Bukkit.broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));
else broadcastMessage(abortPrefix + message("GAME_GAMEOVER_SEEKERS_QUIT"));

View file

@ -15,6 +15,7 @@ Localization:
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f wurde von &c{PLAYER}&f gefunden und ist nun ein Seeker."
GAME_GAMEOVER_HIDERS_FOUND: "Alle Hider wurden gefunden."
GAME_GAMEOVER_SEEKERS_QUIT: "All Seeker haben das Spiel verlassen."
GAME_GAMEOVER_HIDERS_QUIT: "All Hider haben das Spiel verlassen."
GAME_GAMEOVER_TIME: "Seekers haben keine Spielzeit mehr. Die Hiders haben gewonnen!"
GAME_SETUP: "Spiel wurde noch nicht eingerichtet. Führe &c/hs setup&f aus, um die Einrichtungsschritte zu sehen."
GAME_INGAME: "Du bist bereits in der Lobby oder im Spiel."

View file

@ -15,6 +15,7 @@ Localization:
GAME_PLAYER_FOUND_BY: "&e{PLAYER}&f was found by &c{PLAYER}&f and became a seeker."
GAME_GAMEOVER_HIDERS_FOUND: "All hiders have been found."
GAME_GAMEOVER_SEEKERS_QUIT: "All seekers have quit."
GAME_GAMEOVER_HIDERS_QUIT: "All hiders have quit."
GAME_GAMEOVER_TIME: "Seekers ran out of time. Hiders win!"
GAME_SETUP: "Game is not setup. Run /hs setup to see what you need to do."
GAME_INGAME: "You are already in the lobby/game."