Skip to content

Multiple free-space tiles can render an incomplete card #13

Description

@YoyoJesus

Problem

The admin UI permits multiple isFreeSpace tiles. effectivePoolSize subtracts every free space after the first, but getCardSize still returns the minimum size of 5. pickCardWithFreeSpace then drops all but one free-space tile and can return fewer than 25 cells. tooFewTiles uses the raw tile count, so it does not prevent rendering.

Reproduction

  1. Create a 25-tile pool with two tiles marked Free.
  2. Open /bingo.

The effective pool is 24, the selected card has 23 regular tiles plus one centered free space (24 total), and the UI renders only 24 cells in a 5-column grid. The core calculation reproduces as { effectivePoolSize: 24, cardSize: 5, renderedTiles: 24 }.

Suggested fix

Validate or enforce exactly zero or one free-space tile, or base the availability check on the effective pool and require cardSize ** 2 selected tiles before showing the board. The tile admin should prevent the invalid configuration or clearly normalize extra free spaces.

Affected code

  • src/lib/bingo.ts
  • src/lib/server/cardShuffle.ts
  • src/routes/bingo/+page.server.ts
  • src/routes/admin/tiles/+page.server.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions