diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index 17dc1374..d44820cc 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -89,7 +89,7 @@ public class GameState implements Runnable { markOrder = new MarkOrder(); //This could be instantiated at some point with a select map? markListeners = new ArrayList<>(); - startTime = System.currentTimeMillis() + 60000; + resetStartTime(); new Thread(this).start(); //Run the auto updates on the game state new Thread(this, "GameState").start(); //Run the auto updates on the game state @@ -149,6 +149,10 @@ public class GameState implements Runnable { return startTime; } + public static void resetStartTime(){ + startTime = System.currentTimeMillis() + MainServerThread.TIME_TILL_START; + } + public static Double getWindDirection() { return windDirection; } diff --git a/src/main/java/seng302/gameServer/MainServerThread.java b/src/main/java/seng302/gameServer/MainServerThread.java index c1eb394f..fe0d9017 100644 --- a/src/main/java/seng302/gameServer/MainServerThread.java +++ b/src/main/java/seng302/gameServer/MainServerThread.java @@ -27,9 +27,9 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate { private static final int PORT = 4942; private static final Integer CLIENT_UPDATES_PER_SECOND = 10; private static final int LOG_LEVEL = 1; - private static final int PRESTART_TIME = 60 * -1000; - private static final int WARNING_TIME = 30 * -1000; - private static final int PREPATORY_TIME = 10 * -1000; + private static final int WARNING_TIME = 10 * -1000; + private static final int PREPATORY_TIME = 5 * -1000; + public static final int TIME_TILL_START = 10 * 1000; private boolean terminated; diff --git a/src/main/java/seng302/visualiser/GameClient.java b/src/main/java/seng302/visualiser/GameClient.java index c3947826..16c17595 100644 --- a/src/main/java/seng302/visualiser/GameClient.java +++ b/src/main/java/seng302/visualiser/GameClient.java @@ -12,6 +12,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Node; import javafx.scene.input.KeyEvent; import javafx.scene.layout.Pane; +import seng302.gameServer.GameState; import seng302.gameServer.MainServerThread; import seng302.gameServer.server.messages.BoatAction; import seng302.model.ClientYacht; @@ -76,8 +77,16 @@ public class GameClient { LobbyController lobbyController = loadLobby(); lobbyController.setPlayerListSource(clientLobbyList); lobbyController.disableReadyButton(); - lobbyController.setTitle(regattaData.getRegattaName()); - lobbyController.setCourseName(regattaData.getCourseName()); + + if (regattaData != null){ + lobbyController.setTitle(regattaData.getRegattaName()); + lobbyController.setCourseName(regattaData.getCourseName()); + } + else{ + lobbyController.setTitle(ipAddress); + lobbyController.setCourseName(""); + } + lobbyController.addCloseListener((exitCause) -> this.loadStartScreen()); this.lobbyController = lobbyController; } @@ -98,10 +107,20 @@ public class GameClient { socketThread.addStreamObserver(this::parsePackets); LobbyController lobbyController = loadLobby(); lobbyController.setPlayerListSource(clientLobbyList); - lobbyController.setTitle("Hosting: " + regattaData.getRegattaName()); - lobbyController.setCourseName(regattaData.getCourseName()); + + if (regattaData != null){ + lobbyController.setTitle("Hosting: " + regattaData.getRegattaName()); + lobbyController.setCourseName(regattaData.getCourseName()); + } + else{ + lobbyController.setTitle("Hosting: " + ipAddress); + lobbyController.setCourseName(""); + } + lobbyController.addCloseListener(exitCause -> { if (exitCause == CloseStatus.READY) { + GameState.resetStartTime(); + lobbyController.disableReadyButton(); server.startGame(); } else if (exitCause == CloseStatus.LEAVE) { loadStartScreen(); diff --git a/src/main/java/seng302/visualiser/controllers/LobbyController.java b/src/main/java/seng302/visualiser/controllers/LobbyController.java index 86a63ff5..fa160e53 100644 --- a/src/main/java/seng302/visualiser/controllers/LobbyController.java +++ b/src/main/java/seng302/visualiser/controllers/LobbyController.java @@ -96,7 +96,7 @@ public class LobbyController { ); initialiseImageView(); - timeUntilStart.setText(""); + timeUntilStart.setText("Waiting For Host..."); } /** @@ -170,7 +170,7 @@ public class LobbyController { public void updateRaceState(RaceState raceState){ this.raceState = raceState; - timeUntilStart.setText(raceState.getRaceTimeStr()); + timeUntilStart.setText("Starting in: " + raceState.getRaceTimeStr()); } public void disableReadyButton () {