diff options
-rw-r--r-- | draughts/app.js | 5 | ||||
-rw-r--r-- | 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; |