diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index 14550218..5943625d 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -433,7 +433,7 @@ public class GameState implements Runnable { * @param yacht The yacht to disable */ private void boatTempShutDown(ServerYacht yacht) { - yacht.setSpeedMultiplier(0); + yacht.setPowerUpSpeedMultiplier(0); Timer shutDownTimer = new Timer("Shutdown Timer"); shutDownTimer.schedule(new TimerTask() { @Override @@ -542,13 +542,13 @@ public class GameState implements Runnable { TokenType tokenType = collidedToken.getTokenType(); switch (tokenType) { case BOOST: - yacht.setSpeedMultiplier(VELOCITY_BOOST_MULTIPLIER); + yacht.setPowerUpSpeedMultiplier(VELOCITY_BOOST_MULTIPLIER); break; case BUMPER: // TODO: 22/09/17 wmu16 break; case HANDLING: - yacht.setHandlingMultiplier(HANDLING_BOOST_MULTIPLIER); + yacht.setPowerUpHandlingMultiplier(HANDLING_BOOST_MULTIPLIER); break; case WIND_WALKER: // TODO: 22/09/17 wmu16 @@ -634,23 +634,29 @@ public class GameState implements Runnable { Double trueWindAngle = Math.abs(windDirection - yacht.getHeading()); Double boatSpeedInKnots = PolarTable.getBoatSpeed(getWindSpeedKnots(), trueWindAngle); Double maxBoatSpeed = - GeoUtility.knotsToMMS(boatSpeedInKnots) * serverSpeedMultiplier * yacht.getSpeedMultiplier() * yacht.getMaxSpeedMultiplier(); + GeoUtility.knotsToMMS(boatSpeedInKnots) * serverSpeedMultiplier * yacht + .getPowerUpSpeedMultiplier() * yacht.getBoatTypeSpeedMultiplier(); Double currentVelocity = yacht.getCurrentVelocity(); // TODO: 15/08/17 remove magic numbers from these equations. if (yacht.getSailIn()) { if (currentVelocity < maxBoatSpeed - 500) { - yacht.changeVelocity((maxBoatSpeed / 100) * yacht.getAccelerationMultiplier()); + yacht.changeVelocity( + (maxBoatSpeed / 100) * yacht.getBoatTypeAccelerationMultiplier()); } else if (currentVelocity > maxBoatSpeed + 500) { - yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier()); + yacht.changeVelocity( + (-currentVelocity / 200) * yacht.getBoatTypeAccelerationMultiplier()); } else { - yacht.setCurrentVelocity((maxBoatSpeed) * yacht.getAccelerationMultiplier()); + yacht + .setCurrentVelocity((maxBoatSpeed) * yacht.getBoatTypeAccelerationMultiplier()); } } else { if (currentVelocity > 3000) { - yacht.changeVelocity((-currentVelocity / 200) * yacht.getAccelerationMultiplier()); + yacht.changeVelocity( + (-currentVelocity / 200) * yacht.getBoatTypeAccelerationMultiplier()); } else if (currentVelocity > 100) { - yacht.changeVelocity((-currentVelocity / 50) * yacht.getAccelerationMultiplier()); + yacht.changeVelocity( + (-currentVelocity / 50) * yacht.getBoatTypeAccelerationMultiplier()); } 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 d1f36c7c..ee692d63 100644 --- a/src/main/java/seng302/model/ServerYacht.java +++ b/src/main/java/seng302/model/ServerYacht.java @@ -11,10 +11,6 @@ import seng302.utilities.GeoUtility; import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; import java.util.HashMap; -import java.util.Objects; -import java.util.Observable; -import java.util.Observer; -import seng302.visualiser.fxObjects.assets_3D.BoatMeshType; /** * Yacht class for the racing boat.
Class created to store more variables (eg. boat statuses) @@ -28,9 +24,9 @@ public class ServerYacht { //Boat info private BoatMeshType boatType; private Double turnStep = 5.0; - private Double maxSpeedMultiplier = 1.0; - private Double turnStepMultiplier = 1.0; - private Double accelerationMultiplier = 1.0; + private Double boatTypeSpeedMultiplier = 1.0; + private Double boatTypeTurnStepMultiplier = 1.0; + private Double boatTypeAccelerationMultiplier = 1.0; private Integer sourceId; private String hullID; //matches HullNum in the XML spec. private String shortName; @@ -60,8 +56,8 @@ public class ServerYacht { //PowerUp private TokenType powerUp; private Long powerUpStartTime; - private Integer speedMultiplier; - private Integer handlingMultiplier; + private Integer powerUpSpeedMultiplier; + private Integer powerUpHandlingMultiplier; public ServerYacht(BoatMeshType boatType, Integer sourceId, String hullID, String shortName, @@ -83,8 +79,8 @@ public class ServerYacht { this.legNumber = 0; this.boatColor = Colors.getColor(sourceId - 1); this.powerUp = null; - this.speedMultiplier = 1; - this.handlingMultiplier = 1; + this.powerUpSpeedMultiplier = 1; + this.powerUpHandlingMultiplier = 1; this.hasEnteredRoundingZone = false; this.hasPassedLine = false; @@ -122,8 +118,8 @@ public class ServerYacht { public void powerDown() { this.powerUp = null; - this.speedMultiplier = 1; - this.handlingMultiplier = 1; + this.powerUpSpeedMultiplier = 1; + this.powerUpHandlingMultiplier = 1; } public Long getPowerUpStartTime() { @@ -140,7 +136,7 @@ public class ServerYacht { * @param amount the amount by which to adjust the boat heading. */ public void adjustHeading(Double amount) { - Double newVal = heading + amount * handlingMultiplier * turnStepMultiplier; + Double newVal = heading + amount * powerUpHandlingMultiplier * boatTypeTurnStepMultiplier; lastHeading = heading; heading = (double) Math.floorMod(newVal.longValue(), 360L); } @@ -433,18 +429,18 @@ public class ServerYacht { } public void setBoatType(BoatMeshType boatType) { - this.accelerationMultiplier = boatType.accelerationMultiplier; - this.maxSpeedMultiplier = boatType.maxSpeedMultiplier; - this.turnStepMultiplier = boatType.turnStep; + this.boatTypeAccelerationMultiplier = boatType.accelerationMultiplier; + this.boatTypeSpeedMultiplier = boatType.maxSpeedMultiplier; + this.boatTypeTurnStepMultiplier = boatType.turnStep; this.boatType = boatType; } - public Double getMaxSpeedMultiplier() { - return maxSpeedMultiplier; + public Double getBoatTypeSpeedMultiplier() { + return boatTypeSpeedMultiplier; } - public Double getAccelerationMultiplier(){ - return accelerationMultiplier; + public Double getBoatTypeAccelerationMultiplier() { + return boatTypeAccelerationMultiplier; } @@ -452,19 +448,19 @@ public class ServerYacht { return boatType; } - public Integer getSpeedMultiplier() { - return speedMultiplier; + public Integer getPowerUpSpeedMultiplier() { + return powerUpSpeedMultiplier; } - public void setSpeedMultiplier(Integer speedMultiplier) { - this.speedMultiplier = speedMultiplier; + public void setPowerUpSpeedMultiplier(Integer powerUpSpeedMultiplier) { + this.powerUpSpeedMultiplier = powerUpSpeedMultiplier; } - public Integer getHandlingMultiplier() { - return handlingMultiplier; + public Integer getPowerUpHandlingMultiplier() { + return powerUpHandlingMultiplier; } - public void setHandlingMultiplier(Integer handlingMultiplier) { - this.handlingMultiplier = handlingMultiplier; + public void setPowerUpHandlingMultiplier(Integer powerUpHandlingMultiplier) { + this.powerUpHandlingMultiplier = powerUpHandlingMultiplier; } }