From 0d0b2e59d5f80652cbb62fa45e2b87a5143d29f8 Mon Sep 17 00:00:00 2001 From: William Muir Date: Tue, 29 Aug 2017 21:40:25 +1200 Subject: [PATCH] WIP: Tokens works well with collection. Dissapear upon picking up across all clients. Still bug with mark ordering and arrows :/ #story[1250] --- .../java/seng302/gameServer/GameState.java | 18 ++++++++++-------- .../seng302/gameServer/MainServerThread.java | 2 +- .../seng302/gameServer/MessageFactory.java | 8 +++++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index 654a57b4..9ce3c409 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -54,18 +54,18 @@ public class GameState implements Runnable { private Logger logger = LoggerFactory.getLogger(GameState.class); - public static final int WARNING_TIME = 10 * -1000; - public static final int PREPATORY_TIME = 5 * -1000; - public static final int TIME_TILL_START = 10 * 1000; - public static Integer MAX_PLAYERS = 8; + static final int WARNING_TIME = 10 * -1000; + static final int PREPATORY_TIME = 5 * -1000; + private static final int TIME_TILL_START = 10 * 1000; + static Integer MAX_PLAYERS = 8; private static final Integer STATE_UPDATES_PER_SECOND = 60; - public static Double ROUNDING_DISTANCE = 50d; // TODO: 14/08/17 wmu16 - Look into this value further - public static final Double MARK_COLLISION_DISTANCE = 15d; + private static Double ROUNDING_DISTANCE = 50d; // TODO: 14/08/17 wmu16 - Look into this value further + private static final Double MARK_COLLISION_DISTANCE = 15d; public static final Double YACHT_COLLISION_DISTANCE = 25.0; - public static final Double BOUNCE_DISTANCE_MARK = 20.0; + private static final Double BOUNCE_DISTANCE_MARK = 20.0; public static final Double BOUNCE_DISTANCE_YACHT = 30.0; - public static final Double COLLISION_VELOCITY_PENALTY = 0.3; + private static final Double COLLISION_VELOCITY_PENALTY = 0.3; private static Long previousUpdateTime; public static Double windDirection; @@ -350,6 +350,8 @@ public class GameState implements Runnable { if (distance < YACHT_COLLISION_DISTANCE) { tokens.remove(token); serverYacht.setPowerUp(token.getTokenType()); + logger.debug("Yacht: " + serverYacht.getShortName() + " got powerup " + token + .getTokenType()); notifyMessageListeners(MessageFactory.getRaceXML()); break; } diff --git a/src/main/java/seng302/gameServer/MainServerThread.java b/src/main/java/seng302/gameServer/MainServerThread.java index c0b59751..bd5e4d23 100644 --- a/src/main/java/seng302/gameServer/MainServerThread.java +++ b/src/main/java/seng302/gameServer/MainServerThread.java @@ -50,7 +50,7 @@ public class MainServerThread implements Runnable, ClientConnectionDelegate { terminated = false; thread = new Thread(this, "MainServer"); startUpdatingWind(); -// startSpawningTokens(); + startSpawningTokens(); thread.start(); } diff --git a/src/main/java/seng302/gameServer/MessageFactory.java b/src/main/java/seng302/gameServer/MessageFactory.java index 76410c1e..c71e6028 100644 --- a/src/main/java/seng302/gameServer/MessageFactory.java +++ b/src/main/java/seng302/gameServer/MessageFactory.java @@ -22,10 +22,16 @@ import seng302.utilities.XMLGenerator; * A Class for interfacing between the data we have in the GameState to the messages we need to send * through the MainServerThread. * - * WARNING DO NOT USE THIS CLASS IF GAMESTATE HAS NOT BEEN INSTANTIATED. + * WARNING DO NOT USE THIS CLASS IF GAMESTATE HAS NOT BEEN INSTANTIATED. (Main Server has not started) * // TODO: 29/08/17 wmu16 - Make GameState non static to fix this ¯\_(ツ)_/¯ * Created by wmu16 on 29/08/17. */ + +/* +Ideally this class would be created with an instance of the GameState (I tried implementing this for + a bit) but it was too difficult to properly make GameState non static without doing some proper + re working. To do later. + */ public class MessageFactory { private static XMLGenerator xmlGenerator = new XMLGenerator();