aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/blackjack_rules_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-24 19:31:05 -0400
committerhistoria <[not public]>2026-09-24 19:31:05 -0400
commitd114c747a7672c7e4daab3a5b5f1b2f066ebc912 (patch)
tree81cc03354561f2f631d68f0de28bc742b1f49114 /internal/casino/blackjack_rules_test.go
parentf606db40c3290fd9ce40b53ef9bbe135b1e6f6e2 (diff)
downloadthehouseoficarus-d114c747a7672c7e4daab3a5b5f1b2f066ebc912.tar.gz
feat: additional baca and bj rules variants
Diffstat (limited to 'internal/casino/blackjack_rules_test.go')
-rw-r--r--internal/casino/blackjack_rules_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/internal/casino/blackjack_rules_test.go b/internal/casino/blackjack_rules_test.go
new file mode 100644
index 0000000..62f4d0a
--- /dev/null
+++ b/internal/casino/blackjack_rules_test.go
@@ -0,0 +1,49 @@
+package casino
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestBlackjackRuleCardDefaultsAndOverrides(t *testing.T) {
+ yes, no := true, false
+ cases := []struct {
+ cfg BlackjackConfig
+ want []string
+ }{
+ {BlackjackConfig{}, []string{"Number of decks: 8", "Blackjack pays 3:2", "Dealer stands on soft 17", "Double after split: Yes", "Maximum split hands: 4", "Surrender: Not offered"}},
+ {BlackjackConfig{Decks: 1, BlackjackPayout: 1.2, DealerHitSoft17: &yes, DoubleAfterSplit: &no, MaxSplitHands: 2, DoubleSplitBlackjack: &no}, []string{"Number of decks: 1", "Blackjack pays 6:5", "Dealer hits soft 17", "Double after split: No", "Re-splitting: No", "Split-and-doubled 21 receives blackjack payout: No"}},
+ {BlackjackConfig{Decks: 6, ResplitAces: &yes, Surrender: &yes}, []string{"Number of decks: 6", "Re-splitting aces: Yes", "Surrender: Late"}},
+ }
+ for _, tc := range cases {
+ cfg := TableConfig{ID: "test", Game: GameBlackjack, Blackjack: tc.cfg}
+ text := cfg.BlackjackRulesText()
+ for _, want := range tc.want {
+ if !strings.Contains(text, want) {
+ t.Errorf("missing %q in %s", want, text)
+ }
+ }
+ table := newBlackjackTable(42, cfg, newTestRand())
+ events := table.join("alice")
+ found := false
+ for _, e := range events {
+ if e.Message == text {
+ found = true
+ if e.Public {
+ t.Error("rules broadcast to bystanders")
+ }
+ }
+ }
+ if !found {
+ t.Fatal("joining did not display effective rules")
+ }
+ }
+}
+
+func TestSixToFiveNaturalPayout(t *testing.T) {
+ hand := &blackjackHand{bet: 10, cards: []card{{rank: "A"}, {rank: "K"}}}
+ _, payout, err := settleHand(hand, 20, false, BlackjackConfig{BlackjackPayout: 1.2})
+ if err != nil || payout != 22 {
+ t.Fatalf("payout=%d err=%v", payout, err)
+ }
+}