diff --git a/src/main/java/seng302/gameServer/GameState.java b/src/main/java/seng302/gameServer/GameState.java index aaea82cf..6e73de05 100644 --- a/src/main/java/seng302/gameServer/GameState.java +++ b/src/main/java/seng302/gameServer/GameState.java @@ -85,7 +85,7 @@ public class GameState implements Runnable { players = new ArrayList<>(); GameState.hostIpAddress = hostIpAddress; customizationFlag = false; - + speedMultiplier = 1.0; currentStage = GameStages.LOBBYING; isRaceStarted = false; //set this when game stage changes to prerace diff --git a/src/main/resources/server_config/xml_templates/race.ftlh b/src/main/resources/server_config/xml_templates/race.ftlh index 7c58cb3e..8fa95216 100644 --- a/src/main/resources/server_config/xml_templates/race.ftlh +++ b/src/main/resources/server_config/xml_templates/race.ftlh @@ -35,7 +35,15 @@ - + + + + + + + + + diff --git a/src/test/java/features/SendChat.feature b/src/test/java/features/SendChat.feature index 5eff2da7..08397454 100644 --- a/src/test/java/features/SendChat.feature +++ b/src/test/java/features/SendChat.feature @@ -1,5 +1,5 @@ Feature: SendChat Scenario: User send chat to another client - Given The are two games running + Given There are two games running When the user has pressed sends the message "Hello world" in a text box Then the other client should receive the message "Hello world" diff --git a/src/test/java/steps/SendChatSteps.java b/src/test/java/steps/SendChatSteps.java index c2b5b802..b0701628 100644 --- a/src/test/java/steps/SendChatSteps.java +++ b/src/test/java/steps/SendChatSteps.java @@ -3,7 +3,11 @@ package steps; import cucumber.api.java.en.Given; import cucumber.api.java.en.Then; import cucumber.api.java.en.When; +import javafx.scene.layout.Pane; +import seng302.gameServer.GameStages; +import seng302.gameServer.GameState; import seng302.gameServer.MainServerThread; +import seng302.visualiser.ClientToServerThread; import seng302.visualiser.GameClient; /** @@ -11,31 +15,44 @@ import seng302.visualiser.GameClient; */ public class SendChatSteps { - MainServerThread mst; - GameClient client1; - GameClient client2; + private boolean dcSent = false; + private ClientToServerThread client; + private ClientToServerThread host; + private MainServerThread mst; //TODO Need to mock the controller pane in order to run the full game client - @Given("^The are two games running$") + @Given("^There are two games running$") public void the_are_two_games_running() throws Throwable { -// client1 = new GameClient(new Pane()); -// client1.runAsHost("localhost", 4942); -//// client2 = new ClientToServerThread("localhost", 4942); -// GameState.setCurrentStage(GameStages.RACING); -// Thread.sleep(200); + mst = new MainServerThread(); + host = new ClientToServerThread("localhost", 4942); + try { + Thread.sleep(100); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + client = new ClientToServerThread("localhost", 4942); + try { + Thread.sleep(100); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + mst.startGame(); + Thread.sleep(200); } @When("^the user has pressed sends the message \"([^\"]*)\" in a text box$") public void the_user_has_pressed_sends_the_message_in_a_text_box(String arg1) throws Throwable { -// client1.getSocketThread().sendChatterMessage(arg1); + client.sendChatterMessage("[time_prefix] " + arg1); } @Then("^the other client should receive the message \"([^\"]*)\"$") - public void the_other_client_should_recieve_the_message(String arg1) throws Throwable { -// System.out.println(client2.getPacketQueue()); -// client2.setSocketToClose(); + public void the_other_client_should_receive_the_message(String arg1) throws Throwable { + System.out.println("HERE IT IS" + host.getPacketQueue().peek()); + mst.terminate(); + host.setSocketToClose(); + client.setSocketToClose(); } } \ No newline at end of file