diff options
| author | MayteApolix <83069108+MayteApolix@users.noreply.github.com> | 2022-01-16 22:32:46 +0100 | 
|---|---|---|
| committer | MayteApolix <83069108+MayteApolix@users.noreply.github.com> | 2022-01-16 22:32:46 +0100 | 
| commit | 7a446c4383d8ee9676e4071551a279c0d586136d (patch) | |
| tree | f622cc23480a37987c30a68a67453ad03020e4e8 /draughts | |
| parent | 4612982e64478e042efae3a560e8a6a137b999c0 (diff) | |
| parent | 31e81bd0dafa8f2c5b43c0d426b333836c32a60e (diff) | |
Merge branch 'main' of https://github.com/MayteSteeghs/draughts
Diffstat (limited to 'draughts')
| -rw-r--r-- | draughts/app.js | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/draughts/app.js b/draughts/app.js index 94dca46..e7fd6a1 100644 --- a/draughts/app.js +++ b/draughts/app.js @@ -58,11 +58,11 @@ wss.on("connection", ws => {  	 * array.  	 */  	ws.on("close", () => { -		if (game.ongoing) { +		if (game.ongoing && env.games.includes(game)) {  			game.messageOpponent({ head: Messages.DISCONNECT }, ws)  			stats.ongoingGames-- +			stats.totalGames--  		} -		stats.totalGames--  		env.removeGame(game)  	}) @@ -70,10 +70,11 @@ wss.on("connection", ws => {  		msg = JSON.parse(msg)  		switch (msg.head) {  		case Messages.RESIGN: -			if (game.ongoing) +			if (game.ongoing && env.games.includes(game)) {  				game.messageOpponent(msg, ws) -			stats.ongoingGames-- -			stats.totalGames-- +				stats.ongoingGames-- +				stats.totalGames-- +			}  			env.removeGame(game)  			break  		case Messages.MOVED: |