found bug: Vote Buttons are now only visible if you can actually vote

This commit is contained in:
Seraina 2022-05-13 15:45:38 +02:00
parent 6f6cd28379
commit 8ecfd8e5e1
3 changed files with 12 additions and 6 deletions

View File

@ -100,6 +100,10 @@ public class Client {
ChatController.getClient().setUsername(newName);
}
public GameStateModel getGameStateModel() {
return gameStateModel;
}
/**
* Sends a message to the Server in a formatted way COMND$msg
*/
@ -347,17 +351,18 @@ public class Client {
gameStateModel.setDayClone(false);
LOGGER.debug("----------------Night, Your role is:" + gameStateModel.getYourRole() + gameStateModel);
chatApp.getGameController().setNoiseButtonInvisible();
chatApp.getGameController().setVoteButtonVisibilityNight();
chatApp.getGameController().setVoteButtonVisibilityNight(gameStateModel);
break;
case GuiParameters.day: //ClientGameInfoHandler
gameStateModel.setDayClone(true);
LOGGER.debug("----------------Day, Your role is:" + gameStateModel.getYourRole()+ gameStateModel);
chatApp.getGameController().setNoiseButtonVisible();
chatApp.getGameController().setVoteButtonVisibilityDay();
chatApp.getGameController().setVoteButtonVisibilityDay(gameStateModel);
break;
case GuiParameters.updateGameState:
gameStateModel.setGSFromString(data);
chatApp.getGameController().updateRoomLabels();
gameStateModel.setRoleFromPosition(position);
break;
case GuiParameters.noiseHeardAtPosition:
try {

View File

@ -138,6 +138,7 @@ public class GameStateModel {
String role = "h";
try {
role = passengerTrainClone[1][position];
LOGGER.debug("-----------------------Role in Set role:" + role);
} catch (Exception e) {
LOGGER.warn("Not an integer between 0-5");
}

View File

@ -131,12 +131,12 @@ public class GameController implements Initializable {
return chatAreaGame;
}
public void setVoteButtonVisibilityDay(){
public void setVoteButtonVisibilityDay(GameStateModel g){
Platform.runLater(new Runnable() {
@Override
public void run() {
LOGGER.debug(buttonRoom0);
if (gameStateModel.getYourRole().equals("h")) {
if (g.getYourRole().equals("h")) {
try {
buttonRoom0.setVisible(true);
buttonRoom1.setVisible(true);
@ -164,12 +164,12 @@ public class GameController implements Initializable {
});
}
public void setVoteButtonVisibilityNight(){
public void setVoteButtonVisibilityNight(GameStateModel g){
Platform.runLater(new Runnable() {
@Override
public void run() {
LOGGER.debug(buttonRoom0);
if (gameStateModel.getYourRole().equals("g")) {
if (g.getYourRole().equals("g")) {
try {
buttonRoom0.setVisible(true);
buttonRoom1.setVisible(true);