From adcc0ed5cf4febeae6af69370cbf70c0d15e019d Mon Sep 17 00:00:00 2001 From: Ben Kyd Date: Fri, 2 Apr 2021 01:03:45 +0100 Subject: [PATCH] detect if game multiplayer --- client/public/scrabble/game.js | 0 client/public/scrabble/index.html | 2 ++ client/public/scrabble/network.js | 15 +++++++++++++++ client/public/scrabble/pieces.js | 3 +-- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 client/public/scrabble/game.js create mode 100644 client/public/scrabble/network.js diff --git a/client/public/scrabble/game.js b/client/public/scrabble/game.js new file mode 100644 index 0000000..e69de29 diff --git a/client/public/scrabble/index.html b/client/public/scrabble/index.html index e98577b..40e3afe 100644 --- a/client/public/scrabble/index.html +++ b/client/public/scrabble/index.html @@ -388,8 +388,10 @@ + + \ No newline at end of file diff --git a/client/public/scrabble/network.js b/client/public/scrabble/network.js new file mode 100644 index 0000000..7658187 --- /dev/null +++ b/client/public/scrabble/network.js @@ -0,0 +1,15 @@ + +// is game singleplayer? +const urlParser = new URLSearchParams(window.location.search); + +let isSingleplayer = false; +if (urlParser.get('id') === null) +{ + isSingleplayer = true; +} + +if (!isSingleplayer) +{ + // init socket +} + diff --git a/client/public/scrabble/pieces.js b/client/public/scrabble/pieces.js index 9cf8faf..b49abc7 100644 --- a/client/public/scrabble/pieces.js +++ b/client/public/scrabble/pieces.js @@ -74,7 +74,6 @@ function piecePickedUp(piece) { BoardSounds[2].play(); - piece.classList.add('dragging-piece'); } @@ -100,9 +99,9 @@ function piecePlaced(piece) { DrawerSounds[Math.floor(Math.random() * 3)].play(); - piece.classList.add('unplayed-piece'); piece.classList.remove('played-piece'); piece.classList.remove('dragging-piece'); + piece.classList.add('unplayed-piece'); delete piece.dataset.coords; setupPieces();