Merge branch 'master' into story68
-updated port and starboard boat checks -added gps method to check if on correct side of a line -updated pos check method to make boats round marks with the new tech # Conflicts: # racevisionGame/src/main/java/mock/app/ConnectionAcceptor.java # racevisionGame/src/main/java/mock/app/Event.java # racevisionGame/src/main/java/mock/model/commandFactory/TackGybeCommand.java # racevisionGame/src/main/java/mock/model/commandFactory/VMGCommand.java
This commit is contained in:
@@ -33,7 +33,7 @@ public class MockBoat extends Boat {
|
||||
/**
|
||||
* Stores whether the boat is on autoVMG or not
|
||||
*/
|
||||
private boolean autoVMG = true;
|
||||
private boolean autoVMG = false;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -649,4 +649,4 @@ public class MockRace extends Race {
|
||||
public List<CompoundMark> getCompoundMarks() {
|
||||
return compoundMarks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@ package mock.model;
|
||||
|
||||
import network.Messages.BoatLocation;
|
||||
import network.Messages.BoatStatus;
|
||||
import network.Messages.Enums.BoatLocationDeviceEnum;
|
||||
import network.Messages.LatestMessages;
|
||||
import network.Messages.RaceStatus;
|
||||
import network.Utils.AC35UnitConverter;
|
||||
import shared.model.Bearing;
|
||||
import shared.model.CompoundMark;
|
||||
import shared.model.Constants;
|
||||
import shared.model.Mark;
|
||||
@@ -47,7 +49,9 @@ public class RaceServer {
|
||||
mark.getPosition().getLatitude(),
|
||||
mark.getPosition().getLongitude(),
|
||||
this.boatLocationSequenceNumber,
|
||||
0, 0,
|
||||
BoatLocationDeviceEnum.Mark,
|
||||
Bearing.fromDegrees(0),
|
||||
0,
|
||||
race.getRaceClock().getCurrentTimeMilli());
|
||||
|
||||
//Iterates the sequence number.
|
||||
@@ -99,7 +103,8 @@ public class RaceServer {
|
||||
boat.getCurrentPosition().getLatitude(),
|
||||
boat.getCurrentPosition().getLongitude(),
|
||||
this.boatLocationSequenceNumber,
|
||||
boat.getBearing().degrees(),
|
||||
BoatLocationDeviceEnum.RacingYacht,
|
||||
boat.getBearing(),
|
||||
boat.getCurrentSpeed(),
|
||||
race.getRaceClock().getCurrentTimeMilli());
|
||||
|
||||
@@ -133,19 +138,17 @@ public class RaceServer {
|
||||
}
|
||||
|
||||
|
||||
//Convert wind direction and speed to ints. //TODO this conversion should be done inside the racestatus class.
|
||||
int windDirectionInt = AC35UnitConverter.encodeHeading(race.getWindDirection().degrees());
|
||||
int windSpeedInt = (int) (race.getWindSpeed() * Constants.KnotsToMMPerSecond);
|
||||
|
||||
//Create race status object, and send it.
|
||||
RaceStatus raceStatus = new RaceStatus(
|
||||
RaceStatus.currentMessageVersionNumber,
|
||||
System.currentTimeMillis(),
|
||||
race.getRaceId(),
|
||||
race.getRaceStatusEnum().getValue(),
|
||||
race.getRaceStatusEnum(),
|
||||
race.getRaceClock().getStartingTimeMilli(),
|
||||
windDirectionInt,
|
||||
windSpeedInt,
|
||||
race.getRaceType().getValue(),
|
||||
race.getWindDirection(),
|
||||
race.getWindSpeed(),
|
||||
race.getRaceType(),
|
||||
boatStatuses);
|
||||
|
||||
this.latestMessages.setRaceStatus(raceStatus);
|
||||
|
||||
@@ -2,8 +2,6 @@ package mock.model.commandFactory;
|
||||
|
||||
import mock.model.MockBoat;
|
||||
import mock.model.MockRace;
|
||||
import mock.model.VMG;
|
||||
import shared.model.Bearing;
|
||||
|
||||
/**
|
||||
* Created by David on 2/08/2017.
|
||||
@@ -20,30 +18,18 @@ public class TackGybeCommand implements Command {
|
||||
//The refactoring of MockRace will require changes to be made
|
||||
@Override
|
||||
public void execute() {
|
||||
/*if(boat.getBearing().degrees()>180){
|
||||
boat.setBearing(Bearing.fromDegrees(360 - race.getWindDirection().degrees()));
|
||||
} else {
|
||||
boat.setBearing(Bearing.fromDegrees(race.getWindDirection().degrees()));
|
||||
|
||||
boat.setAutoVMG(false);
|
||||
|
||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
||||
race.getWindDirection(),
|
||||
race.getWindSpeed(),
|
||||
boat.calculateBearingToNextMarker(),
|
||||
Bearing.fromDegrees(0d),
|
||||
Bearing.fromDegrees(359.99999d));
|
||||
VMG boatVMG = new VMG(boat.getCurrentSpeed(), boat.getBearing());
|
||||
if(race.improvesVelocity(boatVMG, newVMG, boat.calculateBearingToNextMarker())){
|
||||
boat.setVMG(newVMG);
|
||||
}*/
|
||||
/*double angle = Math.max(race.getWindDirection().degrees(), boat.getBearing().degrees()) - Math.min(race.getWindDirection().degrees(), boat.getBearing().degrees());
|
||||
boat.setBearing(Bearing.fromDegrees(angle));*/
|
||||
double boatAngle = boat.getBearing().degrees();
|
||||
double windAngle =race.getWindDirection().degrees();
|
||||
double differenceAngle = calcDistance(boatAngle, windAngle);
|
||||
double angleA = windAngle + differenceAngle;
|
||||
double angleB = windAngle - differenceAngle;
|
||||
if(angleA % 360 == boatAngle){
|
||||
boat.setBearing(Bearing.fromDegrees(angleB));
|
||||
} else {
|
||||
boat.setBearing(Bearing.fromDegrees(angleA));
|
||||
}
|
||||
}
|
||||
|
||||
public double calcDistance(double degreeA, double degreeB){
|
||||
double phi = Math.abs(degreeB - degreeA) % 360;
|
||||
double distance = phi > 180 ? 360 - phi : phi;
|
||||
return distance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,13 @@ public class VMGCommand implements Command {
|
||||
//The refactoring of MockRace will require changes to be made
|
||||
@Override
|
||||
public void execute() {
|
||||
if (boat.getAutoVMG()){
|
||||
boat.setAutoVMG(false);
|
||||
System.out.println("Auto VMG off!");
|
||||
} else {
|
||||
boat.setAutoVMG(true);
|
||||
System.out.println("Auto VMG on!");
|
||||
}
|
||||
boat.setAutoVMG(true);
|
||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
||||
race.getWindDirection(),
|
||||
race.getWindSpeed(),
|
||||
boat.calculateBearingToNextMarker(),
|
||||
Bearing.fromDegrees(0d),
|
||||
Bearing.fromDegrees(359.99999d));
|
||||
boat.setVMG(newVMG);*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,17 @@ public class WindCommand implements Command {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
boat.setAutoVMG(false);
|
||||
|
||||
double wind = race.getWindDirection().degrees();
|
||||
double heading = boat.getBearing().degrees();
|
||||
|
||||
double offset = 3.0;
|
||||
|
||||
offset *= direction;
|
||||
if(wind - heading < 0) offset *= -1;
|
||||
double headWindDelta = wind - heading;
|
||||
if ((headWindDelta < 0) || (headWindDelta > 180)) offset *= -1;
|
||||
|
||||
boat.setBearing(Bearing.fromDegrees(heading + offset));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user