From efcc8b13e9489ad01d31740883f5ef0bcda5f6fb Mon Sep 17 00:00:00 2001 From: MayteApolix <83069108+MayteApolix@users.noreply.github.com> Date: Sun, 16 Jan 2022 23:06:18 +0100 Subject: some more comments in statTracker --- draughts/app.js | 5 +++-- draughts/statTracker.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/draughts/app.js b/draughts/app.js index e7fd6a1..e255308 100644 --- a/draughts/app.js +++ b/draughts/app.js @@ -37,6 +37,9 @@ wss.on("connection", ws => { * to join. */ let game = env.games.filter(g => !g.ongoing)[0] + stats.ongoingGames++ + stats.totalGames++ + if (!game) { game = new Game() env.games.push(game) @@ -47,8 +50,6 @@ wss.on("connection", ws => { game.ongoing = true game.messageClient({ head: Messages.WELCOME, body: Color.RED }, ws) game.messageOpponent({ head: Messages.START }, ws) - stats.ongoingGames++ - stats.totalGames++ game.nextTurn() } diff --git a/draughts/statTracker.js b/draughts/statTracker.js index b5a09b9..c301d9f 100644 --- a/draughts/statTracker.js +++ b/draughts/statTracker.js @@ -1,8 +1,12 @@ +/** + * The gameStatus object tracks our statics to be displayed on our splash screen. + */ + var gameStatus = { - minimumMoves: Infinity, - averageMoves: Infinity, - ongoingGames: 0, - totalGames: 0 + minimumMoves: Infinity, /* The minimum amount of moves a game was completed*/ + averageMoves: Infinity, /* The average amount of moves of all games completed*/ + ongoingGames: 0, /*How many games are ongoing*/ + totalGames: 0 /* How many games were initialized (used for calculations) */ } module.exports = gameStatus; -- cgit v1.2.3