|
|
|
|
@ -7,6 +7,9 @@ import seng302.Controllers.RaceController;
|
|
|
|
|
import seng302.GPSCoordinate;
|
|
|
|
|
import seng302.Model.*;
|
|
|
|
|
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
|
|
|
|
|
import seng302.Networking.Utils.BoatStatusMessage;
|
|
|
|
|
import seng302.Networking.Utils.ByteConverter;
|
|
|
|
|
import seng302.Networking.Utils.Enums.BoatStatus;
|
|
|
|
|
import seng302.Networking.Utils.BoatLocationMessage;
|
|
|
|
|
import seng302.RaceDataSource;
|
|
|
|
|
import seng302.VisualiserInput;
|
|
|
|
|
@ -51,18 +54,26 @@ public class StreamedRace extends Race {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks the position of the boat, this updates the boats current position.
|
|
|
|
|
* Checks the position of the boat.
|
|
|
|
|
*
|
|
|
|
|
* @param boat Boat that the position is to be updated for.
|
|
|
|
|
* @param timeElapsed Time that has elapse since the start of the the race.
|
|
|
|
|
* @see BoatInRace
|
|
|
|
|
*/
|
|
|
|
|
protected void checkPosition(Boat boat, long timeElapsed) {
|
|
|
|
|
if (boat.getCurrentLeg().getName().toLowerCase().contains("finish")) {
|
|
|
|
|
//boat has finished
|
|
|
|
|
StreamedCourse raceData = visualiserInput.getCourse();
|
|
|
|
|
BoatStatusMessage boatStatusMessage = visualiserInput.getBoatStatus().get(boat.getSourceID());
|
|
|
|
|
BoatStatus boatStatus = BoatStatus.valueOf(boatStatusMessage.getBoatStatus());
|
|
|
|
|
int legNumber = boatStatusMessage.getLegNumber();
|
|
|
|
|
|
|
|
|
|
if (boatStatus == BoatStatus.DNF) {
|
|
|
|
|
boat.setDnf(true);
|
|
|
|
|
} else if (boatStatus == BoatStatus.FINISHED || legNumber > raceData.getLegs().size()) {
|
|
|
|
|
boatsFinished++;
|
|
|
|
|
boat.setFinished(true);
|
|
|
|
|
boat.setTimeFinished(timeElapsed);
|
|
|
|
|
boat.setFinished(true);
|
|
|
|
|
} else {
|
|
|
|
|
boat.setCurrentLeg(raceData.getLegs().get(legNumber));
|
|
|
|
|
}
|
|
|
|
|
//Update the boat display table in the GUI to reflect the leg change
|
|
|
|
|
updatePositions();
|
|
|
|
|
|