Skip to content

fix: settle blackjack naturals before comparing totals - #48

Merged
XxFran10xX merged 1 commit into
mainfrom
blackjack-natural
Oct 23, 2026
Merged

XxFran10xX merged 1 commit into
mainfrom
blackjack-natural

Conversation

@XxFran10xX

Copy link
Copy Markdown
Contributor

What was wrong

BlackjackGame.settle compared totals before it looked at naturals. A natural only changed the payout (3:2), not who won, so:

  • a player natural against a dealer who drew to 21 with three or more cards was a push;
  • a dealer natural against a player 21 made with three or more cards (or after a split) was also a push.

What changes

Settlement now checks for naturals first, as in standard blackjack:

Player Dealer Before After
natural 21 with 3+ cards push win, 3:2
21 with 3+ cards, or a split ace + ten natural push lose
natural natural push push
split ace + ten (21, not a natural) anything but a natural unchanged unchanged, even money

A dealer natural is a dealer pile of exactly two cards totalling 21. The dealer never draws on 21, so a two-card pile at the settle always holds the two dealt cards. isNatural for players is unchanged (unsplit, two cards, 21).

Everything else stays as it was: the soft-17 setting, no insurance or surrender, the (bet * 3) / 2 rounding, and the house bank, guild reserve and tray logic. The worst-case reserve still covers every win, because this only turns some pushes into wins (3:2 was already reserved) or into losses.

Dealer peek

The dealer does not peek. The hole card is dealt face down and only turned over in the dealer phase. Players act first, then the dealer reveals and draws, and the round is settled. The fix does not need a peek, so I did not add one.

What this means at the table: players can double or split before anyone knows the dealer has a natural, and a dealer natural now takes those extra stakes as well. A hand that doubled or split to 21 used to push against a dealer natural; now it loses everything on it. Hands under 21 already lost the full doubled or split stake to a dealer natural before this PR. This is the European no-hole-card "dealer takes all" rule. If fran wants US rules instead (peek on an ace or ten up, end the round at once on a dealer natural, so only the original bet is at risk), that would be a separate change.

Help book

The jar's help.yml now has a new blackjack page after "Getting paid":

Blackjack beats 21
Blackjack is 21 on your first two cards. It beats any other 21, yours or the dealer's.
A dealer blackjack also takes any doubles and splits.
Two blackjacks draw.

No existing page contradicted the corrected rule outright. "Getting paid" still says "Draw with the dealer and your money comes back", and the new page qualifies that. The live server's plugins/Games/help.yml is not updated automatically. To show the new page on Main, copy that page into the live file by hand.

Tests

New tests in BlackjackGameTest:

  • naturalBeatsADealerWhoDrawsToTwentyOne: A+K against a dealer who draws 10+5+6 is paid 30 on a 20 bet and gets bet.natural.
  • dealerNaturalBeatsAPlayerWhoDrawsToTwentyOne: 5+6+10 against a dealer A+K loses the 20 stake to the dealer.
  • twoNaturalsPush: A+10 against a dealer A+K is a push with no win payment.
  • splitAceAndTenIsTwentyOneButNotANatural (regression): split aces both catch a ten-value card and are paid 40 (1:1 on each 20 hand), with no bet.natural.
  • splitAceAndTenLosesBothStakesToADealerNatural: split ace + ten against a dealer natural loses both stakes (40).

Local Windows run with the usual temporary DurableFiles fsync patch (not committed): all 132 BlackjackGameTest tests pass. Only the 12 known Windows-only TableManagerPersistenceTest/TableManagerLifecycleTest failures remain. Linux CI is authoritative.

No version bump: the pom stays at main-SNAPSHOT, as in the recent PRs. No tag or release.

🤖 Generated with Claude Code

A natural (ace and ten-value card as the first two cards of an unsplit
hand) now beats any other 21 on either side: a player natural is paid
3 to 2 against a dealer who draws to 21, a dealer natural takes a player
hand that reached 21 with more cards or after a split, and two naturals
push. Split ace-and-ten stays 21 paid even money.

The help book gains a page saying so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 90b437c1-d9ca-42b8-8a61-7fd8a1cbe305
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the size:S 10-29 effective changed lines (tests excluded in mixed PRs). label Oct 23, 2026
@XxFran10xX
XxFran10xX merged commit 8c23d50 into main Oct 23, 2026
3 checks passed
@XxFran10xX
XxFran10xX deleted the blackjack-natural branch October 23, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant