From cae17481021b89a75bf5e0c0a41a1fd449ac68bd Mon Sep 17 00:00:00 2001 From: Benjamin Auder <benjamin.auder@somewhere> Date: Wed, 23 Mar 2022 09:48:33 +0100 Subject: [PATCH] Showing rules after random rematch only --- server.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server.js b/server.js index 9c85eeb..0a85deb 100644 --- a/server.js +++ b/server.js @@ -22,9 +22,7 @@ function launchGame(vname, players, options) { Crypto.randomBytes(randstrSize).toString("hex").slice(0, randstrSize); games[gid] = { vname: vname, - players: players.map(p => { - return (!p ? null : {sid: p.sid, name: p.name}); - }), + players: players, options: options, time: Date.now() }; @@ -127,8 +125,10 @@ wss.on("connection", (socket, req) => { if (games[obj.gid].rematch[1-myIndex]) { // Launch new game, colors reversed let vname = games[obj.gid].vname; - if (games[obj.gid].rematch.every(r => r == 2)) - vname = getRandomVariant(); + const allrand = games[obj.gid].rematch.every(r => r == 2); + if (allrand) vname = getRandomVariant(); + games[obj.gid].players.forEach(p => + p.randvar = allrand ? true : false); launchGame(vname, games[obj.gid].players.reverse(), games[obj.gid].options); -- 2.44.0