diff --git a/src/main/java/seng302/visualiser/GameView3D.java b/src/main/java/seng302/visualiser/GameView3D.java index d53024da..cdcefafb 100644 --- a/src/main/java/seng302/visualiser/GameView3D.java +++ b/src/main/java/seng302/visualiser/GameView3D.java @@ -735,4 +735,8 @@ public class GameView3D { // }); // playerYacht.addMarkRoundingListener(this::updateMarkArrows); } + + public void setWindDir(double windDir) { + this.windDir = windDir; + } } diff --git a/src/main/java/seng302/visualiser/controllers/RaceViewController.java b/src/main/java/seng302/visualiser/controllers/RaceViewController.java index 369955f6..452b5823 100644 --- a/src/main/java/seng302/visualiser/controllers/RaceViewController.java +++ b/src/main/java/seng302/visualiser/controllers/RaceViewController.java @@ -88,8 +88,6 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel @FXML private AnchorPane rvAnchorPane; @FXML - private Text windDirectionText; - @FXML private AnchorPane windArrowHolder; @FXML private Slider annotationSlider; @@ -100,9 +98,11 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel @FXML private Text fpsDisplay; @FXML - private Text windSpeedText; - @FXML private ImageView windImageView; + @FXML + private Label windDirectionLabel; + @FXML + private Label windSpeedLabel; //Race Data private Map participants; @@ -216,12 +216,12 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel // raceState.addCollisionListener(gameView::drawCollision); raceState.windDirectionProperty().addListener((obs, oldDirection, newDirection) -> { -// gameView.setWindDir(newDirection.doubleValue()); + gameView.setWindDir(newDirection.doubleValue()); Platform.runLater(() -> updateWindDirection(newDirection.doubleValue())); }); -// raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) -> -// Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue())) -// ); + raceState.windSpeedProperty().addListener((obs, oldSpeed, newSpeed) -> + Platform.runLater(() -> updateWindSpeed(newSpeed.doubleValue())) + ); Platform.runLater(() -> { updateWindDirection(raceState.windDirectionProperty().doubleValue()); updateWindSpeed(raceState.getWindSpeed()); @@ -473,8 +473,8 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel * @param direction the from north angle of the wind. */ private void updateWindDirection(double direction) { -// windDirectionText.setText(String.format("%.1f°", direction)); -// windArrowText.setRotate(direction); + windDirectionLabel.setText(String.format("%.1f°", direction)); + windImageView.setRotate(direction); } /** @@ -482,7 +482,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel * @param windSpeed Windspeed in knots. */ private void updateWindSpeed(double windSpeed) { -// windSpeedText.setText("Speed: " + String.format("%.1f", windSpeed) + " Knots"); + windSpeedLabel.setText(String.format("%.1f", windSpeed) + " Knots"); } diff --git a/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java b/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java index 3292bf6f..87e920a0 100644 --- a/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java +++ b/src/main/java/seng302/visualiser/fxObjects/ChatHistory.java @@ -70,4 +70,7 @@ public class ChatHistory extends ScrollPane { } } + + + } diff --git a/src/main/resources/views/RaceView.fxml b/src/main/resources/views/RaceView.fxml index 02188f66..b8767c03 100644 --- a/src/main/resources/views/RaceView.fxml +++ b/src/main/resources/views/RaceView.fxml @@ -14,38 +14,28 @@ - + + - + - - - + + + - - - + + + - - + + @@ -86,70 +76,67 @@ - - + + - - + + - + - + - + - + - + - + - + - + - - + + - - - + + + - - + + + + + + - - + + diff --git a/src/test/java/seng302/gameServer/server/ChatCommandsTest.java b/src/test/java/seng302/gameServer/server/ChatCommandsTest.java index 07f6baf2..221a6782 100644 --- a/src/test/java/seng302/gameServer/server/ChatCommandsTest.java +++ b/src/test/java/seng302/gameServer/server/ChatCommandsTest.java @@ -68,9 +68,11 @@ public class ChatCommandsTest { } catch (InterruptedException ie) { ie.printStackTrace(); } + mst.terminate(); host = null; client = null; mst = null; + } catch (IOException ioe) { ioe.printStackTrace(); } @@ -86,6 +88,11 @@ public class ChatCommandsTest { new GameState("localhost"); mst = new MainServerThread(); host = null; + try { + Thread.sleep(100); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } try { host = new ClientToServerThread("localhost", 4942); } catch (IOException ioe) { @@ -97,7 +104,7 @@ public class ChatCommandsTest { ie.printStackTrace(); } mst.startGame(); - host.sendChatterMessage("[time_prefix] >speed 5.0"); + host.sendChatterMessage("[time_prefix] >speed 5"); try { Thread.sleep(100); } catch (InterruptedException ie) { @@ -106,7 +113,7 @@ public class ChatCommandsTest { Assert.assertEquals(5.0, GameState.getSpeedMultiplier(), 0.00001); mst.terminate(); try { - Thread.sleep(2000); + Thread.sleep(200); } catch (InterruptedException ie) { ie.printStackTrace(); } diff --git a/src/test/java/steps/SendChatSteps.java b/src/test/java/steps/SendChatSteps.java index 3c10260d..e9e1ff2e 100644 --- a/src/test/java/steps/SendChatSteps.java +++ b/src/test/java/steps/SendChatSteps.java @@ -5,6 +5,7 @@ import cucumber.api.java.en.Then; import cucumber.api.java.en.When; import javafx.util.Pair; import org.junit.Assert; +import seng302.gameServer.GameState; import seng302.gameServer.MainServerThread; import seng302.model.stream.packets.StreamPacket; import seng302.utilities.StreamParser; @@ -24,6 +25,11 @@ public class SendChatSteps { @Given("^There are two games running$") public void the_are_two_games_running() throws Throwable { mst = new MainServerThread(); + try { + Thread.sleep(100); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } host = new ClientToServerThread("localhost", 4942); try { Thread.sleep(100); diff --git a/src/test/java/steps/ToggleSailSteps.java b/src/test/java/steps/ToggleSailSteps.java index 034c10e1..347fe1d1 100644 --- a/src/test/java/steps/ToggleSailSteps.java +++ b/src/test/java/steps/ToggleSailSteps.java @@ -23,31 +23,32 @@ public class ToggleSailSteps { @Given("^The game is running$") public void the_game_is_running() throws Throwable { -// mst = new MainServerThread(); -// client = new ClientToServerThread("localhost", 4942); -// GameState.setCurrentStage(GameStages.RACING); -// Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other -// ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); -// Assert.assertFalse(yacht.getSailIn()); + mst = new MainServerThread(); + client = new ClientToServerThread("localhost", 4942); + GameState.setCurrentStage(GameStages.RACING); + Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other + ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); + Assert.assertFalse(yacht.getSailIn()); } @When("^the user has pressed \"([^\"]*)\"$") public void the_user_has_pressed(String arg1) throws Throwable { -// startTime = System.currentTimeMillis(); -// if (arg1 == "shift") { -// client.sendBoatAction(BoatAction.SAILS_IN); -// } + startTime = System.currentTimeMillis(); + if (arg1 == "shift") { + client.sendBoatAction(BoatAction.SAILS_IN); + } } @Then("^the sails are \"([^\"]*)\"$") public void the_sails_are(String arg1) throws Throwable { -// Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other -// ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); -// if (arg1 == "in") { -// Assert.assertTrue(yacht.getSailIn()); -// } else { -// Assert.assertFalse(yacht.getSailIn()); -// } + Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other + ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); + if (arg1 == "in") { + Assert.assertTrue(yacht.getSailIn()); + } else { + Assert.assertFalse(yacht.getSailIn()); + } + mst.terminate(); } }