Added a way to end a game, when its lobby is closed.
This commit is contained in:
parent
4d82af32f4
commit
88f72d7612
@ -24,6 +24,7 @@ public class Game implements Runnable {
|
||||
protected boolean isDay = false; //false means it is night, it is night by default
|
||||
protected VoteHandler voteHandler = new VoteHandler();
|
||||
private Lobby lobby;
|
||||
private boolean isOngoing = true;
|
||||
private String name;
|
||||
private static int nameCounter = 0;
|
||||
/**
|
||||
@ -57,6 +58,10 @@ public class Game implements Runnable {
|
||||
isDay = day;
|
||||
}
|
||||
|
||||
public void setOngoing(boolean ongoing) {
|
||||
isOngoing = ongoing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new game, creates a passenger array and saves it in gameState, sets the OG
|
||||
* currently at gameState.train[3] fills the passengerTrain moving from left to rigth in the
|
||||
@ -102,7 +107,7 @@ public class Game implements Runnable {
|
||||
LOGGER.info(gameState.toString());
|
||||
|
||||
i = 0;
|
||||
while (true) {
|
||||
while (isOngoing == true) {
|
||||
if (!isDay) {
|
||||
LOGGER.info("NIGHT");
|
||||
gameOverCheck = voteHandler.ghostVote(gameState.getPassengerTrain(), this);
|
||||
|
||||
@ -228,6 +228,7 @@ public class Lobby {
|
||||
*/
|
||||
public void closeLobby() {
|
||||
lobbies.remove(this);
|
||||
game.setOngoing(false); // ends game
|
||||
//ClientHandler.broadcastAnnouncementToAll("Lobby nr. " + this.getLobbyID() + " has been closed.");
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user