From 3a4a150e70414d9b92692569040b5ba7c32d9ec3 Mon Sep 17 00:00:00 2001 From: muktar1907 Date: Sat, 27 Apr 2024 03:06:19 -0500 Subject: [PATCH] edits made to index_1.html --- html/index.html | 9 ++++++--- html/index_1.html | 24 ++++++++++++++---------- src/main/java/uta/cse3310/App.java | 6 ++++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/html/index.html b/html/index.html index 3286d22..a3b3c76 100644 --- a/html/index.html +++ b/html/index.html @@ -154,11 +154,9 @@

Timer: 30 seconds

if("grid" in messageData) { //store all letters inside grid variable - grid=JSON.parse(messageData.grid); - + grid=JSON.parse(messageData.grid); } - if(nick==="") { console.log("Player: "+messageData.player); @@ -169,6 +167,11 @@

Timer: 30 seconds

console.log("GameId: "+ gameId); } + if("ready" in messageData && messageData.ready==="true") + { + generateGrid(); + } + } else if(type==="UpdateGame") diff --git a/html/index_1.html b/html/index_1.html index 162b24d..81af1b8 100644 --- a/html/index_1.html +++ b/html/index_1.html @@ -84,15 +84,15 @@

Leaderboard

- -
-

Timer: 30 seconds

-
+ -
- +
+ +
+

Timer: 30 seconds

+
@@ -158,7 +158,10 @@

Timer: 30 seconds

console.log("GameId: "+ gameId); } - + if("ready" in messageData && messageData.ready==="true") + { + generateGrid(); + } } else if(type==="UpdateGame") { @@ -275,7 +278,7 @@

Timer: 30 seconds

//too big may have to do smaller grid or smaller cells function generateGrid() { - const tbl = document.createElement("table"); + const tbl = document.getElementById("wordGrid"); const tblBody = document.createElement("tbody"); //create cells @@ -300,9 +303,10 @@

Timer: 30 seconds

tblBody.appendChild(row); } tbl.appendChild(tblBody); - document.body.appendChild(tbl); + myDiv=document.getElementById("Game"); + myDiv.appendChild(tbl); tbl.setAttribute("border","1.5"); - eventListener(); + //eventListener(); } function eventListener() diff --git a/src/main/java/uta/cse3310/App.java b/src/main/java/uta/cse3310/App.java index ea08c7e..77ab2b8 100644 --- a/src/main/java/uta/cse3310/App.java +++ b/src/main/java/uta/cse3310/App.java @@ -389,6 +389,12 @@ public void messageHandler(Gson gson, String jsonString, WebSocket conn) } jsonObject.addProperty("gameId",G.getGameID()); + //if enough players joined, automatically start game + if(G.getPlayersList().size()==G.getGameMode()) + { + jsonObject.addProperty("ready","true"); + } + //send back to all connections broadcast(jsonObject.toString());