|
|
|
|
@ -174,7 +174,7 @@ public abstract class Race implements Runnable {
|
|
|
|
|
|
|
|
|
|
private boolean doNotFinish() {
|
|
|
|
|
Random rand = new Random();
|
|
|
|
|
return rand.nextInt(100) < 1;
|
|
|
|
|
return rand.nextInt(4) < 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@ -262,8 +262,21 @@ public abstract class Race implements Runnable {
|
|
|
|
|
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg());
|
|
|
|
|
}
|
|
|
|
|
//Update the boat display table in the GUI to reflect the leg change
|
|
|
|
|
updatePositions();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update position of boats in race, no position if on starting leg or DNF.
|
|
|
|
|
*/
|
|
|
|
|
private void updatePositions() {
|
|
|
|
|
FXCollections.sort(startingBoats, (a, b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
|
|
|
|
|
boat.setPosition(startingBoats.indexOf(boat));
|
|
|
|
|
for(BoatInRace boat: startingBoats) {
|
|
|
|
|
if(boat != null) {
|
|
|
|
|
boat.setPosition(Integer.toString(startingBoats.indexOf(boat) + 1));
|
|
|
|
|
if (boat.getCurrentLeg().getName().equals("DNF") || boat.getCurrentLeg().getLegNumber() == 0)
|
|
|
|
|
boat.setPosition("-");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|