|
|
|
@ -1,12 +1,10 @@
|
|
|
|
package seng302.Model;
|
|
|
|
package seng302.Model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javafx.animation.AnimationTimer;
|
|
|
|
import javafx.animation.AnimationTimer;
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.FXCollections;
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
import javafx.collections.ObservableList;
|
|
|
|
import org.geotools.referencing.GeodeticCalculator;
|
|
|
|
import org.geotools.referencing.GeodeticCalculator;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import seng302.Constants;
|
|
|
|
import seng302.Constants;
|
|
|
|
import seng302.DataInput.RaceDataSource;
|
|
|
|
import seng302.DataInput.RaceDataSource;
|
|
|
|
import seng302.MockOutput;
|
|
|
|
import seng302.MockOutput;
|
|
|
|
@ -19,7 +17,6 @@ import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Parent class for races
|
|
|
|
* Parent class for races
|
|
|
|
* Created by fwy13 on 3/03/17.
|
|
|
|
* Created by fwy13 on 3/03/17.
|
|
|
|
@ -30,60 +27,19 @@ public class Race implements Runnable {
|
|
|
|
protected List<Leg> legs;
|
|
|
|
protected List<Leg> legs;
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
protected int boatsFinished = 0;
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
protected long totalTimeElapsed;
|
|
|
|
protected int scaleFactor = 20;
|
|
|
|
protected int scaleFactor = 3;
|
|
|
|
protected int PRERACE_TIME = 18000; //time in milliseconds to pause during pre-race. At the moment, 3 minutes
|
|
|
|
|
|
|
|
private long startTime;
|
|
|
|
private long startTime;
|
|
|
|
protected boolean countdownFinish = false;
|
|
|
|
|
|
|
|
protected boolean runRace = true;
|
|
|
|
|
|
|
|
private int lastFPS = 20;
|
|
|
|
|
|
|
|
private int raceId;
|
|
|
|
private int raceId;
|
|
|
|
private int dnfChance = 0; //percentage chance a boat fails at each checkpoint
|
|
|
|
private int dnfChance = 0; //percentage chance a boat fails at each checkpoint
|
|
|
|
private MockOutput mockOutput;
|
|
|
|
private MockOutput mockOutput;
|
|
|
|
private static int boatOffset = 0;
|
|
|
|
|
|
|
|
private int finished = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Initailiser for Race
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param boats Takes in an array of boats that are participating in the race.
|
|
|
|
|
|
|
|
* @param legs Number of marks in order that the boats pass in order to complete the race.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Race(List<Boat> boats, List<Leg> legs, int raceID, MockOutput mockOutput) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.startingBoats = FXCollections.observableArrayList(boats);
|
|
|
|
public Race(RaceDataSource raceData, MockOutput mockOutput) {
|
|
|
|
this.legs = legs;
|
|
|
|
this.startingBoats = FXCollections.observableArrayList(raceData.getBoats());
|
|
|
|
|
|
|
|
this.legs = raceData.getLegs();
|
|
|
|
this.legs.add(new Leg("Finish", this.legs.size()));
|
|
|
|
this.legs.add(new Leg("Finish", this.legs.size()));
|
|
|
|
this.raceId = raceID;
|
|
|
|
this.raceId = raceData.getRaceId();
|
|
|
|
this.mockOutput = mockOutput;
|
|
|
|
this.mockOutput = mockOutput;
|
|
|
|
|
|
|
|
this.startTime = System.currentTimeMillis() + (Constants.PRE_RACE_WAIT_TIME / this.scaleFactor);
|
|
|
|
this.startTime = System.currentTimeMillis() + (this.PRERACE_TIME / this.scaleFactor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Race(RaceDataSource raceData, MockOutput mockOutput) {
|
|
|
|
|
|
|
|
this(raceData.getBoats(), raceData.getLegs(), raceData.getRaceId(), mockOutput);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Calculates the boats next GPS position based on its distance travelled and heading
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param oldCoordinates GPS coordinates of the boat's starting position
|
|
|
|
|
|
|
|
* @param distanceTravelled distance in nautical miles
|
|
|
|
|
|
|
|
* @param azimuth boat's current direction. Value between -180 and 180
|
|
|
|
|
|
|
|
* @return The boat's new coordinate
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Find new coordinate using current heading and distance
|
|
|
|
|
|
|
|
GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
|
|
|
|
|
|
|
|
//Load start point into calculator
|
|
|
|
|
|
|
|
Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
|
|
|
|
|
|
|
|
geodeticCalculator.setStartingGeographicPoint(startPoint);
|
|
|
|
|
|
|
|
//load direction and distance tranvelled into calculator
|
|
|
|
|
|
|
|
geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
|
|
|
|
|
|
|
|
//get new point
|
|
|
|
|
|
|
|
Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new GPSCoordinate(endPoint.getY(), endPoint.getX());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -91,123 +47,94 @@ public class Race implements Runnable {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
initialiseBoats();
|
|
|
|
initialiseBoats();
|
|
|
|
countdownTimer();
|
|
|
|
countdownTimer.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Starts the heartbeat timer, which sends a heartbeat message every so often (i.e., 5 seconds).
|
|
|
|
* Countdown timer until race starts.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Countdown timer until race starts. Use PRERACE_TIME to set countdown duration.
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected void countdownTimer() {
|
|
|
|
|
|
|
|
AnimationTimer timer = new AnimationTimer() {
|
|
|
|
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
long timeLeft;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(long arg0) {
|
|
|
|
|
|
|
|
timeLeft = startTime - currentTime;
|
|
|
|
|
|
|
|
ArrayList<BoatStatus> boatStatuses = new ArrayList<>();
|
|
|
|
|
|
|
|
//For each boat, we update its position, and generate a BoatLocationMessage.
|
|
|
|
|
|
|
|
for (int i = 0; i < startingBoats.size(); i++) {
|
|
|
|
|
|
|
|
Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size());
|
|
|
|
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), 0);
|
|
|
|
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.PRESTART, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
boatOffset = (boatOffset + 1) % (startingBoats.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (timeLeft <= 60000/scaleFactor && timeLeft > 0) {
|
|
|
|
private AnimationTimer countdownTimer = new AnimationTimer() {
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 2, startTime, 0, 2300, 1, boatStatuses);
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
long timeLeft;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
else if (timeLeft <= 0) {
|
|
|
|
public void handle(long arg0) {
|
|
|
|
countdownFinish = true;
|
|
|
|
timeLeft = startTime - currentTime;
|
|
|
|
if (runRace) {
|
|
|
|
if (timeLeft <= 0) {
|
|
|
|
simulateRace();
|
|
|
|
System.setProperty("javafx.animation.fullspeed", "true");
|
|
|
|
}
|
|
|
|
raceTimer.start();
|
|
|
|
stop();
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 1, startTime, 0, 2300,1, boatStatuses);
|
|
|
|
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
currentTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
timer.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
ArrayList<BoatStatus> boatStatuses = new ArrayList<>();
|
|
|
|
* Starts the Race Simulation, playing the race start to finish with the timescale.
|
|
|
|
for (Boat boat : startingBoats) {
|
|
|
|
* This prints the boats participating, the order that the events occur in time order, and the respective information of the events.
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(),
|
|
|
|
*/
|
|
|
|
boat.getCurrentPosition().getLongitude(), boat.getHeading(), 0);
|
|
|
|
private void simulateRace() {
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.PRESTART, 0));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
System.setProperty("javafx.animation.fullspeed", "true");
|
|
|
|
int raceStatusNumber = timeLeft <= 60000 / scaleFactor && timeLeft > 0? 2 : 1;
|
|
|
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, raceStatusNumber, startTime, 0, 2300, 1, boatStatuses);
|
|
|
|
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
|
|
|
|
|
|
|
|
for (Boat boat : startingBoats) {
|
|
|
|
currentTime = System.currentTimeMillis();
|
|
|
|
boat.setStarted(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new AnimationTimer() {
|
|
|
|
private AnimationTimer raceTimer = new AnimationTimer() {
|
|
|
|
//Start time of loop.
|
|
|
|
//Start time of loop.
|
|
|
|
long timeRaceStarted = System.currentTimeMillis();
|
|
|
|
long timeRaceStarted = System.currentTimeMillis();
|
|
|
|
|
|
|
|
int boatOffset = 0;
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void handle(long arg0) {
|
|
|
|
@Override
|
|
|
|
if (boatsFinished < startingBoats.size()) {
|
|
|
|
public void handle(long arg0) {
|
|
|
|
//Get the current time.
|
|
|
|
if (boatsFinished < startingBoats.size()) {
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
//Get the current time.
|
|
|
|
//Update the total elapsed time.
|
|
|
|
long currentTime = System.currentTimeMillis();
|
|
|
|
totalTimeElapsed = currentTime - timeRaceStarted;
|
|
|
|
//Update the total elapsed time.
|
|
|
|
ArrayList<BoatStatus> boatStatuses = new ArrayList<>();
|
|
|
|
totalTimeElapsed = currentTime - timeRaceStarted;
|
|
|
|
finished = 0;
|
|
|
|
ArrayList<BoatStatus> boatStatuses = new ArrayList<>();
|
|
|
|
//For each boat, we update it's position, and generate a BoatLocationMessage.
|
|
|
|
//For each boat, we update its position, and generate a BoatLocationMessage.
|
|
|
|
for (int i = 0; i < startingBoats.size(); i++) {
|
|
|
|
for (int i = 0; i < startingBoats.size(); i++) {
|
|
|
|
Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size());
|
|
|
|
Boat boat = startingBoats.get((i + boatOffset) % startingBoats.size());
|
|
|
|
if (boat != null) {
|
|
|
|
if (boat != null) {
|
|
|
|
//Update position.
|
|
|
|
//Update position.
|
|
|
|
if (boat.getTimeFinished() < 0) {
|
|
|
|
if (boat.getTimeFinished() < 0) {
|
|
|
|
updatePosition(boat, Math.round(1000 / lastFPS) > 20 ? 15 : Math.round(1000 / lastFPS));
|
|
|
|
updatePosition(boat, 15);
|
|
|
|
checkPosition(boat, totalTimeElapsed);
|
|
|
|
checkPosition(boat, totalTimeElapsed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (boat.getTimeFinished() > 0) {
|
|
|
|
if (boat.getTimeFinished() > 0) {
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity());
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity());
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.FINISHED, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(), BoatStatusEnum.FINISHED, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
finished++;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity());
|
|
|
|
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(),
|
|
|
|
|
|
|
|
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatusEnum.RACING : BoatStatusEnum.DNF, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (startingBoats.size()==finished){
|
|
|
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 4, startTime, 0, 2300, 2, boatStatuses);
|
|
|
|
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stop();
|
|
|
|
mockOutput.parseBoatLocation(boat.getSourceID(), boat.getCurrentPosition().getLatitude(), boat.getCurrentPosition().getLongitude(), boat.getHeading(), boat.getVelocity());
|
|
|
|
|
|
|
|
boatStatuses.add(new BoatStatus(boat.getSourceID(),
|
|
|
|
|
|
|
|
boat.getCurrentLeg().getLegNumber() >= 0 ? BoatStatusEnum.RACING : BoatStatusEnum.DNF, boat.getCurrentLeg().getLegNumber()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boatOffset = (boatOffset + 1) % (startingBoats.size());
|
|
|
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 3, startTime, 0, 2300, 2, boatStatuses);
|
|
|
|
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boatOffset = (boatOffset + 1) % (startingBoats.size());
|
|
|
|
|
|
|
|
RaceStatus raceStatus = new RaceStatus(System.currentTimeMillis(), raceId, 3, startTime, 0, 2300, 2, boatStatuses);
|
|
|
|
|
|
|
|
mockOutput.parseRaceStatus(raceStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public void initialiseBoats() {
|
|
|
|
public void initialiseBoats() {
|
|
|
|
Leg officialStart = legs.get(0);
|
|
|
|
Leg officialStart = legs.get(0);
|
|
|
|
String name = officialStart.getName();
|
|
|
|
String name = officialStart.getName();
|
|
|
|
Marker endMark = officialStart.getEndCompoundMark();
|
|
|
|
Marker endMark = officialStart.getEndCompoundMark();
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<GPSCoordinate> startingPositions = getSpreadStartingPositions();
|
|
|
|
ArrayList<GPSCoordinate> startingPositions = getSpreadStartingPositions();
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < startingBoats.size(); i++) {
|
|
|
|
for (int i = 0; i < startingBoats.size(); i++) {
|
|
|
|
Boat boat = startingBoats.get(i);
|
|
|
|
Boat boat = startingBoats.get(i);
|
|
|
|
if (boat != null) {
|
|
|
|
if (boat != null) {
|
|
|
|
Leg newLeg = new Leg(name, new Marker(startingPositions.get(i)), endMark, 0);
|
|
|
|
Leg newLeg = new Leg(name, new Marker(startingPositions.get(i)), endMark, 0);
|
|
|
|
boat.setCurrentLeg(newLeg);
|
|
|
|
boat.setCurrentLeg(newLeg);
|
|
|
|
|
|
|
|
boat.setVelocity(Constants.TEST_VELOCITIES[i]);
|
|
|
|
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
|
|
|
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
|
|
|
boat.setCurrentPosition(startingPositions.get(i));
|
|
|
|
boat.setCurrentPosition(startingPositions.get(i));
|
|
|
|
boat.setHeading(boat.calculateHeading());
|
|
|
|
boat.setHeading(boat.calculateHeading());
|
|
|
|
@ -249,19 +176,26 @@ public class Race implements Runnable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Sets the chance each boat has of failing at a gate or marker
|
|
|
|
* Calculates the boats next GPS position based on its distance travelled and heading
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param chance percentage chance a boat has of failing per checkpoint.
|
|
|
|
* @param oldCoordinates GPS coordinates of the boat's starting position
|
|
|
|
|
|
|
|
* @param distanceTravelled distance in nautical miles
|
|
|
|
|
|
|
|
* @param azimuth boat's current direction. Value between -180 and 180
|
|
|
|
|
|
|
|
* @return The boat's new coordinate
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected void setDnfChance(int chance) {
|
|
|
|
public static GPSCoordinate calculatePosition(GPSCoordinate oldCoordinates, double distanceTravelled, double azimuth) {
|
|
|
|
if (chance >= 0 && chance <= 100) {
|
|
|
|
|
|
|
|
dnfChance = chance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean doNotFinish() {
|
|
|
|
//Find new coordinate using current heading and distance
|
|
|
|
Random rand = new Random();
|
|
|
|
GeodeticCalculator geodeticCalculator = new GeodeticCalculator();
|
|
|
|
return rand.nextInt(100) < dnfChance;
|
|
|
|
//Load start point into calculator
|
|
|
|
|
|
|
|
Point2D startPoint = new Point2D.Double(oldCoordinates.getLongitude(), oldCoordinates.getLatitude());
|
|
|
|
|
|
|
|
geodeticCalculator.setStartingGeographicPoint(startPoint);
|
|
|
|
|
|
|
|
//load direction and distance travelled into calculator
|
|
|
|
|
|
|
|
geodeticCalculator.setDirection(azimuth, distanceTravelled * Constants.NMToMetersConversion);
|
|
|
|
|
|
|
|
//get new point
|
|
|
|
|
|
|
|
Point2D endPoint = geodeticCalculator.getDestinationGeographicPoint();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new GPSCoordinate(endPoint.getY(), endPoint.getX());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -316,13 +250,19 @@ public class Race implements Runnable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns the boats that have started the race.
|
|
|
|
* Sets the chance each boat has of failing at a gate or marker
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return ObservableList of Boat class that participated in the race.
|
|
|
|
* @param chance percentage chance a boat has of failing per checkpoint.
|
|
|
|
* @see ObservableList
|
|
|
|
|
|
|
|
* @see Boat
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public ObservableList<Boat> getStartingBoats() {
|
|
|
|
protected void setDnfChance(int chance) {
|
|
|
|
return startingBoats;
|
|
|
|
if (chance >= 0 && chance <= 100) {
|
|
|
|
|
|
|
|
dnfChance = chance;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected boolean doNotFinish() {
|
|
|
|
|
|
|
|
Random rand = new Random();
|
|
|
|
|
|
|
|
return rand.nextInt(100) < dnfChance;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|