|
|
|
|
@ -4,18 +4,17 @@ import javafx.animation.AnimationTimer;
|
|
|
|
|
import network.Messages.BoatLocation;
|
|
|
|
|
import network.Messages.BoatStatus;
|
|
|
|
|
import network.Messages.Enums.BoatStatusEnum;
|
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
|
import network.Messages.LatestMessages;
|
|
|
|
|
import network.Messages.RaceStatus;
|
|
|
|
|
import network.Utils.AC35UnitConverter;
|
|
|
|
|
import shared.dataInput.BoatDataSource;
|
|
|
|
|
import shared.dataInput.RaceDataSource;
|
|
|
|
|
import network.Messages.Enums.RaceStatusEnum;
|
|
|
|
|
import shared.dataInput.RegattaDataSource;
|
|
|
|
|
import shared.model.*;
|
|
|
|
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
|
|
import java.time.temporal.TemporalUnit;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import static java.lang.Math.cos;
|
|
|
|
|
@ -771,6 +770,68 @@ public class MockRace extends Race {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks to be run on boats rounding marks on the port side
|
|
|
|
|
* @param boat the boat that is rounding a mark
|
|
|
|
|
* @param roundingChecks the checks to run
|
|
|
|
|
*/
|
|
|
|
|
private void boatRoundingCheckPort(MockBoat boat, List<GPSCoordinate> roundingChecks){
|
|
|
|
|
//boats must pass all checks in order to round a mark
|
|
|
|
|
switch (boat.getRoundingStatus()) {
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
|
|
|
|
|
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition())) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1://has been parallel to the mark
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
|
|
|
|
|
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
|
|
|
|
|
roundingChecks.get(1), boat.getCurrentPosition())) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2://has traveled 180 degrees around the mark
|
|
|
|
|
//Move boat on to next leg.
|
|
|
|
|
boat.resetRoundingStatus();
|
|
|
|
|
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
|
|
|
|
boat.setCurrentLeg(nextLeg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks to be run on boats rounding marks on the starboard side
|
|
|
|
|
* @param boat the boat that is rounding a mark
|
|
|
|
|
* @param roundingChecks the checks to run
|
|
|
|
|
*/
|
|
|
|
|
private void boatRoundingCheckStarboard(MockBoat boat, List<GPSCoordinate> roundingChecks){
|
|
|
|
|
//boats must pass all checks in order to round a mark
|
|
|
|
|
switch (boat.getRoundingStatus()) {
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isStarboardSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
|
|
|
|
|
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition())) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1://has been parallel to the mark
|
|
|
|
|
if (boat.isStarboardSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
|
|
|
|
|
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
|
|
|
|
|
roundingChecks.get(1), boat.getCurrentPosition())) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2://has traveled 180 degrees around the mark
|
|
|
|
|
//Move boat on to next leg.
|
|
|
|
|
boat.resetRoundingStatus();
|
|
|
|
|
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
|
|
|
|
boat.setCurrentLeg(nextLeg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if a boat has finished any legs, or has pulled out of race (DNF).
|
|
|
|
|
* @param boat The boat to check.
|
|
|
|
|
@ -798,28 +859,16 @@ public class MockRace extends Race {
|
|
|
|
|
GPSCoordinate roundCheck2 = GPSCoordinate.calculateNewPosition(startDirectionLinePoint,
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()));
|
|
|
|
|
|
|
|
|
|
List<GPSCoordinate> roundingChecks = new ArrayList<GPSCoordinate>(Arrays.asList(roundCheck1, roundCheck2));
|
|
|
|
|
|
|
|
|
|
//boats must pass all checks in order to round a mark
|
|
|
|
|
switch (boat.getRoundingStatus()){
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
|
|
|
|
|
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
|
|
|
|
|
roundCheck1, boat.getCurrentPosition())){
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1://has been parallel to the mark
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
|
|
|
|
|
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
|
|
|
|
|
roundCheck2, boat.getCurrentPosition())){
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
switch (boat.getCurrentLeg().getEndCompoundMark().getRoundingType()) {
|
|
|
|
|
case SP://Not yet implemented so these gates will be rounded port side
|
|
|
|
|
case Port:
|
|
|
|
|
boatRoundingCheckPort(boat, roundingChecks);
|
|
|
|
|
break;
|
|
|
|
|
case 2://has traveled 180 degrees around the mark
|
|
|
|
|
//Move boat on to next leg.
|
|
|
|
|
boat.resetRoundingStatus();
|
|
|
|
|
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
|
|
|
|
boat.setCurrentLeg(nextLeg);
|
|
|
|
|
case PS://not yet implemented so these gates will be rounded starboard side
|
|
|
|
|
case Starboard:
|
|
|
|
|
boatRoundingCheckStarboard(boat, roundingChecks);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|