VMGCommand now toggles autoVMG on and off. Linked up observer and observable so the current boat can now be controlled. Fixed autoVMG not working.
#Story[1097]
This commit is contained in:
@@ -350,7 +350,7 @@ public class MockRace extends Race {
|
||||
}
|
||||
|
||||
private void newOptimalVMG(MockBoat boat) {
|
||||
long tackPeriod = 15000;
|
||||
long tackPeriod = 1000;
|
||||
|
||||
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
||||
//Calculate the new VMG.
|
||||
|
||||
@@ -2,6 +2,7 @@ package mock.model.commandFactory;
|
||||
|
||||
import mock.model.MockBoat;
|
||||
import mock.model.MockRace;
|
||||
import mock.model.VMG;
|
||||
import shared.model.Bearing;
|
||||
|
||||
/**
|
||||
@@ -19,16 +20,14 @@ public class TackGybeCommand implements Command {
|
||||
//The refactoring of MockRace will require changes to be made
|
||||
@Override
|
||||
public void execute() {
|
||||
/*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);
|
||||
/*if(boat.getBearing().degrees()>180){
|
||||
boat.setBearing(Bearing.fromDegrees(360 - race.getWindDirection().degrees()));
|
||||
} else {
|
||||
boat.setBearing(Bearing.fromDegrees(race.getWindDirection().degrees()));
|
||||
}*/
|
||||
this.boat.setBearing(Bearing.fromDegrees(360 - boat.getBearing().degrees()));
|
||||
System.out.println(race.getWindDirection().degrees());
|
||||
double angle = Math.max(race.getWindDirection().degrees(), boat.getBearing().degrees()) - Math.min(race.getWindDirection().degrees(), boat.getBearing().degrees());
|
||||
boat.setBearing(Bearing.fromDegrees(angle));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user