Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…oup27 into main
  • Loading branch information
beshoykamel1 committed Apr 30, 2024
2 parents 4bd4e5c + f5dffc8 commit 653256e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
14 changes: 11 additions & 3 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ <h1>The Word Search Game</h1>
connection.onmessage = function (event) {
var message = JSON.parse(event.data);

if ('YouAre' in message) {
if (message.YouAre == "PLAYERONE") {
PlayerIdx = 0;
}
else {
PlayerIdx = 1;
}

gameid = message.GameId;
}

if (message.type === "wordCoordinates"){
console.log("[" + message.coordinates[0] + "] [" + message.coordinates[1] +"]");
console.log("Start idx: " + getIdx(message.coordinates[0]) + " End idx: " + getIdx(message.coordinates[1]));
Expand Down Expand Up @@ -359,9 +370,6 @@ <h1>The Word Search Game</h1>
}
}

function gridStart(){

}
</script>
</div>

Expand Down
20 changes: 10 additions & 10 deletions html/tttsample.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@
if (gameid == obj.GameId) {
// button state to display values

document.getElementById("b1").value = ButtonStateToDisplay.get(obj.Button[0]);
document.getElementById("b2").value = ButtonStateToDisplay.get(obj.Button[1]);
document.getElementById("b3").value = ButtonStateToDisplay.get(obj.Button[2]);
document.getElementById("b4").value = ButtonStateToDisplay.get(obj.Button[3]);
document.getElementById("b5").value = ButtonStateToDisplay.get(obj.Button[4]);
document.getElementById("b6").value = ButtonStateToDisplay.get(obj.Button[5]);
document.getElementById("b7").value = ButtonStateToDisplay.get(obj.Button[6]);
document.getElementById("b8").value = ButtonStateToDisplay.get(obj.Button[7]);
document.getElementById("b9").value = ButtonStateToDisplay.get(obj.Button[8]);
// document.getElementById("b1").value = ButtonStateToDisplay.get(obj.Button[0]);
// document.getElementById("b2").value = ButtonStateToDisplay.get(obj.Button[1]);
// document.getElementById("b3").value = ButtonStateToDisplay.get(obj.Button[2]);
// document.getElementById("b4").value = ButtonStateToDisplay.get(obj.Button[3]);
// document.getElementById("b5").value = ButtonStateToDisplay.get(obj.Button[4]);
// document.getElementById("b6").value = ButtonStateToDisplay.get(obj.Button[5]);
// document.getElementById("b7").value = ButtonStateToDisplay.get(obj.Button[6]);
// document.getElementById("b8").value = ButtonStateToDisplay.get(obj.Button[7]);
// document.getElementById("b9").value = ButtonStateToDisplay.get(obj.Button[8]);


// the message line
document.getElementById("topMessage").innerHTML = obj.Msg[idx];
// document.getElementById("topMessage").innerHTML = obj.Msg[idx];
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/uta/cse3310/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class App extends WebSocketServer {
// the vector ActiveGames
private Vector<Game> ActiveGames = new Vector<Game>();

private int GameId = 1;
private int GameId = 0;

private int connectionId = 0;

Expand Down Expand Up @@ -100,7 +100,9 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {

// search for a game needing a player
Game G = null;
System.err.println("ActiveGames size: " + ActiveGames.size());
for (Game i : ActiveGames) {
System.err.println("for loop for active games fired.");
if (i.Players == uta.cse3310.PlayerType.PLAYERONE ||
i.Players == uta.cse3310.PlayerType.PLAYERTWO ||
i.Players == uta.cse3310.PlayerType.PLAYERTHREE) {
Expand All @@ -111,12 +113,13 @@ public void onOpen(WebSocket conn, ClientHandshake handshake) {

// No matches ? Create a new Game.
// No matches ? Create a new Game.
if (G == null) {
if (G == null || GameId % 2 == 1) {
G = new Game(stats);
G.GameId = GameId;
GameId++;
// Add the first player
G.Players = PlayerType.PLAYERONE;
G.Players = uta.cse3310.PlayerType.PLAYERONE;
// G.Players = PlayerType.PLAYERONE;
ActiveGames.add(G);
System.out.println("creating a new Game");

Expand Down

0 comments on commit 653256e

Please sign in to comment.