Fixed sort order for boats in race

- Sort boats by leg number (preserves order when boats enter shared leg)

#story [19]
This commit is contained in:
cbt24
2017-03-20 17:26:13 +13:00
parent 419fa8e9fe
commit c8fcada427
2 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -24,7 +24,7 @@ public abstract class Race implements Runnable {
protected long totalTimeElapsed;
private int SLEEP_TIME = 25; //time in milliseconds to pause in a paced loop
private int SLEEP_TIME = 50; //time in milliseconds to pause in a paced loop
private int PRERACE_TIME = 10000;//Integer.MAX_VALUE; //time in milliseconds to pause during pre-race
/**
@@ -177,6 +177,7 @@ public abstract class Race implements Runnable {
boat.setCurrentLeg(nextLeg);
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg());
}
FXCollections.sort(startingBoats, (a,b) -> b.getCurrentLeg().getLegNumber() - a.getCurrentLeg().getLegNumber());
}
}
@@ -143,7 +143,7 @@ public class ResizableRaceCanvas extends Canvas {
double height = getHeight();
gc.clearRect(0, 0, width, height);
System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height);
//System.out.println("Race Map Canvas Width: "+ width + ", Height:" + height);
this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int)width, (int)height);
if (map == null){
@@ -176,7 +176,7 @@ public class ResizableRaceCanvas extends Canvas {
if (boat != null) {
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour());
displayText(boat.getName(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
displayText(boat.getName().getValue(), boat.getVelocity(), this.map.convertGPS(boat.getCurrentPosition()));
}
}
}