diff options
Diffstat (limited to 'internal/casino/craps_regression_test.go')
| -rw-r--r-- | internal/casino/craps_regression_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/internal/casino/craps_regression_test.go b/internal/casino/craps_regression_test.go new file mode 100644 index 0000000..322325c --- /dev/null +++ b/internal/casino/craps_regression_test.go @@ -0,0 +1,51 @@ +package casino + +import ( + "testing" +) + +func TestCrapsLargestStakeAndOddsLimit(t *testing.T) { + tb := crapsFixture() + tb.Config.MaxBet = MaxCredits / 1000 + tb.Config.Craps.Odds = 1000000 + tb.join("a") + w := &testWallet{chips: MaxCredits} + amount := tb.Config.MaxBet + tb.bet("a", "pass", amount, w) + tb.resolveRoll(2, 2) + tb.bet("a", "odds pass", amount, w) + if len(w.open) != 2 { + t.Fatal("valid large odds rejected") + } +} +func TestCrapsHopIsUnordered(t *testing.T) { + tb := crapsFixture() + tb.join("a") + w := &testWallet{chips: 100} + tb.bet("a", "hop 3 2", 10, w) + tb.bet("a", "hop 2 3", 10, w) + if len(w.open) != 1 || w.chips != 90 { + t.Fatal("duplicate unordered hop accepted") + } + tb.action("a", "unbet hop 3 2") + if len(w.open) != 0 || w.paid != 10 || w.chips != 90 { + t.Fatal("reverse-order removal failed") + } +} +func TestCrapsMixedPairPreviewCombinesAllBets(t *testing.T) { + tb := crapsFixture() + tb.join("a") + w := &testWallet{chips: 1000} + tb.point = 8 + tb.bet("a", "hard 8", 10, w) + tb.bet("a", "hop 2 3", 10, w) + tb.bet("a", "field", 10, w) + for _, row := range tb.projectionFor(tb.players.get("a")) { + if row.Rolls == "4+4" && row.Net != 70 { + t.Fatal("hard win minus hop and field losses", row) + } + if row.Rolls == "2+3" && row.Net != 140 { + t.Fatal("hop win minus field loss", row) + } + } +} |
