Skip to content

Commit

Permalink
fix tests for 35x35 grid
Browse files Browse the repository at this point in the history
  • Loading branch information
muktar1907 committed Apr 23, 2024
1 parent b7b0bb0 commit 451ae4f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
32 changes: 28 additions & 4 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h1>The Word Search Game</h1>
</div>
</body>
<script>
var socket = new WebSocket("ws://localhost:9105");
var socket = new WebSocket("ws://"+ window.location.hostname+":9105");


socket.onopen = function(evt) {
Expand All @@ -68,6 +68,7 @@ <h1>The Word Search Game</h1>
socket.onmessage = function(evt) {
console.log("Message received: " + evt.data);
var messageData = JSON.parse(evt.data);

};

socket.onclose = function(evt) {
Expand All @@ -83,6 +84,23 @@ <h1>The Word Search Game</h1>
socket.onerror = function(evt) {
console.error("WebSocket error: " + evt.message);
};
gameId;
class Player
{
nick;
score;
status;
totalPoints;
gameWins;
}

class UserEvent
{
gameId;
player;
cell;
action;
}

function requestGameList() {
var data = { type: "RequestGameList" };
Expand Down Expand Up @@ -131,7 +149,7 @@ <h1>The Word Search Game</h1>
gameIndex: gameIndex,
modeIndex: mode
};
socket.send(JSON.stringify(data));
//socket.send(JSON.stringify(data));
}

// replace leaveGame function with one that sends a WebSocket message
Expand Down Expand Up @@ -164,15 +182,16 @@ <h1>The Word Search Game</h1>
const tblBody = document.createElement("tbody");
//create cells

for(let i=0;i<=35;i++)
for(let i=0;i<35;i++)
{
//create rows
const row = document.createElement("tr");
for(let j=0;j<=35;j++)
for(let j=0;j<35;j++)

{
//create cells and add it to the row
const cell = document.createElement("td");
//cell.setAttribute("id",)
const cellText=document.createTextNode(`${i}`);
cell.appendChild(cellText);
row.appendChild(cell);
Expand All @@ -185,5 +204,10 @@ <h1>The Word Search Game</h1>
document.body.appendChild(tbl);
tbl.setAttribute("border","1.5");
}

function buttonClick(i)
{

}
</script>

6 changes: 3 additions & 3 deletions src/main/java/uta/cse3310/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void setGameStatus(boolean gameStatus) {
public void startGame() {
displayRules();
// gridField=new GridField(wordList);
gridField.generateGrid(50);
gridField.generateGrid(36);
gameStatus = true;
}

Expand All @@ -98,8 +98,8 @@ public void updateGame(ArrayList<UserEvent> attempt) {
while (i.hasNext()) {
UserEvent U = (UserEvent) i.next();
int index = U.cell;
int row = index / 50;
int column = index % 50;
int row = index / 35;
int column = index % 35;

word = word + grid[row][column];
System.out.println(word);
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/uta/cse3310/gameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ public void testUpdate()
UserEvent U4= new UserEvent();
UserEvent U5= new UserEvent();
U1.player=player1;
U1.cell=50;
U1.cell=35;
U1.action=0;
U2.player=player1;
U2.cell=51;
U2.cell=36;
U2.action=1;
U3.player=player1;
U3.cell=52;
U3.cell=37;
U3.action=1;
U4.player=player1;
U4.cell=53;
U4.cell=38;
U4.action=2;
ArrayList<UserEvent> attempt = new ArrayList<UserEvent>(){
{
Expand Down

0 comments on commit 451ae4f

Please sign in to comment.