|
|
|
@@ -6,6 +6,7 @@ import network.Messages.LatestMessages;
|
|
|
|
|
import shared.dataInput.BoatDataSource;
|
|
|
|
|
import shared.dataInput.RaceDataSource;
|
|
|
|
|
import shared.dataInput.RegattaDataSource;
|
|
|
|
|
import shared.enums.RoundingType;
|
|
|
|
|
import shared.model.*;
|
|
|
|
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
|
@@ -473,26 +474,27 @@ public class MockRace extends Race {
|
|
|
|
|
|
|
|
|
|
//boolean for if boat has to/needs to pass through a gate
|
|
|
|
|
boolean gateCheck = boat.getCurrentLeg().getEndCompoundMark().getMark2() == null || boat.isBetweenGate(boat.getCurrentLeg().getEndCompoundMark());
|
|
|
|
|
Mark roundingMark = boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing);
|
|
|
|
|
|
|
|
|
|
switch (boat.getRoundingStatus()) {
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing)) &&
|
|
|
|
|
GPSCoordinate.passesLine(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing).getPosition(),
|
|
|
|
|
if (boat.isPortSide(roundingMark) &&
|
|
|
|
|
GPSCoordinate.passesLine(roundingMark.getPosition(),
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition(), legBearing) &&
|
|
|
|
|
gateCheck) {
|
|
|
|
|
gateCheck && boat.isBetweenGate(roundingMark, Mark.tempMark(roundingChecks.get(0)))) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1://has been parallel to the mark
|
|
|
|
|
// System.out.println("round 1");
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing)) &&
|
|
|
|
|
GPSCoordinate.passesLine(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing).getPosition(),
|
|
|
|
|
roundingChecks.get(1), boat.getCurrentPosition(), Bearing.fromDegrees(legBearing.degrees() - 90))) {//negative 90 from bearing because of port rounding
|
|
|
|
|
case 1://has been parallel to the mark;
|
|
|
|
|
if (boat.isPortSide(roundingMark) &&
|
|
|
|
|
GPSCoordinate.passesLine(roundingMark.getPosition(),
|
|
|
|
|
roundingChecks.get(1), boat.getCurrentPosition(),
|
|
|
|
|
Bearing.fromDegrees(legBearing.degrees() - 90)) &&//negative 90 from bearing because of port rounding
|
|
|
|
|
boat.isBetweenGate(roundingMark, Mark.tempMark(roundingChecks.get(1)))) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2://has traveled 180 degrees around the mark
|
|
|
|
|
// System.out.println("round 2");
|
|
|
|
|
//Move boat on to next leg.
|
|
|
|
|
boat.resetRoundingStatus();
|
|
|
|
|
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
|
|
|
|
@@ -512,20 +514,23 @@ public class MockRace extends Race {
|
|
|
|
|
|
|
|
|
|
//boolean for if boat has to/needs to pass through a gate
|
|
|
|
|
boolean gateCheck = boat.getCurrentLeg().getEndCompoundMark().getMark2() == null || boat.isBetweenGate(boat.getCurrentLeg().getEndCompoundMark());
|
|
|
|
|
Mark roundingMark = boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing);
|
|
|
|
|
|
|
|
|
|
switch (boat.getRoundingStatus()) {
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isStarboardSide(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing)) &&
|
|
|
|
|
GPSCoordinate.passesLine(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing).getPosition(),
|
|
|
|
|
if (boat.isStarboardSide(roundingMark) &&
|
|
|
|
|
GPSCoordinate.passesLine(roundingMark.getPosition(),
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition(), legBearing) &&
|
|
|
|
|
gateCheck) {
|
|
|
|
|
gateCheck &&
|
|
|
|
|
boat.isBetweenGate(roundingMark, Mark.tempMark(roundingChecks.get(0)))) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 1://has been parallel to the mark
|
|
|
|
|
if (boat.isStarboardSide(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing)) &&
|
|
|
|
|
GPSCoordinate.passesLine(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing).getPosition(),
|
|
|
|
|
roundingChecks.get(1), boat.getCurrentPosition(), Bearing.fromDegrees(legBearing.degrees() + 90))) {//positive 90 from bearing because of starboard rounding
|
|
|
|
|
if (boat.isStarboardSide(roundingMark) &&
|
|
|
|
|
GPSCoordinate.passesLine(roundingMark.getPosition(),
|
|
|
|
|
roundingChecks.get(1), boat.getCurrentPosition(), Bearing.fromDegrees(legBearing.degrees() + 90)) && //positive 90 from bearing because of starboard rounding
|
|
|
|
|
boat.isBetweenGate(roundingMark, Mark.tempMark(roundingChecks.get(1)))) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
@@ -556,8 +561,17 @@ public class MockRace extends Race {
|
|
|
|
|
|
|
|
|
|
//use the direction line to create three invisible points that act as crossover lines a boat must cross
|
|
|
|
|
//to round a mark
|
|
|
|
|
|
|
|
|
|
double bearingToAdd;
|
|
|
|
|
if (boat.getCurrentLeg().getEndCompoundMark().getRoundingType() == RoundingType.Port ||
|
|
|
|
|
boat.getCurrentLeg().getEndCompoundMark().getRoundingType() == RoundingType.SP){
|
|
|
|
|
bearingToAdd = 90;
|
|
|
|
|
}else{
|
|
|
|
|
bearingToAdd = -90;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPSCoordinate roundCheck1 = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees() - 90));//adding 90 so the check line is parallel
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees() + bearingToAdd));
|
|
|
|
|
|
|
|
|
|
GPSCoordinate roundCheck2;
|
|
|
|
|
try{
|
|
|
|
@@ -568,15 +582,12 @@ public class MockRace extends Race {
|
|
|
|
|
Bearing bearingOfNextDirectionLine = GPSCoordinate.calculateBearing(startNextDirectionLinePoint, endNextDirectionLinePoint);
|
|
|
|
|
|
|
|
|
|
roundCheck2 = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees() + 90));
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees() + bearingToAdd));
|
|
|
|
|
}catch(NullPointerException e){
|
|
|
|
|
//this is caused by the last leg not being having a leg after it
|
|
|
|
|
roundCheck2 = roundCheck1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GPSCoordinate> roundingChecks = new ArrayList<GPSCoordinate>(Arrays.asList(roundCheck1, roundCheck2));
|
|
|
|
|
|
|
|
|
|
switch (boat.getCurrentLeg().getEndCompoundMark().getRoundingType()) {
|
|
|
|
|