Skip to content

Add rainbow tricks format via CompoundFormats#508

Merged
rbtying merged 8 commits intomasterfrom
claude/add-rainbow-tricks-VmAEs
Mar 30, 2026
Merged

Add rainbow tricks format via CompoundFormats#508
rbtying merged 8 commits intomasterfrom
claude/add-rainbow-tricks-VmAEs

Conversation

@rbtying
Copy link
Copy Markdown
Owner

@rbtying rbtying commented Mar 28, 2026

Rainbow tricks require cards all of the same rank spanning at least 4
distinct effective suits, with a configurable minimum card count
(default: num_decks * 2 + 1). Following players must play a rainbow
bomb (same rank, same count) if available; highest rank wins.

  • Add CompoundFormats struct with rainbows: Option field
  • Add is_rainbow to TrickFormat; thread through trick mechanics
  • Implement rainbow detection, legal-play, and winner logic in trick.rs
  • Add rainbow-specific tests (9 new tests)
  • Add SetCompoundFormats action/message in core
  • Thread compound_formats through PropagatedState and play phase
  • Add rainbow settings UI in Initialize.tsx (UncommonSettings)
  • Add rainbow visual indicator in Trick.tsx
  • Add rainbow help text in Play.tsx HelperContents
  • Regenerate TypeScript types to include CompoundFormats/is_rainbow

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c

claude added 8 commits March 28, 2026 06:02
Rainbow tricks require cards all of the same rank spanning at least 4
distinct effective suits, with a configurable minimum card count
(default: num_decks * 2 + 1). Following players must play a rainbow
bomb (same rank, same count) if available; highest rank wins.

- Add CompoundFormats struct with rainbows: Option<usize> field
- Add is_rainbow to TrickFormat; thread through trick mechanics
- Implement rainbow detection, legal-play, and winner logic in trick.rs
- Add rainbow-specific tests (9 new tests)
- Add SetCompoundFormats action/message in core
- Thread compound_formats through PropagatedState and play phase
- Add rainbow settings UI in Initialize.tsx (UncommonSettings)
- Add rainbow visual indicator in Trick.tsx
- Add rainbow help text in Play.tsx HelperContents
- Regenerate TypeScript types to include CompoundFormats/is_rainbow

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
- Clarify rainbow bomb definition: "same number of cards as the trick,
  all of the same rank" instead of vague "enough cards"
- Fix misleading phrasing: "if no follower plays a rainbow bomb, the
  leader wins" (leader always plays one by definition)
- Resolve rebase conflict with master's new regression tests:
  add is_rainbow: false to new TrickFormat struct literals and
  CompoundFormats::default() to new from_cards() call

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
Rainbows are unrelated to bombs in Shengji. Rename hand_has_rainbow_bomb
to hand_has_rainbow, update all comments, test names, and UI text to
use 'rainbow' consistently instead of 'rainbow bomb'.

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
When the trick format is a rainbow, instead of the normal suit-based
decomposition, scan the player's hand for same-rank groups of the
required size. Return each valid group as a playable option.

This makes both the ? helper modal (now shows clickable rainbow options)
and the ✨ suggest button work correctly for rainbow tricks.

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
Replace the two obligation tests that called is_legal_play directly with
versions that go through Trick::play_cards. Both tests now also verify
the trick completes and the correct winner is returned, exercising the
can_play_cards → is_legal_play → compute_rainbow_winner path end-to-end.

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
A rainbow throw consists of multiple units each independently forming a
valid rainbow (same rank spanning ≥4 suits). This extends single-unit
rainbow leads to allow compound plays like "4 fives + 4 eights".

Changes:
- `from_cards`: try `try_multi_rainbow_format` after single rainbow detection
- `can_play_cards`: accept multi-rainbow leads as valid
- `is_legal_play`: use `can_satisfy_rainbow_units` (backtracking assignment
  by rank) for both single- and multi-unit rainbow obligation checks
- Throw validation: rainbow throws check by rank (any opponent with ≥count
  cards of a higher rank invalidates the corresponding unit)
- Forced-card extraction: for rainbow throws, extract matching-number cards
  from the played set rather than duplicating the representative card
- `compute_rainbow_winner`: use `rainbow_play_combo` for multi-unit rank
  comparison (greedy highest-rank-first assignment)
- Remove now-unused `hand_has_rainbow` helper
- Add tests: detection, obligation, winner comparison, throw invalidation

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
The multi-unit case is a strict generalization of the single-unit case:
group by rank, require each group to independently span ≥4 suits and
have ≥min_cards cards. A single qualifying group produces a 1-unit format;
multiple groups produce a throw. Remove the now-redundant single-unit
helper and the dead `rainbow_number` function.

https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c
@rbtying rbtying merged commit 7fb1246 into master Mar 30, 2026
4 checks passed
@rbtying rbtying deleted the claude/add-rainbow-tricks-VmAEs branch March 30, 2026 15:42
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.

2 participants