Add bomb cards feature for multi-deck games#498
Merged
Conversation
When playing with 4+ decks, players can now use "bombs" (4+ identical cards) that beat any play of the same card count. A bomb of higher rank beats a lower-rank bomb, and a trump bomb beats a non-trump bomb. The feature is disabled by default and can be enabled via game settings. https://claude.ai/code/session_01E543mMXuFZfstF526sWFy1
Expand BombPolicy from a simple on/off toggle to three options: - NoBombs: bombs disabled (default) - AllowBombs: bombs can be played regardless of suit - AllowBombsSuitFollowing: bombs must follow suit (same suit as led, trump bombs always allowed, off-suit only when void in led suit) This gives players the choice between house rules (any suit) and standard Chinese rules (must follow suit) for bomb plays. https://claude.ai/code/session_01E543mMXuFZfstF526sWFy1
- Deduplicate suit-counting in is_legal_play by extracting a closure - Convert winner() to &self method (compute_winner), eliminating 5 parameters - Use played_card_mappings to detect bombs in compute_winner instead of re-calling is_bomb on raw cards - Unify bomb-beats-bomb and bomb-beats-non-bomb branches - Simplify bomb comparison: cmp_effective already handles trump > non-trump - Simplify is_bomb to use plain Card equality (no OrderedCard needed) - Use filter_map instead of flat_map with Option in new code Net reduction of 73 lines. https://claude.ai/code/session_01E543mMXuFZfstF526sWFy1
Add a new pc! macro variant with bomb_policy parameter (using semicolon separator to avoid ambiguity with existing variants). Replace all verbose PlayCards struct literals in bomb tests with the compact macro form. Net reduction of 382 lines of test boilerplate. https://claude.ai/code/session_01E543mMXuFZfstF526sWFy1
Replace .is_multiple_of(2) with % 2 == 0 since unsigned_is_multiple_of is still an unstable Rust feature and the Docker build image uses a stable toolchain that doesn't support it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
is_multiple_of is now stable and required by clippy::manual_is_multiple_of. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
Adds support for "bomb" plays in multi-deck games — 4+ identical cards played together that beat any other play of the same size.
BombPolicyenum with three variants:NoBombs— disabled (default, backward-compatible)AllowBombs— bombs can be played regardless of suitAllowBombsSuitFollowing— bombs must follow the led suit (standard Chinese rules); trump bombs always allowedpc!macro to reduce boilerplateCommits
Add bomb cards feature for multi-deck games— core implementationAdd suit-following variant for bomb policy— expanded policy optionsSimplify bomb logic in trick.rs— refactor/cleanup (-73 lines)Refactor bomb tests to use pc! macro— test cleanup (-382 lines)Fix frontend formatting for gen-types.d.tsFix unstable is_multiple_of usage breaking wasm build—is_multiple_ofis unstable; replaced with% 2 == 0Move build image into repo and add weekly rebuild workflow— the build image (ghcr.io/rbtying/shengji-build-image) is now managed in this repo with weekly rebuilds to keep the Rust toolchain current🤖 Generated with Claude Code