diff options
Diffstat (limited to 'internal/casino/craps_rules.go')
| -rw-r--r-- | internal/casino/craps_rules.go | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/internal/casino/craps_rules.go b/internal/casino/craps_rules.go index 86aa9bb..8d2f7d4 100644 --- a/internal/casino/craps_rules.go +++ b/internal/casino/craps_rules.go @@ -2,8 +2,7 @@ package casino import "fmt" -// CrapsConfig intentionally supports bank craps only. Other games must supply -// their own outcome rules, not silently inherit bank-craps probabilities. +// CrapsConfig selects explicit house rules and the shared wager limits. type CrapsConfig struct { Odds int `yaml:"odds,omitempty"` // 0 = 3-4-5x; positive = uniform Nx Field12 int `yaml:"field_12,omitempty"` @@ -23,14 +22,23 @@ func validateCraps(c TableConfig) error { if c.Craps.Field12 != 0 && c.Craps.Field12 != 2 && c.Craps.Field12 != 3 { return fmt.Errorf("craps field_12 must be 2 or 3") } - if c.Craps.Variant != "" && c.Craps.Variant != "bank" { - return fmt.Errorf("only bank craps is implemented") + switch c.Craps.variant() { + case "bank", "simplified", "high_point", "crapless", "new_york", "die_rich", "diceless": + default: + return fmt.Errorf("unknown craps variant %q", c.Craps.Variant) + } + if !c.Craps.allows("odds") && c.Craps.Odds != 0 { + return fmt.Errorf("this craps variant does not support odds") } return nil } func crapsNumber(n int) bool { return n == 4 || n == 5 || n == 6 || n == 8 || n == 9 || n == 10 } func crapsTrueOdds(n int) (int, int) { switch n { + case 2, 12: + return 6, 1 + case 3, 11: + return 3, 1 case 4, 10: return 2, 1 case 5, 9: @@ -43,6 +51,9 @@ func (c CrapsConfig) oddsLimit(n int, against bool) int { if c.Odds > 0 { return c.Odds } + if c.variant() == "crapless" && !crapsNumber(n) { + return 1 + } if against { return 6 } @@ -57,11 +68,18 @@ func (c CrapsConfig) oddsLimit(n int, against bool) int { } func (c TableConfig) CrapsRulesText() string { r := c.Craps.Normalize() + if r.variant() != "bank" && r.variant() != "diceless" { + return r.variantRulesText() + } + prefix := "" + if r.variant() == "diceless" { + prefix = "Diceless Craps — bank rules using cards, not dice. Two independent six-card packs labelled 1-6; draw one from each, replace and reshuffle BOTH after EVERY roll. All 36 ordered pairs are equally likely. No finite shoe or card counting.\n" + } odds := "3-4-5x (don't: 6x laid)" if r.Odds > 0 { odds = fmt.Sprintf("%dx", r.Odds) } - return fmt.Sprintf("Bank Craps | Free odds %s | Field 12 pays %d:1\n"+ + return prefix + fmt.Sprintf("Bank Craps | Free odds %s | Field 12 pays %d:1\n"+ "bet <amount> on pass / dontpass / come / dontcome / field\n"+ "bet <amount> on place 6 / buy 4 / lay 10 / hard 8 / hop 2 3\n"+ "bet <amount> on seven / craps / eleven / ace-deuce / aces / boxcars / horn\n"+ @@ -79,7 +97,7 @@ func (c TableConfig) CrapsRulesText() string { "Bets remain open until the roll. Dice rotate on seven-out.\n"+ "autoroll: repeat every 3 seconds on your turn (multiplayer waits 10 seconds).\n"+ "unbet <target>: remove non-contract bets/odds; pass/come contracts stay.\n"+ - "unbet all: return every optional bet and odds at once.\n"+ + "unbet all: return every optional bet and odds at once.\n"+ "stop cancels autoroll without leaving; in manual mode stop/sitout wait for bets.\n"+ "Disconnect forfeits live bets.\n"+ "Winning bets return stake and are removed (no automatic pressing).", odds, r.Field12) @@ -134,14 +152,7 @@ func crapsOutcome(kind string, n, a, b, point, field12 int) (bool, int, int) { x, y = y, x } if kind == "place" { - switch n { - case 4, 10: - x, y = 9, 5 - case 5, 9: - x, y = 7, 5 - default: - x, y = 7, 6 - } + x, y = crapsPlaceOdds(n) } return true, x, y case "hard": |
