From 53f38fa9bcf3ce71c0460124af0356c85d8a00c7 Mon Sep 17 00:00:00 2001 From: muktar1907 Date: Tue, 23 Apr 2024 12:32:57 -0500 Subject: [PATCH 1/2] edits --- html/lobby.html | 6 +++--- src/main/java/uta/cse3310/App.java | 22 ++++++++++++++++++++++ src/main/java/uta/cse3310/UserEvent.java | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/html/lobby.html b/html/lobby.html index 47ed0aa..8a371ae 100644 --- a/html/lobby.html +++ b/html/lobby.html @@ -50,12 +50,12 @@

The Word Search Game

socket.onopen = function(evt) { console.log("Open"); requestGameList(); - }; + } socket.onmessage = function(evt) { console.log("Message received: " + evt.data); var messageData = JSON.parse(evt.data); - }; + } socket.onclose = function(evt) { console.log("WebSocket connection closed."); @@ -64,7 +64,7 @@

The Word Search Game

leaveGame(nick); } document.getElementById("topMessage").innerText = "Server Offline"; - }; + } socket.onerror = function(evt) { console.error("WebSocket error: " + evt.message); diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java index 97b524a..62c3007 100644 --- a/src/main/java/uta/cse3310/App.java +++ b/src/main/java/uta/cse3310/App.java @@ -138,8 +138,30 @@ public void onMessage(WebSocket conn, String message) { GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); UserEvent U = gson.fromJson(message,UserEvent.class); + System.out.println(U.cell+ "was selected"); insertInnerMap(U,everyAttempt); + if(U.action==2) + { + ArrayList attempt= new ArrayList(); + attempt=everyAttempt.get(U.gameId).get(U.player.getNick()); + Game G = null; + for(Game i : activeGames) + { + if(i.getGameID().equals(U.gameId)) + { + G = i; + G.updateGame(attempt); + break; + } + } + String jsonString; + jsonString = gson.toJson(G); + + System.out.println(jsonString); + broadcast(jsonString); + } + } diff --git a/src/main/java/uta/cse3310/UserEvent.java b/src/main/java/uta/cse3310/UserEvent.java index b73f5eb..53773ff 100644 --- a/src/main/java/uta/cse3310/UserEvent.java +++ b/src/main/java/uta/cse3310/UserEvent.java @@ -2,7 +2,7 @@ // User events are sent from the webpage to the server public class UserEvent { - public int gameId;//id of the game in which the event took place + public String gameId;//id of the game in which the event took place public Player player;//the player that made the event public int cell;//refers to the cell containing a selected letter public int action; //click=0,hover=1,release=2 From 15734f29aa2bade29ba5f4afd0f7eb5c1030f306 Mon Sep 17 00:00:00 2001 From: muktar1907 Date: Tue, 23 Apr 2024 14:37:31 -0500 Subject: [PATCH 2/2] rename html files --- html/index.html | 253 ++++++++++++++++++++++++++------------------ html/lobby.html | 171 ------------------------------ html/tictactoe.html | 120 +++++++++++++++++++++ 3 files changed, 272 insertions(+), 272 deletions(-) delete mode 100644 html/lobby.html create mode 100644 html/tictactoe.html diff --git a/html/index.html b/html/index.html index ba02b4d..8a371ae 100644 --- a/html/index.html +++ b/html/index.html @@ -1,120 +1,171 @@ + - + + + The Word Search Game Lobby + + +
+
+ + +
+ + +
+
+ + +
+
+ + +
+ +

The Word Search Game

+ + + +
+
+ +
+
+ + +
+ + + +
+
+ + - function buttonclick(i) { - U = new UserEvent(); - U.Button = i; - if (idx == 0) - U.PlayerIdx = "XPLAYER"; - else - U.PlayerIdx = "OPLAYER"; - U.GameId = gameid; - connection.send(JSON.stringify(U)); - console.log(JSON.stringify(U)) - } - \ No newline at end of file diff --git a/html/lobby.html b/html/lobby.html deleted file mode 100644 index 8a371ae..0000000 --- a/html/lobby.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - The Word Search Game Lobby - - - -
-
- - -
- - -
-
- - -
-
- - -
- -

The Word Search Game

- - - -
-
- -
-
- - -
- - - -
-
- - - diff --git a/html/tictactoe.html b/html/tictactoe.html new file mode 100644 index 0000000..ba02b4d --- /dev/null +++ b/html/tictactoe.html @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + \ No newline at end of file