diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index cb6d4958..5818eb66 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -461,17 +461,17 @@ public class GameState implements Runnable { // TODO: 15/08/17 remove magic numbers from these equations. if (yacht.getSailIn()) { if (currentVelocity < maxBoatSpeed - 500) { - yacht.changeVelocity(maxBoatSpeed / 100); + yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAcceleration()); } else if (currentVelocity > maxBoatSpeed + 500) { - yacht.changeVelocity(-currentVelocity / 200); + yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration()); } else { - yacht.setCurrentVelocity(maxBoatSpeed); + yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAcceleration()); } } else { if (currentVelocity > 3000) { - yacht.changeVelocity(-currentVelocity / 200); + yacht.changeVelocity((-currentVelocity / 200) * yacht.getAcceleration()); } else if (currentVelocity > 100) { - yacht.changeVelocity(-currentVelocity / 50); + yacht.changeVelocity((-currentVelocity / 50) * yacht.getAcceleration()); } else if (currentVelocity <= 100) { yacht.setCurrentVelocity(0d); } diff --git a/src/main/java/seng302/model/ServerYacht.java b/src/main/java/seng302/model/ServerYacht.java index 6c3ca3dd..29f7eecc 100644 --- a/src/main/java/seng302/model/ServerYacht.java +++ b/src/main/java/seng302/model/ServerYacht.java @@ -11,6 +11,7 @@ import seng302.utilities.GeoUtility; import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; import java.util.HashMap; +import java.util.Objects; /** * Yacht class for the racing boat.

Class created to store more variables (eg. boat statuses) @@ -25,6 +26,7 @@ public class ServerYacht { private String boatType; private Double turnStep = 10.0; private Double maxSpeedMultiplier = 1.0; + private Double acceleration = 1.0; private Integer sourceId; private String hullID; //matches HullNum in the XML spec. private String shortName; @@ -423,10 +425,11 @@ public class ServerYacht { public void setBoatType(String boatType) { BoatMeshType boatMeshType; for (BoatMeshType boatMesh: BoatMeshType.values()) { - if (boatType == boatMesh.toString()) { + if (Objects.equals(boatType, boatMesh.toString())) { boatMeshType = boatMesh; turnStep = boatMeshType.turnStep; maxSpeedMultiplier = boatMeshType.maxSpeedMultiplier; + acceleration = boatMeshType.accelerationMultiplier; } } this.boatType = boatType; @@ -436,6 +439,10 @@ public class ServerYacht { return maxSpeedMultiplier; } + public Double getAcceleration(){ + return acceleration; + } + public String getBoatType() { return boatType; } diff --git a/src/main/java/seng302/visualiser/controllers/dialogs/BoatCustomizeController.java b/src/main/java/seng302/visualiser/controllers/dialogs/BoatCustomizeController.java index 83b1e520..3a71422a 100644 --- a/src/main/java/seng302/visualiser/controllers/dialogs/BoatCustomizeController.java +++ b/src/main/java/seng302/visualiser/controllers/dialogs/BoatCustomizeController.java @@ -56,9 +56,9 @@ public class BoatCustomizeController implements Initializable{ private ClientToServerThread socketThread; private LobbyController lobbyController; private BoatMeshType currentBoat; - private static Double maxSpeedMultiplier = 1.0; - private static Double maxTurnRate = 10.0; - private static Double maxAcceleration = 2.0; + private Double maxSpeedMultiplier = 1.0; + private Double maxTurnRate = 10.0; + private Double maxAcceleration = 1.0; @Override public void initialize(URL location, ResourceBundle resources) { diff --git a/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatMeshType.java b/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatMeshType.java index e7c375e5..2dc55d30 100644 --- a/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatMeshType.java +++ b/src/main/java/seng302/visualiser/fxObjects/assets_3D/BoatMeshType.java @@ -7,11 +7,11 @@ package seng302.visualiser.fxObjects.assets_3D; */ public enum BoatMeshType { - DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false, 1.5, 1.0, 5.0), + DINGHY("dinghy_hull.stl", "dinghy_mast.stl", 1.36653, "dinghy_sail.stl", 1.36653, null, false, 1.7, 1.0, 5.0), CAT_ATE_A_MERINGUE("catamaran_hull.stl", "catamaran_mast.stl", 0.997, "catamaran_sail.stl", - 0.997, null, false, 1.0, 1.0, 10.0), + 0.997, null, false, 1.0, 1.4, 10.0), PIRATE_SHIP("pirateship_hull.stl", "pirateship_mast.stl", -0.5415, "pirateship_mainsail.stl", - -0.5415, "pirateship_frontsail.stl", true, 1.2, 1.0, 7.0); + -0.5415, "pirateship_frontsail.stl", true, 1.2, 1.6, 6.0); final String hullFile, mastFile, sailFile, jibFile; final double mastOffset, sailOffset;