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) {
|
private void newOptimalVMG(MockBoat boat) {
|
||||||
long tackPeriod = 15000;
|
long tackPeriod = 1000;
|
||||||
|
|
||||||
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
||||||
//Calculate the new VMG.
|
//Calculate the new VMG.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mock.model.commandFactory;
|
|||||||
|
|
||||||
import mock.model.MockBoat;
|
import mock.model.MockBoat;
|
||||||
import mock.model.MockRace;
|
import mock.model.MockRace;
|
||||||
|
import mock.model.VMG;
|
||||||
import shared.model.Bearing;
|
import shared.model.Bearing;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,16 +20,14 @@ public class TackGybeCommand implements Command {
|
|||||||
//The refactoring of MockRace will require changes to be made
|
//The refactoring of MockRace will require changes to be made
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
/*if(boat.getBearing().degrees()>180){
|
||||||
race.getWindDirection(),
|
boat.setBearing(Bearing.fromDegrees(360 - race.getWindDirection().degrees()));
|
||||||
race.getWindSpeed(),
|
} else {
|
||||||
boat.calculateBearingToNextMarker(),
|
boat.setBearing(Bearing.fromDegrees(race.getWindDirection().degrees()));
|
||||||
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);
|
|
||||||
}*/
|
}*/
|
||||||
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