diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index b2c2021d..bb6f0c16 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -165,7 +165,7 @@ public class GameState implements Runnable { // printBoatStatus(playerYacht); } - public static void update() { + public void update() { Long timeInterval = System.currentTimeMillis() - previousUpdateTime; previousUpdateTime = System.currentTimeMillis(); for (Yacht yacht : yachts.values()) { diff --git a/src/main/java/seng302/model/Yacht.java b/src/main/java/seng302/model/Yacht.java index 17cdeb87..aba80d1a 100644 --- a/src/main/java/seng302/model/Yacht.java +++ b/src/main/java/seng302/model/Yacht.java @@ -28,11 +28,6 @@ public class Yacht { void notifyLocation(Yacht yacht, double lat, double lon, double heading, double velocity); } - @FunctionalInterface - public interface YachtPositionListener { - void notifyPosition(int position); - } - //BOTH AFAIK private String boatType; private Integer sourceId; @@ -44,6 +39,7 @@ public class Yacht { private Long estimateTimeAtFinish; private Long timeTillNext; private Long markRoundTime; + private CompoundMark nextMark; private Double heading; private Double lat; private Double lon; @@ -62,60 +58,10 @@ public class Yacht { private ReadOnlyDoubleWrapper velocityProperty = new ReadOnlyDoubleWrapper(); private ReadOnlyLongWrapper timeTillNextProperty = new ReadOnlyLongWrapper(); private ReadOnlyLongWrapper timeSinceLastMarkProperty = new ReadOnlyLongWrapper(); -// private ReadOnlyDoubleWrapper headingProperty = new ReadOnlyDoubleWrapper(); -// private ReadOnlyDoubleWrapper latitudeProperty = new ReadOnlyDoubleWrapper(); -// private ReadOnlyDoubleWrapper longitudeProperty = new ReadOnlyDoubleWrapper(); private CompoundMark lastMarkRounded; - private CompoundMark nextMark; private Integer positionInt = 0; private Color colour; - - /** - * @param location latlon location of the boat stored in a geopoint - * @param heading heading of the boat in degrees from 0 to 365 with 0 being north - */ - public Yacht(GeoPoint location, Double heading) { - this.location = location; - this.heading = heading; - this.velocity = 0.0; - this.sailIn = false; - } - - - /** - * Used in EventTest and RaceTest. - * @param boatName boatName - * @param shortName shortName - * @param location location - * @param heading heading - */ - public Yacht(String boatName, String shortName, GeoPoint location, Double heading) { - this.boatName = boatName; - this.shortName = shortName; - this.location = location; - this.heading = heading; - this.velocity = 0.0; - this.sailIn = false; - } - - /** - * Used in BoatGroupTest. - * - * @param boatName The name of the team sailing the boat - * @param boatVelocity The speed of the boat in meters/second - * @param shortName A shorter version of the teams name - * @param id The id for the yacht - */ - public Yacht(String boatName, double boatVelocity, String shortName, int id) { - this.boatName = boatName; - this.velocity = boatVelocity; - this.shortName = shortName; - this.sourceId = id; - this.sailIn = false; - } - - public Yacht(String boatType, Integer sourceId, String hullID, String shortName, String boatName, String country) { this.boatType = boatType; @@ -162,17 +108,7 @@ public class Yacht { } } } -// if (sailIn) { -// Double secondsElapsed = timeInterval / 1000000.0; -// Double windSpeedKnots = GameState.getWindSpeedKnots(); -// Double trueWindAngle = Math.abs(GameState.getWindDirection() - heading); -// Double boatSpeedInKnots = PolarTable.getBoatSpeed(windSpeedKnots, trueWindAngle); -// velocity = boatSpeedInKnots / 1.943844492 * 1000; // TODO: 26/07/17 cir27 - Remove magic number -// Double metersCovered = velocity * secondsElapsed; -// location = getGeoCoordinate(location, heading, metersCovered); -// } else { -// velocity = 0d; -// } + Double metersCovered = velocity * secondsElapsed; location = getGeoCoordinate(location, heading, metersCovered); } @@ -180,7 +116,6 @@ public class Yacht { public void adjustHeading(Double amount) { Double newVal = heading + amount; lastHeading = heading; - // TODO: 24/07/17 wmu16 - '%' in java does remainder, we need modulo. All this must be changed here, this is why we have neg values! heading = (double) Math.floorMod(newVal.longValue(), 360L); } @@ -457,30 +392,6 @@ public class Yacht { this.velocity = velocity; } -// public void updateLatitudeProperty (Double lat) { -// latitudeProperty.set(lat); -// } -// -// public void updateLongitudeProperty (double lon) { -// longitudeProperty.set(lon); -// } -// -// public void updateHeadingProperty (double heading) { -// headingProperty.set(heading); -// } -// -// public ReadOnlyDoubleProperty latitudeProperty () { -// return latitudeProperty.getReadOnlyProperty(); -// } -// -// public ReadOnlyDoubleProperty longitudeProperty () { -// return longitudeProperty.getReadOnlyProperty(); -// } -// -// public ReadOnlyDoubleProperty headingProperty () { -// return headingProperty; -// } - public void updateLocation (double lat, double lon, double heading, double velocity) { this.lat = lat; this.lon = lon; @@ -495,8 +406,4 @@ public class Yacht { public void addLocationListener (YachtLocationListener listener) { locationListeners.add(listener); } - - public void addPositionListener (YachtPositionListener listener) { - - } } diff --git a/src/test/java/seng302/models/YachtTest.java b/src/test/java/seng302/models/YachtTest.java deleted file mode 100644 index ba6de8c0..00000000 --- a/src/test/java/seng302/models/YachtTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package seng302.models; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Before; -import seng302.model.PolarTable; -import seng302.model.Yacht; -import seng302.model.GeoPoint; - -public class YachtTest { - - Double windDir; - Double windSpd; - List yachts = new ArrayList<>(); - - @Before - public void setUp() { - PolarTable.parsePolarFile(getClass().getResourceAsStream("/config/acc_polars.csv")); - windDir = 90d; - windSpd = 10d; - - yachts.add(new Yacht("Yacht 1", "Y1", new GeoPoint(-30.0, 20.0), 160.0)); - yachts.add(new Yacht("Yacht 2", "Y2", new GeoPoint(-40.0, -20.0), 100.0)); - yachts.add(new Yacht("Yacht 3", "Y3", new GeoPoint(-35.0, -15.5), 20.0)); - } - - -}