Fixed game crash, and improved timer

- Fixed the null pointer exception that happened on slower computers
- Made the timer start counting down when the host clicks ready

Tags: #story[1109]
This commit is contained in:
Michael Rausch
2017-08-16 16:34:31 +12:00
parent 5843fc9212
commit 711c94001b
4 changed files with 33 additions and 10 deletions
@@ -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();
@@ -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 () {