Skip to content

Commit

Permalink
Make sure if the board is expanded
Browse files Browse the repository at this point in the history
the newest cards are always in the bottom row. One of them must be a
member of the SET.
  • Loading branch information
eltoder committed Dec 13, 2024
1 parent 5cc5850 commit 2875444
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2875444

Please sign in to comment.