Skip to content

Add bomb cards feature for multi-deck games#498

Merged
rbtying merged 8 commits intomasterfrom
claude/add-bomb-cards-feature-tx77u
Mar 19, 2026
Merged

Add bomb cards feature for multi-deck games#498
rbtying merged 8 commits intomasterfrom
claude/add-bomb-cards-feature-tx77u

Conversation

@rbtying
Copy link
Owner

@rbtying rbtying commented Mar 5, 2026

Summary

Adds support for "bomb" plays in multi-deck games — 4+ identical cards played together that beat any other play of the same size.

  • BombPolicy enum with three variants:
    • NoBombs — disabled (default, backward-compatible)
    • AllowBombs — bombs can be played regardless of suit
    • AllowBombsSuitFollowing — bombs must follow the led suit (standard Chinese rules); trump bombs always allowed
  • Bombs beat non-bomb plays of the same size; between two bombs, higher rank wins and trump beats non-trump
  • Game setting exposed in the UI (only for 4+ deck games)
  • Comprehensive test coverage using a pc! macro to reduce boilerplate

Commits

  • Add bomb cards feature for multi-deck games — core implementation
  • Add suit-following variant for bomb policy — expanded policy options
  • Simplify 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.ts
  • Fix unstable is_multiple_of usage breaking wasm buildis_multiple_of is unstable; replaced with % 2 == 0
  • Move 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

claude and others added 7 commits March 5, 2026 06:20
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>
@rbtying rbtying changed the title Add bomb card support to trick evaluation Add bomb cards feature for multi-deck games Mar 17, 2026
is_multiple_of is now stable and required by clippy::manual_is_multiple_of.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rbtying rbtying merged commit 88a9e23 into master Mar 19, 2026
4 checks passed
@rbtying rbtying deleted the claude/add-bomb-cards-feature-tx77u branch March 19, 2026 05:01
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