Keep finding some bugs, keep fixing them: Some wierd messages were sent from VoteHandler
This commit is contained in:
parent
84ed547372
commit
d87dd237f7
@ -95,7 +95,7 @@ public class Game implements Runnable {
|
|||||||
passenger.send(GuiParameters.updateGameState, getGame());
|
passenger.send(GuiParameters.updateGameState, getGame());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(2000); //TODO: Is this a good intervall?
|
Thread.sleep(1000); //TODO: Is this a good intervall?
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ public class Game implements Runnable {
|
|||||||
Passenger[] passengerTrain = gameState.getPassengerTrain();
|
Passenger[] passengerTrain = gameState.getPassengerTrain();
|
||||||
|
|
||||||
|
|
||||||
LOGGER.info(gameState.toString());
|
LOGGER.info(gameState.toGhostString());
|
||||||
for (ClientHandler client : lobbyClients) {//begins filling the train with clients
|
for (ClientHandler client : lobbyClients) {//begins filling the train with clients
|
||||||
int index = order[i];
|
int index = order[i];
|
||||||
if (passengerTrain[index].getIsGhost()) { //if there is a ghost
|
if (passengerTrain[index].getIsGhost()) { //if there is a ghost
|
||||||
@ -146,7 +146,7 @@ public class Game implements Runnable {
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
LOGGER.info(gameState.toString());
|
LOGGER.info(gameState.toGhostString());
|
||||||
gameStateModelUpdater(); //TODO: does that work?
|
gameStateModelUpdater(); //TODO: does that work?
|
||||||
for(Passenger passenger : gameState.getPassengerTrain()) {
|
for(Passenger passenger : gameState.getPassengerTrain()) {
|
||||||
passenger.send(Protocol.positionOfClient + "$" + passenger.getPosition(), this);
|
passenger.send(Protocol.positionOfClient + "$" + passenger.getPosition(), this);
|
||||||
|
|||||||
@ -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
|
* 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
|
* @return a String that displays passengerTrain
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toGhostString() {
|
||||||
Passenger[] array = passengerTrain;
|
Passenger[] array = passengerTrain;
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
String[] print = new String[6];
|
String[] print = new String[6];
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public class ServerGameInfoHandler {
|
|||||||
msg = Protocol.printToClientConsole + "$Humans are voting";
|
msg = Protocol.printToClientConsole + "$Humans are voting";
|
||||||
break;
|
break;
|
||||||
case GuiParameters.updateGameState:
|
case GuiParameters.updateGameState:
|
||||||
msg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toString();
|
msg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toGhostString();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(!msg.contains("$")) {
|
if(!msg.contains("$")) {
|
||||||
|
|||||||
@ -78,7 +78,7 @@ public class VoteHandler {
|
|||||||
if (!passengers[newGhostPosition].getIsSpectator()) {
|
if (!passengers[newGhostPosition].getIsSpectator()) {
|
||||||
passengers[newGhostPosition].send(
|
passengers[newGhostPosition].send(
|
||||||
ClientGameInfoHandler.youGotGhostyfied, game);
|
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
|
/* notify passengers the ghosts passed by - for each ghost that ghostified a player, an instance of NoiseHandler
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class GhostPlayer extends Ghost {
|
|||||||
public void send(String msg, Game game) {
|
public void send(String msg, Game game) {
|
||||||
String formattedMsg;
|
String formattedMsg;
|
||||||
if (msg.equals(GuiParameters.updateGameState)) {
|
if (msg.equals(GuiParameters.updateGameState)) {
|
||||||
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toString();
|
formattedMsg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toGhostString();
|
||||||
} else {
|
} else {
|
||||||
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
|
formattedMsg = ServerGameInfoHandler.format(msg, this, game);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,11 +101,17 @@ public class GameStateModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getYourRoleFromPosition(int position) {
|
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() {
|
public int getNrOfPlayers() {
|
||||||
return nrOfPlayers;
|
return
|
||||||
|
nrOfPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDayClone(boolean dayClone) {
|
public void setDayClone(boolean dayClone) {
|
||||||
|
|||||||
@ -396,11 +396,21 @@ public class GameController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setNoiseButtonInvisible() {
|
public void setNoiseButtonInvisible() {
|
||||||
noiseButton.setVisible(false);
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
noiseButton.setVisible(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoiseButtonVisible() {
|
public void setNoiseButtonVisible() {
|
||||||
noiseButton.setVisible(true);
|
Platform.runLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
noiseButton.setVisible(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -18,10 +18,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
.text-field{
|
.textField{
|
||||||
-fx-text-fill: white;
|
-fx-text-fill: white;
|
||||||
-fx-background-color: transparent;
|
-fx-background-color: transparent;
|
||||||
-fx-effect: null;
|
-fx-effect: null;
|
||||||
|
-fx-highlight-text-fill: black;
|
||||||
-fx-animated: null;
|
-fx-animated: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user