aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/big_six_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/big_six_test.go')
-rw-r--r--internal/casino/big_six_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/casino/big_six_test.go b/internal/casino/big_six_test.go
index cccad77..04bc7e3 100644
--- a/internal/casino/big_six_test.go
+++ b/internal/casino/big_six_test.go
@@ -291,3 +291,49 @@ func TestBigSixSettlementFailureAndDeparture(t *testing.T) {
t.Fatal("departing player lost result visibility")
}
}
+
+func TestBigSixPartialTargets(t *testing.T) {
+ for _, tc := range []struct {
+ in string
+ want string
+ ok bool
+ }{
+ {"1", "1", true},
+ {"10", "10", true},
+ {"$20", "20", true},
+ {"sw", "SWORD", true},
+ {"SWO", "SWORD", true},
+ {"sword", "SWORD", true},
+ {"sh", "SHIELD", true},
+ {"shi", "SHIELD", true},
+ {"shield", "SHIELD", true},
+ {"s", "", false}, // SWORD or SHIELD
+ {"do", "", false}, // DOUBLE is automatic, not a wager
+ {"double", "", false}, // and its full name is not a wager either
+ {"", "", false},
+ {"99", "", false},
+ } {
+ got, ok := bigSixResolveTarget(tc.in)
+ if got != tc.want || ok != tc.ok {
+ t.Fatalf("bigSixResolveTarget(%q) = (%q,%v), want (%q,%v)", tc.in, got, ok, tc.want, tc.ok)
+ }
+ }
+ // A partial target must behave exactly like the full label at bet time,
+ // both in the stored wager and in the house-edge reference.
+ cfg := TableConfig{Game: GameBigSix}
+ if e := cfg.HouseEdge("sw"); len(e.Parts) != 1 || e.Parts[0].Loss != 1.0/49 {
+ t.Fatalf("partial house edge: %+v", e)
+ }
+ table := newBigSixTest()
+ table.join("a")
+ w := &recordingWallet{testWallet: testWallet{credits: 100}}
+ table.bet("a", "sw", 5, w)
+ table.bet("a", "sh", 7, w)
+ bets := table.players.get("a").bets
+ if len(w.open) != 2 || len(bets) != 2 || bets[0].spot != "SWORD" || bets[1].spot != "SHIELD" {
+ t.Fatalf("partial targets not canonicalized: %+v", bets)
+ }
+ if bigSixPayout("s") != 0 || bigSixPayout("sw") != 48 || bigSixPayout("sh") != 48 {
+ t.Fatal("partial payout")
+ }
+}