From 6ec14cdc888dcc90590c1a430a52fbf35e1e2b70 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Fri, 22 Jan 2021 20:56:31 -0500 Subject: [PATCH] Fix --- commands/games-mp/nim.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/commands/games-mp/nim.js b/commands/games-mp/nim.js index 8b1a59dc..ce86cb6b 100644 --- a/commands/games-mp/nim.js +++ b/commands/games-mp/nim.js @@ -209,7 +209,11 @@ module.exports = class NimCommand extends Command { } } } - const randomRow = Math.floor(Math.random() * board.length); + const validRows = []; + for (const row of board) { + if (row !== 0) validRows.push(row); + } + const randomRow = validRows[Math.floor(Math.random() * validRows.length)]; const amount = board[randomRow]; board[randomRow] -= amount; return [randomRow, amount];