Merge branch 'master' into story_61
Also got client-server handshake working. Multiple clients can connect and control their own boat. The client's boat has a larger black triangle drawn around it. Probably needs tidying up. Added isClientBoat boolean to VisualiserBoat. WindGenerator is now an interface, implemented by ConstantWindGenerator (useful for testing) and RandomWindGenerator. Added ConstantWindGeneratorTest. RandomWindGenerator was formerly WindGenerator. The WindGenerator is passed in to MockRace. CommandFactory throws a CommandConstructionException if it cannot create a command. MessageSerialiser and MessageDeserialiser correctly terminate on error. Readded VisualiserInput's switch statement in the main loop, pending a refactor. Removed the sleep statement from LobbyController - it was blocking javaFX thread. Lobby.fxml: moved buttons and text input into grid panes, so they don't break when you resize screen. Added some test object creation functions in several test classes (MockRaceTest.createMockRace(), BoatXMLReaderTest.createBoatDataSource(), etc...). #story[1095]
This commit is contained in:
@@ -74,6 +74,11 @@ public class StartController extends Controller implements Observer {
|
||||
*/
|
||||
private ServerConnection serverConnection;
|
||||
|
||||
/**
|
||||
* Writes BoatActions to outgoing message queue.
|
||||
*/
|
||||
private ControllerClient controllerClient;
|
||||
|
||||
|
||||
/**
|
||||
* The race object which describes the currently occurring race.
|
||||
@@ -85,7 +90,7 @@ public class StartController extends Controller implements Observer {
|
||||
/**
|
||||
* An array of colors used to assign colors to each boat - passed in to the VisualiserRace constructor.
|
||||
*/
|
||||
List<Color> colors = new ArrayList<>(Arrays.asList(
|
||||
private List<Color> colors = new ArrayList<>(Arrays.asList(
|
||||
Color.BLUEVIOLET,
|
||||
Color.BLACK,
|
||||
Color.RED,
|
||||
@@ -130,6 +135,14 @@ public class StartController extends Controller implements Observer {
|
||||
this.visualiserRace = new VisualiserRace(boatDataSource, raceDataSource, regattaDataSource, latestMessages, this.colors);
|
||||
new Thread(this.visualiserRace).start();
|
||||
|
||||
//Ugly. TODO refactor
|
||||
ObservableList<VisualiserBoat> boats = visualiserRace.getBoats();
|
||||
for (VisualiserBoat boat : boats) {
|
||||
if (boat.getSourceID() == serverConnection.getAllocatedSourceID()) {
|
||||
boat.setClientBoat(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Initialise the boat table.
|
||||
initialiseBoatTable(this.visualiserRace);
|
||||
@@ -264,7 +277,7 @@ public class StartController extends Controller implements Observer {
|
||||
startWrapper.setVisible(false);
|
||||
start.setVisible(false);
|
||||
|
||||
parent.beginRace(visualiserInput, visualiserRace, controllerClient);
|
||||
parent.beginRace(visualiserRace, controllerClient, serverConnection);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
@@ -315,6 +328,7 @@ public class StartController extends Controller implements Observer {
|
||||
|
||||
LatestMessages latestMessages = new LatestMessages();
|
||||
this.serverConnection = new ServerConnection(socket, latestMessages);
|
||||
this.controllerClient = serverConnection.getControllerClient();
|
||||
|
||||
|
||||
//Store a reference to latestMessages so that we can observe it.
|
||||
|
||||
Reference in New Issue
Block a user