From 32bce6f2c7349d5024ccf64ef06ccc8d317a9733 Mon Sep 17 00:00:00 2001 From: Alexander Sazonov Date: Wed, 20 Apr 2022 18:32:53 +0200 Subject: [PATCH] Fixed newly emerged noise handling issue: now NPC's can send chat messages again --- .../dbis/cs108/gamelogic/ServerGameInfoHandler.java | 13 ++++++++++--- .../dmi/dbis/cs108/gamelogic/VoteHandler.java | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/ServerGameInfoHandler.java b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/ServerGameInfoHandler.java index 061301c..773672b 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/ServerGameInfoHandler.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/ServerGameInfoHandler.java @@ -104,7 +104,11 @@ public class ServerGameInfoHandler { */ public static void ghostNpcParser(GhostNPC npc, String msg, Game game) { switch (msg) { - case ClientGameInfoHandler.noiseNotification: + case ClientGameInfoHandler.noiseNotification + 1 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 2 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 3 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 4 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 5 + " time(s)": String outMsg = npc.getName() + ": " + noiseRandomizer(); game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg); break; @@ -122,9 +126,12 @@ public class ServerGameInfoHandler { */ public static void humanNpcParser(HumanNPC npc, String msg, Game game) { switch (msg) { - case ClientGameInfoHandler.noiseNotification: + case ClientGameInfoHandler.noiseNotification + 1 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 2 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 3 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 4 + " time(s)": + case ClientGameInfoHandler.noiseNotification + 5 + " time(s)": String outMsg = npc.getName() + ": " + noiseRandomizer(); - ; game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg); break; case ClientGameInfoHandler.humanVoteRequest: diff --git a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java index 1c7472d..1150c32 100644 --- a/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java +++ b/src/main/java/ch/unibas/dmi/dbis/cs108/gamelogic/VoteHandler.java @@ -101,7 +101,7 @@ public class VoteHandler { } } for (int i = 0; i < passengers.length; i++) { - if (!passengers[i].getIsGhost() && noiseAmount[i] != 0) { // passenger is human and someone walked by him + if (noiseAmount[i] != 0) { // someone walked by this player passengers[i].send(ClientGameInfoHandler.noiseNotification + noiseAmount[i] + " time(s)", game); } }