From 2875444a06efde2be79a90cf180f2e9e6a4794d8 Mon Sep 17 00:00:00 2001 From: Eugene Toder Date: Thu, 12 Dec 2024 22:19:24 -0500 Subject: [PATCH] Make sure if the board is expanded the newest cards are always in the bottom row. One of them must be a member of the SET. --- src/util.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/util.js b/src/util.js index f9c2d05..d89dd93 100644 --- a/src/util.js +++ b/src/util.js @@ -247,12 +247,13 @@ function hasUsedCards(used, cards) { } function removeCards(internalGameState, cardIndexes, newBoardSize) { - const { current, boardSize } = internalGameState; + const { current, boardSize, minBoardSize } = internalGameState; + const cutoff = Math.min(newBoardSize, minBoardSize); for (const [i, ci] of cardIndexes.entries()) { - if (ci >= newBoardSize) { + if (ci >= cutoff) { current.splice(ci, 1); } else { - const start = Math.min(boardSize, newBoardSize); + const start = Math.min(boardSize, cutoff); const len = cardIndexes.length - i; for (const [j, c] of current.splice(start, len).entries()) { current[cardIndexes[i + j]] = c;