Boats stop when the sails are out. Merged dev. #story[1098]

main
Joseph Gardner 8 years ago
parent 1302769a50
commit 1a7152f54e

@ -319,9 +319,9 @@ public class MockRace extends Race {
//Checks if the current boat has finished the race or not. //Checks if the current boat has finished the race or not.
boolean finish = this.isLastLeg(boat.getCurrentLeg()); 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); newOptimalVMG(boat);
boat.setBearing(boat.calculateBearingToNextMarker()); boat.setBearing(boat.calculateBearingToNextMarker());
} }
@ -342,10 +342,12 @@ public class MockRace extends Race {
if (boat.isAutoVMG()) { if (boat.isAutoVMG()) {
newOptimalVMG(boat); newOptimalVMG(boat);
} }
} else {
this.updateEstimatedTime(boat); boat.setCurrentSpeed(0);
} }
this.updateEstimatedTime(boat);
} }
private void newOptimalVMG(MockBoat boat) { private void newOptimalVMG(MockBoat boat) {

@ -19,8 +19,8 @@ public class CommandFactory {
switch(action) { switch(action) {
case AUTO_PILOT: return new VMGCommand(race, boat); case AUTO_PILOT: return new VMGCommand(race, boat);
case TACK_GYBE: return new TackGybeCommand(race, boat); case TACK_GYBE: return new TackGybeCommand(race, boat);
case SAILS_IN: return new TackGybeCommand(race, boat); case SAILS_IN: return new SailsInCommand(race, boat);
case SAILS_OUT: return new TackGybeCommand(race, boat); case SAILS_OUT: return new SailsOutCommand(race, boat);
default: return null; // TODO - please please have discussion over what to default to default: return null; // TODO - please please have discussion over what to default to
} }
} }

@ -15,5 +15,6 @@ public class SailsInCommand implements Command {
@Override @Override
public void execute() { public void execute() {
this.boat.setSailsOut(false); this.boat.setSailsOut(false);
System.out.println("hi");
} }
} }

@ -14,8 +14,7 @@ public class SailsOutCommand implements Command {
@Override @Override
public void execute() { public void execute() {
System.out.println("hi");
this.boat.setCurrentSpeed(0);
this.boat.setSailsOut(true); this.boat.setSailsOut(true);
System.out.println("hi2");
} }
} }

Loading…
Cancel
Save