Keep finding some bugs, keep fixing them: Some wierd messages were sent from VoteHandler

This commit is contained in:
Seraina 2022-05-14 16:23:35 +02:00
parent 84ed547372
commit d87dd237f7
8 changed files with 29 additions and 12 deletions

View File

@ -95,7 +95,7 @@ public class Game implements Runnable {
passenger.send(GuiParameters.updateGameState, getGame());
}
try {
Thread.sleep(2000); //TODO: Is this a good intervall?
Thread.sleep(1000); //TODO: Is this a good intervall?
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -120,7 +120,7 @@ public class Game implements Runnable {
Passenger[] passengerTrain = gameState.getPassengerTrain();
LOGGER.info(gameState.toString());
LOGGER.info(gameState.toGhostString());
for (ClientHandler client : lobbyClients) {//begins filling the train with clients
int index = order[i];
if (passengerTrain[index].getIsGhost()) { //if there is a ghost
@ -146,7 +146,7 @@ public class Game implements Runnable {
}
i++;
}
LOGGER.info(gameState.toString());
LOGGER.info(gameState.toGhostString());
gameStateModelUpdater(); //TODO: does that work?
for(Passenger passenger : gameState.getPassengerTrain()) {
passenger.send(Protocol.positionOfClient + "$" + passenger.getPosition(), this);

View File

@ -157,7 +157,7 @@ public class GameState {
* where one can see who is a ghost and who is a human, who is a player and who an NPC
* @return a String that displays passengerTrain
*/
public String toString() {
public String toGhostString() {
Passenger[] array = passengerTrain;
StringBuilder stringBuilder = new StringBuilder();
String[] print = new String[6];

View File

@ -67,7 +67,7 @@ public class ServerGameInfoHandler {
msg = Protocol.printToClientConsole + "$Humans are voting";
break;
case GuiParameters.updateGameState:
msg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toString();
msg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toGhostString();
break;
default:
if(!msg.contains("$")) {

View File

@ -78,7 +78,7 @@ public class VoteHandler {
if (!passengers[newGhostPosition].getIsSpectator()) {
passengers[newGhostPosition].send(
ClientGameInfoHandler.youGotGhostyfied, game);
passengers[newGhostPosition].send(game.gameState.toString(), game);
passengers[newGhostPosition].send(GuiParameters.updateGameState, game);
}
/* notify passengers the ghosts passed by - for each ghost that ghostified a player, an instance of NoiseHandler

View File

@ -47,7 +47,7 @@ public class GhostPlayer extends Ghost {
public void send(String msg, Game game) {
String formattedMsg;
if (msg.equals(GuiParameters.updateGameState)) {
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toString();
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toGhostString();
} else {
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
}

View File

@ -101,11 +101,17 @@ public class GameStateModel {
}
public String getYourRoleFromPosition(int position) {
return passengerTrainClone[1][position];
try {
return passengerTrainClone[1][position];
} catch (Exception e) {
LOGGER.info(e.getMessage());
}
return "";
}
public int getNrOfPlayers() {
return nrOfPlayers;
return
nrOfPlayers;
}
public void setDayClone(boolean dayClone) {

View File

@ -396,11 +396,21 @@ public class GameController implements Initializable {
}
public void setNoiseButtonInvisible() {
noiseButton.setVisible(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
noiseButton.setVisible(false);
}
});
}
public void setNoiseButtonVisible() {
noiseButton.setVisible(true);
Platform.runLater(new Runnable() {
@Override
public void run() {
noiseButton.setVisible(true);
}
});
}
/**

View File

@ -18,10 +18,11 @@
.text-field{
.textField{
-fx-text-fill: white;
-fx-background-color: transparent;
-fx-effect: null;
-fx-highlight-text-fill: black;
-fx-animated: null;
}