Boats stop when the sails are out. Merged dev. #story[1098]
This commit is contained in:
@@ -319,9 +319,9 @@ public class MockRace extends Race {
|
||||
//Checks if the current boat has finished the race or not.
|
||||
boolean finish = this.isLastLeg(boat.getCurrentLeg());
|
||||
|
||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds) {
|
||||
if (!finish && totalElapsedMilliseconds >= updatePeriodMilliseconds && !boat.isSailsOut()) {
|
||||
|
||||
if (boat.getCurrentSpeed() == 0 && !boat.isSailsOut()) {
|
||||
if (boat.getCurrentSpeed() == 0) {
|
||||
newOptimalVMG(boat);
|
||||
boat.setBearing(boat.calculateBearingToNextMarker());
|
||||
}
|
||||
@@ -342,10 +342,12 @@ public class MockRace extends Race {
|
||||
if (boat.isAutoVMG()) {
|
||||
newOptimalVMG(boat);
|
||||
}
|
||||
|
||||
this.updateEstimatedTime(boat);
|
||||
} else {
|
||||
boat.setCurrentSpeed(0);
|
||||
}
|
||||
|
||||
this.updateEstimatedTime(boat);
|
||||
|
||||
}
|
||||
|
||||
private void newOptimalVMG(MockBoat boat) {
|
||||
|
||||
@@ -19,8 +19,8 @@ public class CommandFactory {
|
||||
switch(action) {
|
||||
case AUTO_PILOT: return new VMGCommand(race, boat);
|
||||
case TACK_GYBE: return new TackGybeCommand(race, boat);
|
||||
case SAILS_IN: return new TackGybeCommand(race, boat);
|
||||
case SAILS_OUT: return new TackGybeCommand(race, boat);
|
||||
case SAILS_IN: return new SailsInCommand(race, boat);
|
||||
case SAILS_OUT: return new SailsOutCommand(race, boat);
|
||||
default: return null; // TODO - please please have discussion over what to default to
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@ public class SailsInCommand implements Command {
|
||||
@Override
|
||||
public void execute() {
|
||||
this.boat.setSailsOut(false);
|
||||
System.out.println("hi");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ public class SailsOutCommand implements Command {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
System.out.println("hi");
|
||||
this.boat.setCurrentSpeed(0);
|
||||
this.boat.setSailsOut(true);
|
||||
System.out.println("hi2");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user