Fixed sort order for boats in race

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

#story [19]
main
cbt24 9 years ago
parent 419fa8e9fe
commit c8fcada427

@ -24,7 +24,7 @@ public abstract class Race implements Runnable {
protected long totalTimeElapsed; 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 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.setCurrentLeg(nextLeg);
boat.setDistanceTravelledInLeg(boat.getDistanceTravelledInLeg()); 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(); double height = getHeight();
gc.clearRect(0, 0, width, height); 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); this.map = new RaceMap(32.278, -64.863, 32.320989, -64.821, (int)width, (int)height);
if (map == null){ if (map == null){
@ -176,7 +176,7 @@ public class ResizableRaceCanvas extends Canvas {
if (boat != null) { if (boat != null) {
// System.out.print("Drawing Boat At: " + boat.getCurrentPosition()); // System.out.print("Drawing Boat At: " + boat.getCurrentPosition());
displayMark(this.map.convertGPS(boat.getCurrentPosition()), boat.getColour()); 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()));
} }
} }
} }

Loading…
Cancel
Save