From 5d9221827ba354dfbbf226d6f02397f0435c7e2f Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 10 May 2021 16:25:41 +0100 Subject: [PATCH] redacted names --- LICENSE | 2 +- TODO | 3 + client/package.json | 2 +- package.json | 2 +- server/package.json | 2 +- server/src/game-logic.js | 18 +- server/src/socketserver.js | 1 + turns-debug.json | 403 +++++++++++++++++++++++++++++++++++++ 8 files changed, 425 insertions(+), 8 deletions(-) create mode 100644 turns-debug.json diff --git a/LICENSE b/LICENSE index ae5a0da..e9a74d6 100644 --- a/LICENSE +++ b/LICENSE @@ -1 +1 @@ -COPYRIGHT 2021 BENJAMIN KYD - ALL RIGHTS RESERVED +COPYRIGHT 2021 REDACTED - ALL RIGHTS RESERVED diff --git a/TODO b/TODO index e714100..493981a 100644 --- a/TODO +++ b/TODO @@ -7,6 +7,9 @@ # Short term, coursework scope +☐ ANONYOMISE +☐ README + ☐ Translate ✔ Portuagese (Ines) @done(21-04-11 01:03) → Update with new locales diff --git a/client/package.json b/client/package.json index ee7a218..1ab1e8d 100644 --- a/client/package.json +++ b/client/package.json @@ -8,7 +8,7 @@ "setup": "npm i", "test": "nodemon launchserver.js" }, - "author": "Ben Kyd (https://benkyd.co.uk)", + "author": " REDACTED", "license": "UNLICENSED", "dependencies": { "express": "^4.17.1" diff --git a/package.json b/package.json index ddeb03d..728a306 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "author": "Ben Kyd (https://benkyd.co.uk)", + "author": "REDACTED", "license": "UNLICENSED", "dependencies": { "eslint": "^7.23.0", diff --git a/server/package.json b/server/package.json index c254515..6d8ce5c 100644 --- a/server/package.json +++ b/server/package.json @@ -8,7 +8,7 @@ "setup": "npm i", "test": "nodemon index.js" }, - "author": "Ben Kyd (https://benkyd.co.uk)", + "author": "REDACTED", "license": "UNLICENSED", "dependencies": { "body-parser": "^1.19.0", diff --git a/server/src/game-logic.js b/server/src/game-logic.js index d0b9c32..c34c7e4 100644 --- a/server/src/game-logic.js +++ b/server/src/game-logic.js @@ -264,10 +264,11 @@ function PlayTurn(gameuid, playeruid, turn) const turninfo = gameNextTurn(gameuid); ActiveGames[gameuid].gamestates.push(turn); + ActiveGames[gameuid].turn = turninfo.newTurn; + ActiveGames[gameuid].turn = turninfo.newTotalTurn; // give user new tiles - console.log(game); return [turn, turninfo]; } @@ -276,9 +277,18 @@ function SkipTurn(gameuid, playeruid) const turninfo = gameNextTurn(gameuid); // get last game state const turn = { - playeruid: + playeruid: playeruid, + turn: turninfo.newTurn, + turntype: 'SKIP', + outcome: {}, + oldboardtiles: ActiveGames[gameuid].gamestates[ActiveGames[gameuid].gamestates.length - 1], + boardtiles: ActiveGames[gameuid].gamestates[ActiveGames[gameuid].gamestates.length - 1] }; + ActiveGames[gameuid].gamestates.push(turn); + ActiveGames[gameuid].turn = turninfo.newTurn; + ActiveGames[gameuid].turn = turninfo.newTotalTurn; + return [turn, turninfo]; } @@ -286,10 +296,10 @@ function gameNextTurn(gameuid) { const playerCount = ActiveGames[gameuid].players.length; let newTurn = ActiveGames[gameuid].turn += 1; - newTurn = ActiveGames[gameuid].turn % PlayerCount; + newTurn = ActiveGames[gameuid].turn % playerCount; const newTotalTurn = ActiveGames[gameuid].turntotal += 1; return { - turnplayer: ActiveGames[gameuid].players[ActiveGames[gameuid].turn], + turnplayer: ActiveGames[gameuid].players[newTurn], newTurn: newTurn, newTotalTurn: newTotalTurn }; diff --git a/server/src/socketserver.js b/server/src/socketserver.js index 773cc7b..548a7fa 100644 --- a/server/src/socketserver.js +++ b/server/src/socketserver.js @@ -436,6 +436,7 @@ function GamePlayTurn(socket, args) io.to(nextuser).emit('game-your-turn'); } + require('fs').appendFileSync('../turns-debug.json', JSON.stringify(Game.Logic.GetGameByUserUID(user.uid), null, 4)); } function GameExchangeTiles(socket, args) diff --git a/turns-debug.json b/turns-debug.json new file mode 100644 index 0000000..74bbead --- /dev/null +++ b/turns-debug.json @@ -0,0 +1,403 @@ +{ + "uid": "UQWPWN", + "locale": "en", + "players": [ + { + "uid": "4034e8f531d4ad69", + "name": "ben", + "activetiles": [ + "E", + "R", + "I", + "F", + "I", + "E", + "U" + ], + "score": 0 + } + ], + "turn": 1, + "turntotal": 1, + "gamestates": [ + { + "playeruid": -1, + "turn": 0, + "turntype": "", + "outcome": { + "valid": false + }, + "oldboardtiles": [], + "boardtiles": [] + }, + { + "playeruid": "4034e8f531d4ad69", + "turn": -1, + "turntype": "PLACE", + "outcome": {}, + "oldboardtiles": [], + "boardtiles": [ + { + "pos": { + "x": 5, + "y": 14 + }, + "modifier": "NONE", + "letter": "I", + "score": -1 + }, + { + "pos": { + "x": 6, + "y": 14 + }, + "modifier": "NONE", + "letter": "F", + "score": -1 + }, + { + "pos": { + "x": 7, + "y": 14 + }, + "modifier": "TW", + "letter": "I", + "score": -1 + } + ] + } + ], + "tilebag": [ + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "A", + "A", + "A", + "A", + "A", + "A", + "A", + "A", + "A", + "I", + "I", + "I", + "I", + "I", + "I", + "I", + "O", + "O", + "O", + "O", + "O", + "O", + "O", + "O", + "N", + "N", + "N", + "N", + "N", + "N", + "R", + "R", + "R", + "R", + "R", + "T", + "T", + "T", + "T", + "T", + "T", + "L", + "L", + "L", + "L", + "S", + "S", + "S", + "S", + "U", + "U", + "U", + "D", + "D", + "D", + "D", + "G", + "G", + "G", + "B", + "B", + "C", + "C", + "M", + "M", + "P", + "P", + "F", + "H", + "H", + "V", + "V", + "W", + "W", + "Y", + "Y", + "K", + "J", + "X", + "Q", + "Z", + "_", + "_" + ], + "tileset": [ + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z" + ] +}{ + "uid": "UQWPWN", + "locale": "en", + "players": [ + { + "uid": "4034e8f531d4ad69", + "name": "ben", + "activetiles": [ + "E", + "R", + "I", + "F", + "I", + "E", + "U" + ], + "score": 0 + } + ], + "turn": 2, + "turntotal": 2, + "gamestates": [ + { + "playeruid": -1, + "turn": 0, + "turntype": "", + "outcome": { + "valid": false + }, + "oldboardtiles": [], + "boardtiles": [] + }, + { + "playeruid": "4034e8f531d4ad69", + "turn": -1, + "turntype": "PLACE", + "outcome": {}, + "oldboardtiles": [], + "boardtiles": [ + { + "pos": { + "x": 5, + "y": 14 + }, + "modifier": "NONE", + "letter": "I", + "score": -1 + }, + { + "pos": { + "x": 6, + "y": 14 + }, + "modifier": "NONE", + "letter": "F", + "score": -1 + }, + { + "pos": { + "x": 7, + "y": 14 + }, + "modifier": "TW", + "letter": "I", + "score": -1 + } + ] + }, + { + "playeruid": "4034e8f531d4ad69", + "turn": -1, + "turntype": "PLACE", + "outcome": {}, + "oldboardtiles": [], + "boardtiles": [ + { + "pos": { + "x": 8, + "y": 14 + }, + "modifier": "NONE", + "letter": "U", + "score": -1 + } + ] + } + ], + "tilebag": [ + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "E", + "A", + "A", + "A", + "A", + "A", + "A", + "A", + "A", + "A", + "I", + "I", + "I", + "I", + "I", + "I", + "I", + "O", + "O", + "O", + "O", + "O", + "O", + "O", + "O", + "N", + "N", + "N", + "N", + "N", + "N", + "R", + "R", + "R", + "R", + "R", + "T", + "T", + "T", + "T", + "T", + "T", + "L", + "L", + "L", + "L", + "S", + "S", + "S", + "S", + "U", + "U", + "U", + "D", + "D", + "D", + "D", + "G", + "G", + "G", + "B", + "B", + "C", + "C", + "M", + "M", + "P", + "P", + "F", + "H", + "H", + "V", + "V", + "W", + "W", + "Y", + "Y", + "K", + "J", + "X", + "Q", + "Z", + "_", + "_" + ], + "tileset": [ + "A", + "B", + "C", + "D", + "E", + "F", + "G", + "H", + "I", + "J", + "K", + "L", + "M", + "N", + "O", + "P", + "Q", + "R", + "S", + "T", + "U", + "V", + "W", + "X", + "Y", + "Z" + ] +} \ No newline at end of file