Repository navigation
fix: settle blackjack naturals before comparing totals - #48
Merged
Merged
Conversation
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>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
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.
What was wrong
BlackjackGame.settlecompared totals before it looked at naturals. A natural only changed the payout (3:2), not who won, so:What changes
Settlement now checks for naturals first, as in standard blackjack:
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.
isNaturalfor players is unchanged (unsplit, two cards, 21).Everything else stays as it was: the soft-17 setting, no insurance or surrender, the
(bet * 3) / 2rounding, 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.ymlnow has a new blackjack page after "Getting paid":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.ymlis 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 getsbet.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 nobet.natural.splitAceAndTenLosesBothStakesToADealerNatural: split ace + ten against a dealer natural loses both stakes (40).Local Windows run with the usual temporary
DurableFilesfsync patch (not committed): all 132BlackjackGameTesttests pass. Only the 12 known Windows-onlyTableManagerPersistenceTest/TableManagerLifecycleTestfailures 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