Add rainbow tricks format via CompoundFormats#508
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
https://claude.ai/code/session_015xegeMnZfbHPRdnUo1Cv8c