Merge branch 'RaceFactory' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into RaceFactory
This commit is contained in:
@@ -66,7 +66,6 @@ public class MockBoat extends Boat {
|
||||
|
||||
//Calculate bearing.
|
||||
Bearing bearing = GPSCoordinate.calculateBearing(currentPosition, nextMarkerPosition);
|
||||
|
||||
return bearing;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import shared.model.*;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.*;
|
||||
|
||||
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.
|
||||
* @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.
|
||||
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.
|
||||
boat.moveForwards(distanceTravelledMeters);
|
||||
|
||||
|
||||
long tackPeriod = 15000;
|
||||
|
||||
if (boat.getTimeSinceTackChange() > tackPeriod) {
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
package mock.model.commandFactory;
|
||||
|
||||
import mock.model.MockBoat;
|
||||
import mock.model.MockRace;
|
||||
|
||||
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.
|
||||
*/
|
||||
public static final long RacePreStartTime = 3 * 60 * 1000;
|
||||
public static final long RacePreStartTime = 1 * 10 * 1000;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user