Fixed some wonky bugs, and added minimum vote time of 5 seconds to calm the game down a litte
This commit is contained in:
parent
17fc986c50
commit
a8fa462949
@ -36,7 +36,11 @@ public class ServerGameInfoHandler {
|
||||
msg = Protocol.serverRequestsHumanVote + "$" + passenger.getPosition() + "$";
|
||||
break;
|
||||
default:
|
||||
msg = Protocol.printToClientConsole + "$" + msg;
|
||||
if(!msg.contains("$")) {
|
||||
msg = Protocol.printToClientConsole + "$" + msg;
|
||||
} else {
|
||||
msg = msg;
|
||||
}
|
||||
}
|
||||
LOGGER.debug(msg);
|
||||
return msg;
|
||||
@ -64,7 +68,11 @@ public class ServerGameInfoHandler {
|
||||
msg = Protocol.printToGUI + "$" + GuiParameters.updateGameState + game.getGameState().toString();
|
||||
break;
|
||||
default:
|
||||
msg = Protocol.printToClientConsole + "$" + msg;
|
||||
if(!msg.contains("$")) {
|
||||
msg = Protocol.printToClientConsole + "$" + msg;
|
||||
} else {
|
||||
msg = msg;
|
||||
}
|
||||
}
|
||||
LOGGER.debug(msg);
|
||||
return msg;
|
||||
@ -112,7 +120,6 @@ public class ServerGameInfoHandler {
|
||||
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
|
||||
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
||||
//TODO: add likelyhood
|
||||
Timer.ghostAfterVoteTimer();
|
||||
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
|
||||
game.getLobby().getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
|
||||
+ "$" + npc.getPosition());
|
||||
@ -137,7 +144,6 @@ public class ServerGameInfoHandler {
|
||||
case ClientGameInfoHandler.noiseNotification + 4 + " time(s)":
|
||||
case ClientGameInfoHandler.noiseNotification + 5 + " time(s)":
|
||||
String outMsg = npc.getName() + ": " + noiseRandomizer();
|
||||
Timer.ghostAfterVoteTimer();
|
||||
game.getLobby().getAdmin().broadcastNpcChatMessageToLobby(outMsg);
|
||||
game.getLobby().getAdmin().sendMsgToClientsInLobby(Protocol.printToGUI + "$" + GuiParameters.noiseHeardAtPosition
|
||||
+ "$" + npc.getPosition());
|
||||
|
||||
@ -39,6 +39,11 @@ public class Timer {
|
||||
*/
|
||||
public static final int interval = 1;
|
||||
|
||||
/**
|
||||
* The minimal vote time, in seconds
|
||||
*/
|
||||
public static final int minVoteTime = 5;
|
||||
|
||||
/**
|
||||
* The timer for the ghost vote. Checks every {@code interval} seconds if every ghost has already voted.
|
||||
* If all have voted or if the {@code ghostVoteTime} value is reached, the timer ends
|
||||
@ -47,7 +52,7 @@ public class Timer {
|
||||
public static void ghostVoteTimer(Game game) {
|
||||
int counter = 0;
|
||||
while(counter < ghostVoteTime) {
|
||||
if(haveAllGhostsVoted(game)) { //if all ghost have voted
|
||||
if(haveAllGhostsVoted(game) && counter > minVoteTime) { //if all ghost have voted
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@ -62,7 +67,7 @@ public class Timer {
|
||||
public static void humanVoteTimer(Game game) {
|
||||
int counter = 0;
|
||||
while (counter < humanVoteTime) {
|
||||
if (haveAllHumansVoted(game)) return;
|
||||
if (haveAllHumansVoted(game) && counter > minVoteTime) return;
|
||||
try {
|
||||
Thread.sleep(interval*1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@ -68,7 +68,6 @@ public class VoteHandler {
|
||||
}
|
||||
}
|
||||
LOGGER.info("Most votes for: " + newGhostPosition);
|
||||
Timer.ghostAfterVoteTimer();
|
||||
for(Passenger passenger : passengers) {
|
||||
if(passenger.getIsGhost() || passenger.getIsSpectator()) {
|
||||
passenger.send(passengers[newGhostPosition].getName() + ClientGameInfoHandler.gotGhostyfied, game);
|
||||
@ -87,7 +86,6 @@ public class VoteHandler {
|
||||
walk by is being updated. Finally, each passenger receives information about how often he heard something during
|
||||
this night. The player who's just been ghostified is ignored since he didn't participate in this night's
|
||||
ghostification. */
|
||||
Timer.ghostAfterVoteTimer();
|
||||
int[] noiseAmount = new int[6];
|
||||
for (int i = 0; i < passengers.length; i++) {
|
||||
if (passengers[i].getIsGhost() && i != newGhostPosition) {
|
||||
|
||||
@ -346,6 +346,7 @@ public class Client {
|
||||
break;
|
||||
case GuiParameters.day: //ClientGameInfoHandler
|
||||
gameStateModel.setDayClone(true);
|
||||
chatApp.getGameController().setNoiseButtonVisible();
|
||||
break;
|
||||
case GuiParameters.updateGameState:
|
||||
gameStateModel.setGSFromString(data);
|
||||
|
||||
@ -39,6 +39,7 @@ public class JClientProtocolParser {
|
||||
c.clientPinger.setGotPingBack(true);
|
||||
break;
|
||||
case Protocol.printToClientConsole:
|
||||
LOGGER.debug(msg);
|
||||
System.out.println(msg.substring(6));
|
||||
if (!msg.substring(6).equals("Your vote was invalid")) {
|
||||
c.notificationTextDisplay(msg.substring(6));
|
||||
@ -83,8 +84,9 @@ public class JClientProtocolParser {
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn(msg.substring(6));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("Received unknown command");
|
||||
System.out.println("Received unknown command: " + msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,7 +117,6 @@ public class GameStateModel {
|
||||
j = right.indexOf(':');
|
||||
roles[i] = right.substring(0, j);
|
||||
kickedOff[i] = Boolean.parseBoolean(right.substring(j + 1));
|
||||
LOGGER.info(kickedOff[i]);
|
||||
i++;
|
||||
}
|
||||
setPassengerTrainClone(names, roles);
|
||||
|
||||
@ -268,7 +268,7 @@ public class GameController implements Initializable{
|
||||
if(kickedOff[1]) {
|
||||
role1 = new Text("\nkicked off");
|
||||
} else {
|
||||
role1 = new Text("\n" + roles[0]);
|
||||
role1 = new Text("\n" + roles[1]);
|
||||
}
|
||||
role1.setStyle("-fx-font: 25 arial;");
|
||||
role1.setFill(Color.WHITE);
|
||||
@ -276,7 +276,7 @@ public class GameController implements Initializable{
|
||||
if(kickedOff[2]) {
|
||||
role2 = new Text("\nkicked off");
|
||||
} else {
|
||||
role2 = new Text("\n" + roles[0]);
|
||||
role2 = new Text("\n" + roles[2]);
|
||||
}
|
||||
role2.setStyle("-fx-font: 25 arial;");
|
||||
role2.setFill(Color.WHITE);
|
||||
@ -284,7 +284,7 @@ public class GameController implements Initializable{
|
||||
if(kickedOff[3]) {
|
||||
role3 = new Text("\nkicked off");
|
||||
} else {
|
||||
role3 = new Text("\n" + roles[0]);
|
||||
role3 = new Text("\n" + roles[3]);
|
||||
}
|
||||
role3.setStyle("-fx-font: 25 arial;");
|
||||
role3.setFill(Color.WHITE);
|
||||
@ -292,7 +292,7 @@ public class GameController implements Initializable{
|
||||
if(kickedOff[4]) {
|
||||
role4 = new Text("\nkicked off");
|
||||
} else {
|
||||
role4 = new Text("\n" + roles[0]);
|
||||
role4 = new Text("\n" + roles[4]);
|
||||
}
|
||||
role4.setStyle("-fx-font: 25 arial;");
|
||||
role4.setFill(Color.WHITE);
|
||||
@ -300,7 +300,7 @@ public class GameController implements Initializable{
|
||||
if(kickedOff[5]) {
|
||||
role5 = new Text("\nkicked off");
|
||||
} else {
|
||||
role5 = new Text("\n" + roles[0]);
|
||||
role5 = new Text("\n" + roles[5]);
|
||||
}
|
||||
role5.setStyle("-fx-font: 25 arial;");
|
||||
role5.setFill(Color.WHITE);
|
||||
|
||||
Reference in New Issue
Block a user