Ensured that noise notifications can only come from non kickedOff passenegers

This commit is contained in:
Seraina 2022-05-01 19:44:10 +02:00
parent c9f0654eef
commit 68d84b9493
3 changed files with 32 additions and 16 deletions

View File

@ -122,9 +122,12 @@ public class ServerGameInfoHandler {
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)": case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
String outMsg = npc.getName() + ": " + noiseRandomizer(); String outMsg = npc.getName() + ": " + noiseRandomizer();
//TODO: add likelyhood //TODO: add likelyhood
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg); if(!npc.getKickedOff()) {
game.getLobby().getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
+ "$" + npc.getPosition()); game.getLobby().getAdmin().sendMsgToClientsInLobby(
Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
+ "$" + npc.getPosition());
}
break; break;
case ClientGameInfoHandler.ghostVoteRequest: case ClientGameInfoHandler.ghostVoteRequest:
npc.vote(game); npc.vote(game);
@ -146,9 +149,12 @@ public class ServerGameInfoHandler {
case ClientGameInfoHandler.noiseNotification + 4 + " time(s)": case ClientGameInfoHandler.noiseNotification + 4 + " time(s)":
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)": case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
String outMsg = npc.getName() + ": " + noiseRandomizer(); String outMsg = npc.getName() + ": " + noiseRandomizer();
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg); if(!npc.getKickedOff()) {
game.getLobby().getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
+ "$" + npc.getPosition()); game.getLobby().getAdmin().sendMsgToClientsInLobby(
Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
+ "$" + npc.getPosition());
}
break; break;
case ClientGameInfoHandler.humanVoteRequest: case ClientGameInfoHandler.humanVoteRequest:
npc.vote(game); npc.vote(game);

View File

@ -199,7 +199,7 @@ public class GameController implements Initializable {
*/ */
public void addMessageToNotificationText(String msg) { public void addMessageToNotificationText(String msg) {
LOGGER.trace("addMessage " + msg); LOGGER.trace("addMessage " + msg);
Text notification = new Text("\\R" + msg); Text notification = new Text(System.lineSeparator() + msg);
notification.setFill(Color.BLACK); notification.setFill(Color.BLACK);
notification.setStyle("-fx-font: 50 arial;"); notification.setStyle("-fx-font: 50 arial;");
Platform.runLater(new Runnable() { Platform.runLater(new Runnable() {
@ -352,7 +352,9 @@ public class GameController implements Initializable {
@Override @Override
public void run() { public void run() {
try { try {
noiseImage0.setImage(loadBellImage()); if(!gameStateModel.getKickedOff()[0]) {
noiseImage0.setImage(loadBellImage());
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); LOGGER.debug(e.getMessage());
} }
@ -370,7 +372,9 @@ public class GameController implements Initializable {
@Override @Override
public void run() { public void run() {
try { try {
noiseImage1.setImage(loadBellImage()); if(!gameStateModel.getKickedOff()[1]) {
noiseImage1.setImage(loadBellImage());
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); LOGGER.debug(e.getMessage());
} }
@ -387,7 +391,9 @@ public class GameController implements Initializable {
@Override @Override
public void run() { public void run() {
try { try {
noiseImage2.setImage(loadBellImage()); if(!gameStateModel.getKickedOff()[2]) {
noiseImage2.setImage(loadBellImage());
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); LOGGER.debug(e.getMessage());
; ;
@ -405,8 +411,9 @@ public class GameController implements Initializable {
@Override @Override
public void run() { public void run() {
try { try {
LOGGER.debug("hello"); if(!gameStateModel.getKickedOff()[3]) {
noiseImage3.setImage(loadBellImage()); noiseImage3.setImage(loadBellImage());
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); LOGGER.debug(e.getMessage());
} }
@ -423,8 +430,9 @@ public class GameController implements Initializable {
@Override @Override
public void run() { public void run() {
try { try {
LOGGER.debug("hello"); if(!gameStateModel.getKickedOff()[4]) {
noiseImage4.setImage(loadBellImage()); noiseImage4.setImage(loadBellImage());
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); LOGGER.debug(e.getMessage());
} }
@ -441,7 +449,9 @@ public class GameController implements Initializable {
@Override @Override
public void run() { public void run() {
try { try {
noiseImage5.setImage(loadBellImage()); if(!gameStateModel.getKickedOff()[5]) {
noiseImage5.setImage(loadBellImage());
}
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); LOGGER.debug(e.getMessage());
} }

View File

@ -34,7 +34,7 @@
<bottom> <bottom>
<AnchorPane fx:id="ChatArea" BorderPane.alignment="CENTER"> <AnchorPane fx:id="ChatArea" BorderPane.alignment="CENTER">
<children> <children>
<SplitPane fx:id="chatSplitPane" dividerPositions="0.5" minHeight="50.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <SplitPane fx:id="chatSplitPane" dividerPositions="0.8555729984301413" minHeight="50.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items> <items>
<AnchorPane fx:id="chatAnchorPane" minHeight="0.0" minWidth="0.0" /> <AnchorPane fx:id="chatAnchorPane" minHeight="0.0" minWidth="0.0" />
<AnchorPane fx:id="otherNotificationAnchorPane" minHeight="0.0" minWidth="0.0"> <AnchorPane fx:id="otherNotificationAnchorPane" minHeight="0.0" minWidth="0.0">