diff --git a/TODO b/TODO index 9d94fd0..c807fb0 100644 --- a/TODO +++ b/TODO @@ -39,13 +39,14 @@ ✔ Game creation @done(21-04-26 17:38) → Multiplayer game logic → Process turns - → Display turns on client + ✔ Display turns on client @done(21-05-09 22:45) + → Server returns everything new to do with the game ✘ Singleplayer game logic - OUT OF SCOPE @cancelled(21-04-11 01:04) ✘ AI CPU player @cancelled(21-04-11 01:07) ☐ Client - → Display multiplayer game info - → Update dynamically + ✔ Display multiplayer game info @done(21-05-09 22:44) + ✔ Update dynamically @done(21-05-09 22:44) ☐ Code → Refactor to code portsoc eslint @@ -53,6 +54,7 @@ → WHY THE HELL ARE THEY CALLED USERS IN SOME PLACES AND PLAYERS IN OTHERS ☐ Bugfixes + → If a user leaves their current game then makes a new one, it's corrupted → If a user disconnects during a game, the game is irrevokably corrupted diff --git a/client/public/scrabble/game.js b/client/public/scrabble/game.js index 1ed466f..eceea47 100644 --- a/client/public/scrabble/game.js +++ b/client/public/scrabble/game.js @@ -88,7 +88,6 @@ function startMyTurn() } updateUsersUI(Users); startMyTurnUI(); - console.log('my turn', Users); } function startOthersTurn(useruid) @@ -102,7 +101,6 @@ function startOthersTurn(useruid) } updateUsersUI(Users); stopMyTurnUI(); - console.log('not my turn', Users); } function playMyTurn(stagedpieces) @@ -150,7 +148,8 @@ function skipMyTurn() netSkipTurn(); } -function processOthersTurn() +function processTurn(turn) { - + removeStagedPieces(); + renderBoardState(turn.boardtiles); } diff --git a/client/public/scrabble/network.js b/client/public/scrabble/network.js index 41f291e..3b96604 100644 --- a/client/public/scrabble/network.js +++ b/client/public/scrabble/network.js @@ -247,7 +247,7 @@ function onGameBegin(socket, args) function onStartTurn(socket, args) { - console.log('my turn'); + console.log('It\'s my turn!'); startMyTurn(); } @@ -276,12 +276,12 @@ function onTurnError(socket, args) function onturnProcessed(socket, args) { - console.log('proc', args); + processTurn(args.outcome); } function onTurnStart(socket, args) { - console.log('start', args); + console.log('Turn Starting!'); startOthersTurn(args.turninfo.turnplayer.uid); } diff --git a/client/public/scrabble/pieces.js b/client/public/scrabble/pieces.js index 12dd9ed..010bfaa 100644 --- a/client/public/scrabble/pieces.js +++ b/client/public/scrabble/pieces.js @@ -132,6 +132,12 @@ function renderBoardState(pieces) setupPieces(); } +function removeStagedPieces() +{ + for (const piece of document.querySelectorAll('.staged-piece')) + piece.remove(); +} + // places for board coordinate (0-14) function placePieceOnBoard(piece, x, y) { diff --git a/client/public/scrabble/ui.js b/client/public/scrabble/ui.js index d34b1ae..074c342 100644 --- a/client/public/scrabble/ui.js +++ b/client/public/scrabble/ui.js @@ -97,6 +97,10 @@ function startMyTurnUI() IPlayButton.forEach(e => { e.disabled = false; }); + document.querySelectorAll('.unplayed-piece').forEach(e => { + if (e.classList.contains('played-piece')) + e.classList.remove('played-piece'); + }); } function stopMyTurnUI() @@ -110,6 +114,10 @@ function stopMyTurnUI() IPlayButton.forEach(e => { e.disabled = true; }); + document.querySelectorAll('.unplayed-piece').forEach(e => { + if (!e.classList.contains('played-piece')) + e.classList.add('played-piece'); + }); } function onExchangeTiles() diff --git a/server/src/game-logic.js b/server/src/game-logic.js index 693a362..97fabb1 100644 --- a/server/src/game-logic.js +++ b/server/src/game-logic.js @@ -270,7 +270,6 @@ function PlayTurn(gameuid, playeruid, turn) function SkipTurn(gameuid, playeruid) { - console.log('skip'); gameNextTurn(gameuid); }