Skip to content

fix: meld builder validation for red fives and chi sequences#7

Merged
rysb-dev merged 1 commit intomainfrom
fix/meld-builder-validation
Jan 30, 2026
Merged

fix: meld builder validation for red fives and chi sequences#7
rysb-dev merged 1 commit intomainfrom
fix/meld-builder-validation

Conversation

@rysb-dev
Copy link
Copy Markdown
Owner

Summary

Fixes two bugs in the meld builder UI:

Bug 1: Red Five Duplicate Selection

Previously, when using the pon/chi/kan meld builder, users could add more than one red five (aka dora) of the same suit (e.g., 0p, 0p, 0p). The fix:

  • Include meld builder tiles in tileCounts so the palette updates in real-time as tiles are selected
  • Properly check red five availability using the separate red5m/red5p/red5s count keys
  • Update TilePalette to check both disabled tiles and proper counts for red fives

Bug 2: Invalid Chi Meld Sequences

Previously, the chi meld builder allowed any tiles of the same suit, even non-consecutive ones (e.g., 5p5p5p or 2m4m6m). Now:

  • Added getChiAllowedTiles() function that computes valid tiles based on current selection
  • First tile: any numbered (non-honor) tile
  • Second tile: same suit, within ±2 of first tile, able to complete a sequence
  • Third tile: only the tile that completes the 3-consecutive sequence
  • Invalid tiles are visually grayed out and unclickable in the palette

Bonus: Pon/Kan Improvement

For pon/kan/ankan melds, after the first tile is selected, all other tile types are now disabled in the palette (previously only enforced in code, not visually).

Testing

  • npm run check passes (only pre-existing a11y warnings)
  • npm run build succeeds
  • Manual testing recommended for the meld builder flows

- Include meld builder tiles in tileCounts so palette updates in real-time
- Properly check red five availability (red5m/red5p/red5s counts)
- Add chi sequence validation: only allow tiles that can form valid sequences
- Disable invalid tiles visually in the palette during meld building
- For pon/kan: after first tile, only that tile type is selectable
@rysb-dev rysb-dev self-assigned this Jan 30, 2026
@rysb-dev rysb-dev merged commit c6201ae into main Jan 30, 2026
6 checks passed
@rysb-dev rysb-dev deleted the fix/meld-builder-validation branch January 30, 2026 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant