From 7979185753a5f85f08dde7c5bb5c895233547a8e Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Wed, 11 May 2022 22:27:50 -0400 Subject: [PATCH] make sure hider leaving doesnt create win condition --- .../tylermurphy/hideAndSeek/game/Game.java | 21 +++++++++++++------ .../resources/lang/localization_de-DE.yml | 1 + .../resources/lang/localization_en-US.yml | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java index 55e78b5..9ebb471 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Game.java @@ -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(announceMessagesToNonPlayers) Bukkit.broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND")); - else broadcastMessage(gameoverPrefix + message("GAME_GAMEOVER_HIDERS_FOUND")); - end(WinType.SEEKER_WIN); + 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")); diff --git a/src/main/resources/lang/localization_de-DE.yml b/src/main/resources/lang/localization_de-DE.yml index 5fd80d6..fec12ba 100644 --- a/src/main/resources/lang/localization_de-DE.yml +++ b/src/main/resources/lang/localization_de-DE.yml @@ -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." diff --git a/src/main/resources/lang/localization_en-US.yml b/src/main/resources/lang/localization_en-US.yml index b047bdb..1115fc4 100644 --- a/src/main/resources/lang/localization_en-US.yml +++ b/src/main/resources/lang/localization_en-US.yml @@ -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."