Made changes to TackGybeCommand and VMGCommand classes to fit pattern layout.
#Story[1097]
This commit is contained in:
@@ -261,7 +261,6 @@ public class MockRace extends Race {
|
||||
|
||||
//For each boat, we update its position, and generate a BoatLocationMessage.
|
||||
for (MockBoat boat : boats) {
|
||||
|
||||
//If it is still racing, update its position.
|
||||
if (boat.getStatus() == BoatStatusEnum.RACING) {
|
||||
|
||||
@@ -417,6 +416,7 @@ public class MockRace extends Race {
|
||||
*/
|
||||
public boolean improvesVelocity(VMG currentVMG, VMG potentialVMG, Bearing bearingToDestination) {
|
||||
|
||||
|
||||
//Calculates the angle between the boat and its destination.
|
||||
Angle angleBetweenDestAndHeading = Angle.fromDegrees(currentVMG.getBearing().degrees() - bearingToDestination.degrees());
|
||||
|
||||
@@ -478,7 +478,7 @@ public class MockRace extends Race {
|
||||
boat.moveForwards(distanceTravelledMeters);
|
||||
|
||||
|
||||
long tackPeriod = 15000;
|
||||
long tackPeriod = 1000;
|
||||
|
||||
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
||||
//Calculate the new VMG.
|
||||
|
||||
@@ -5,5 +5,5 @@ import mock.model.MockRace;
|
||||
|
||||
public interface CommandFactory {
|
||||
|
||||
void runCommand(MockBoat boat, MockRace race);
|
||||
void execute();
|
||||
}
|
||||
|
||||
@@ -11,8 +11,15 @@ import shared.model.Bearing;
|
||||
public class TackGybeCommand implements CommandFactory {
|
||||
|
||||
//The refactoring of MockRace will require changes to be made
|
||||
|
||||
private MockBoat boat;
|
||||
|
||||
public TackGybeCommand(final MockBoat boat){
|
||||
this.boat = boat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runCommand(MockBoat boat, MockRace race) {
|
||||
public void execute() {
|
||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
||||
race.getWindDirection(),
|
||||
race.getWindSpeed(),
|
||||
@@ -23,5 +30,7 @@ public class TackGybeCommand implements CommandFactory {
|
||||
if(race.improvesVelocity(boatVMG, newVMG, boat.calculateBearingToNextMarker())){
|
||||
boat.setVMG(newVMG);
|
||||
}*/
|
||||
Bearing newBearing = Bearing.fromDegrees(360d - boat.getBearing().degrees());
|
||||
boat.setBearing(newBearing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,16 @@ import shared.model.Bearing;
|
||||
*/
|
||||
public class VMGCommand implements CommandFactory {
|
||||
|
||||
private MockBoat boat;
|
||||
|
||||
public VMGCommand(final MockBoat boat){
|
||||
this.boat = boat;
|
||||
}
|
||||
|
||||
|
||||
//The refactoring of MockRace will require changes to be made
|
||||
@Override
|
||||
public void runCommand(MockBoat boat, MockRace race) {
|
||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
||||
race.getWindDirection(),
|
||||
race.getWindSpeed(),
|
||||
boat.calculateBearingToNextMarker(),
|
||||
Bearing.fromDegrees(0d),
|
||||
Bearing.fromDegrees(359.99999d));
|
||||
boat.setVMG(newVMG);*/
|
||||
public void execute() {
|
||||
//MOCKBOAT SHOULD HAVE PARAMETER TO TOGGLE AUTO-VMG ON AND OFF
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user