Merge branch 'RaceFactory' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into RaceFactory

main
Connor Taylor-Brown 8 years ago
commit c8621a7be5

@ -66,7 +66,6 @@ public class MockBoat extends Boat {
//Calculate bearing. //Calculate bearing.
Bearing bearing = GPSCoordinate.calculateBearing(currentPosition, nextMarkerPosition); Bearing bearing = GPSCoordinate.calculateBearing(currentPosition, nextMarkerPosition);
return bearing; return bearing;
} }

@ -10,6 +10,7 @@ import shared.model.*;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.*; import java.util.*;
import static java.lang.Math.cos; import static java.lang.Math.cos;
@ -269,7 +270,7 @@ public class MockRace extends Race {
* @param bearingToDestination The bearing between the boat and its destination. * @param bearingToDestination The bearing between the boat and its destination.
* @return True if the new VMG is improves velocity, false otherwise. * @return True if the new VMG is improves velocity, false otherwise.
*/ */
private boolean improvesVelocity(VMG currentVMG, VMG potentialVMG, Bearing bearingToDestination) { public boolean improvesVelocity(VMG currentVMG, VMG potentialVMG, Bearing bearingToDestination) {
//Calculates the angle between the boat and its destination. //Calculates the angle between the boat and its destination.
Angle angleBetweenDestAndHeading = Angle.fromDegrees(currentVMG.getBearing().degrees() - bearingToDestination.degrees()); Angle angleBetweenDestAndHeading = Angle.fromDegrees(currentVMG.getBearing().degrees() - bearingToDestination.degrees());
@ -331,6 +332,7 @@ public class MockRace extends Race {
//Move the boat forwards that many meters, and advances its time counters by enough milliseconds. //Move the boat forwards that many meters, and advances its time counters by enough milliseconds.
boat.moveForwards(distanceTravelledMeters); boat.moveForwards(distanceTravelledMeters);
long tackPeriod = 15000; long tackPeriod = 15000;
if (boat.getTimeSinceTackChange() > tackPeriod) { if (boat.getTimeSinceTackChange() > tackPeriod) {

@ -1,4 +1,9 @@
package mock.model.commandFactory; package mock.model.commandFactory;
import mock.model.MockBoat;
import mock.model.MockRace;
public interface CommandFactory { public interface CommandFactory {
void runCommand(MockBoat boat, MockRace race);
} }

@ -0,0 +1,27 @@
package mock.model.commandFactory;
import mock.model.MockBoat;
import mock.model.MockRace;
import mock.model.VMG;
import shared.model.Bearing;
/**
* Created by David on 2/08/2017.
*/
public class TackGybeCommand implements CommandFactory {
//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));
VMG boatVMG = new VMG(boat.getCurrentSpeed(), boat.getBearing());
if(race.improvesVelocity(boatVMG, newVMG, boat.calculateBearingToNextMarker())){
boat.setVMG(newVMG);
}*/
}
}

@ -0,0 +1,24 @@
package mock.model.commandFactory;
import mock.model.MockBoat;
import mock.model.MockRace;
import mock.model.VMG;
import shared.model.Bearing;
/**
* Created by David on 2/08/2017.
*/
public class VMGCommand implements CommandFactory {
//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);*/
}
}

@ -38,7 +38,7 @@ public class Constants {
/** /**
* The race pre-start time, in milliseconds. 3 minutes. * The race pre-start time, in milliseconds. 3 minutes.
*/ */
public static final long RacePreStartTime = 3 * 60 * 1000; public static final long RacePreStartTime = 1 * 10 * 1000;
/** /**

Loading…
Cancel
Save