Added checkPosition into MockRace which was removed. Boat now updates legs again.
#Story[1097]
This commit is contained in:
@@ -346,7 +346,7 @@ public class MockRace extends Race {
|
||||
|
||||
this.updateEstimatedTime(boat);
|
||||
}
|
||||
|
||||
checkPosition(boat, totalElapsedMilliseconds);
|
||||
}
|
||||
|
||||
private void newOptimalVMG(MockBoat boat) {
|
||||
@@ -443,6 +443,44 @@ public class MockRace extends Race {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a boat has finished any legs, or has pulled out of race (DNF).
|
||||
* @param boat The boat to check.
|
||||
* @param timeElapsed The total time, in milliseconds, that has elapsed since the race started.
|
||||
*/
|
||||
protected void checkPosition(MockBoat boat, long timeElapsed) {
|
||||
|
||||
//The distance, in nautical miles, within which the boat needs to get in order to consider that it has reached the marker.
|
||||
double epsilonNauticalMiles = 100.0 / Constants.NMToMetersConversion; //100 meters. TODO should be more like 5-10.
|
||||
|
||||
if (boat.calculateDistanceToNextMarker() < epsilonNauticalMiles) {
|
||||
//Boat has reached its target marker, and has moved on to a new leg.
|
||||
|
||||
//Calculate how much the boat overshot the marker by.
|
||||
double overshootMeters = boat.calculateDistanceToNextMarker();
|
||||
|
||||
//Move boat on to next leg.
|
||||
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
||||
boat.setCurrentLeg(nextLeg);
|
||||
|
||||
//Add overshoot distance into the distance travelled for the next leg.
|
||||
boat.setDistanceTravelledInLeg(overshootMeters);
|
||||
|
||||
//Setting a high value for this allows the boat to immediately do a large turn, as it needs to in order to get to the next mark.
|
||||
boat.setTimeSinceTackChange(999999);
|
||||
|
||||
//Check if the boat has finished
|
||||
if (this.isLastLeg(boat.getCurrentLeg())) {
|
||||
//Boat has finished.
|
||||
boat.setTimeFinished(timeElapsed);
|
||||
boat.setCurrentSpeed(0);
|
||||
boat.setStatus(BoatStatusEnum.FINISHED);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return compoundMarks;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user