diff options
Diffstat (limited to 'internal/casino')
| -rw-r--r-- | internal/casino/craps.go | 24 | ||||
| -rw-r--r-- | internal/casino/craps_clock.go | 23 | ||||
| -rw-r--r-- | internal/casino/craps_clock_test.go | 24 | ||||
| -rw-r--r-- | internal/casino/craps_projection.go | 64 | ||||
| -rw-r--r-- | internal/casino/craps_test.go | 5 | ||||
| -rw-r--r-- | internal/casino/craps_ux.go | 45 | ||||
| -rw-r--r-- | internal/casino/craps_wagers.go | 124 |
7 files changed, 168 insertions, 141 deletions
diff --git a/internal/casino/craps.go b/internal/casino/craps.go index 8322192..3bbb08f 100644 --- a/internal/casino/craps.go +++ b/internal/casino/craps.go @@ -37,7 +37,8 @@ type crapsTable struct { roundElapsed time.Duration multiplayer bool lastCall bool - countdown int // simplified craps: automatic-roll countdown lines emitted + pendingRoll time.Duration // manual roll: time left before the dice resolve + countdown int // simplified craps: automatic-roll countdown lines emitted } type CrapsBetView struct { Name, Target string @@ -111,6 +112,9 @@ func (t *crapsTable) board(_ string) Snapshot { } func (t *crapsTable) menu(name string) Event { e := t.betMenuEvent(name, t.commands(name)) + if e.Menu != nil { + e.Menu.Heading = t.shooterHeading() + } e.Snapshot = t.view() return e } @@ -130,6 +134,10 @@ func (t *crapsTable) join(name string) []Event { } func (t *crapsTable) remove(name string) { t.countdown = 0 + if len(t.queue) > 0 && t.queue[0] == name { + // The queued roll belongs to the shooter; a departing shooter cancels it. + t.pendingRoll = 0 + } t.removeSeatLocked(name) for i, n := range t.queue { if n == name { @@ -457,6 +465,12 @@ func (t *crapsTable) action(name, action string) []Event { if p == nil { return []Event{t.private(name, "You aren't playing craps.")} } + if action == "leave_after" { + p.LeaveAfter = true + events := []Event{t.private(name, "You’ll leave after this round. Your live bets still need to settle.")} + events = append(events, t.finishCrapsControls()...) + return append(events, t.syncRoundClock()...) + } if events, ok := t.controlLocked(name, action); ok { events = append(events, t.finishCrapsControls()...) return append(events, t.syncRoundClock()...) @@ -485,7 +499,12 @@ func (t *crapsTable) action(name, action string) []Event { if t.multiplayer && t.roundElapsed < crapsBetDelay { return append(events, t.private(name, fmt.Sprintf("Others have time to bet: you can shoot in {casino_emphasis}%d seconds{/}. Bets remain open until you roll.", crapsSeconds(crapsBetDelay-t.roundElapsed)))) } - return append(events, t.roll()...) + if t.pendingRoll > 0 { + return append(events, t.private(name, "The dice are already in the air.")) + } + t.pendingRoll = crapsManualRollDelay + shake := t.playerAction(name, fmt.Sprintf("{casino_emphasis}%s shakes the dice...{/}", name), "{casino_emphasis}You shake the dice...{/}") + return append(events, shake) } if action == "unbet" { return append(t.unbetAllLocked(p), t.finishCrapsControls()...) @@ -593,6 +612,7 @@ func (t *crapsTable) refundAll() []Event { t.point = 0 t.rolled = false t.countdown = 0 + t.pendingRoll = 0 t.made = map[int]bool{} t.seen = map[int]bool{} t.phase = phaseWaiting diff --git a/internal/casino/craps_clock.go b/internal/casino/craps_clock.go index bbba19e..ab28329 100644 --- a/internal/casino/craps_clock.go +++ b/internal/casino/craps_clock.go @@ -13,6 +13,10 @@ const ( // Simplified craps has no manual roll: one shared automatic countdown // starts with the first live bet and resolves every wager. crapsSimplifiedDelay = 3 * time.Second + + // A requested manual roll first shows the shake, then the outcome chart, + // then resolves the dice five ticks (three seconds) later. + crapsManualRollDelay = 3 * time.Second ) func crapsSeconds(d time.Duration) int { @@ -118,7 +122,24 @@ func (t *crapsTable) tickElapsed(elapsed time.Duration) []Event { } return events } - if elapsed <= 0 || !t.hasLiveBets() { + if elapsed <= 0 { + return events + } + if t.pendingRoll > 0 { + // A manual roll is in the air: no other deadline may fire first. Only + // the shake is announced now; the result follows when the dice land. + if !t.hasLiveBets() { + t.pendingRoll = 0 + return events + } + t.pendingRoll -= elapsed + if t.pendingRoll <= 0 { + t.pendingRoll = 0 + return append(events, t.roll()...) + } + return events + } + if !t.hasLiveBets() { return events } t.roundElapsed += elapsed diff --git a/internal/casino/craps_clock_test.go b/internal/casino/craps_clock_test.go index 8f606f9..f9ad445 100644 --- a/internal/casino/craps_clock_test.go +++ b/internal/casino/craps_clock_test.go @@ -71,6 +71,7 @@ func TestCrapsSoloAndRosterTransitions(t *testing.T) { t.Fatal("solo deadline", tb.view()) } tb.action("alice", "roll") + tb.tickElapsed(3 * time.Second) if tb.dice == [2]int{} { t.Fatal("solo could not roll") } @@ -196,7 +197,7 @@ func TestCrapsConsolidatedResultsAndBetNumbers(t *testing.T) { tb.join("alice") w := &testWallet{chips: 1000} events := tb.bet("alice", "pass", 10, w) - if !strings.Contains(crapsEventText(events), "ROLL RESULTS ON YOUR BETS") { + if !strings.Contains(crapsEventText(events), "ROLL OUTCOMES") { t.Fatal("no post-bet roll table") } tb.bet("alice", "dontpass", 10, w) @@ -204,7 +205,7 @@ func TestCrapsConsolidatedResultsAndBetNumbers(t *testing.T) { events = tb.resolveRoll(3, 4) balances, settlements := 0, 0 for _, e := range events { - if e.ShowBalance { + if e.ShowBalance || (e.Menu != nil && e.Menu.ShowBalance) { balances++ } if strings.Contains(e.Message, "Pass [5]:") || strings.Contains(e.Message, "Pass [5]") { @@ -258,18 +259,18 @@ func TestCrapsUnbetAllAndRollTableFormat(t *testing.T) { if w.paid != before+40 { t.Fatal("second unbet all moved money", w.paid) } - // Roll table formatting: grouped totals, single-level tags only. + // Roll outcome line: every total once, single-level tags only. tb2 := crapsFixture() tb2.join("alice") w2 := &testWallet{chips: 100} tb2.bet("alice", "pass", 1, w2) table := tb2.rollTable(tb2.players.get("alice")) - for _, tag := range []string{"{casino_payout}7{/}", "{casino_result_win}+1{/}", "{casino_payout}2{/}", "{casino_result_loss}-1{/}"} { + for _, tag := range []string{"{casino_result_win}7(+1){/}", "{casino_result_loss}2(-1){/}", "{dim}4(-){/}"} { if !strings.Contains(table, tag) { t.Fatal("missing", tag, table) } } - if strings.Contains(table, "{casino_muted}") || strings.Contains(table, "{casino_result_win}+{") { + if strings.Contains(table, "{casino_muted}") || strings.Contains(table, "{casino_result_win}+") { t.Fatal("nested or unknown tag", table) } } @@ -282,12 +283,12 @@ func TestCrapsRollTableHardPairLabels(t *testing.T) { tb.bet("alice", "hop 2 3", 10, w) tb.point = 8 table := tb.rollTable(tb.players.get("alice")) - for _, want := range []string{"{casino_payout}4+4{/}", "{casino_result_win}+80{/}", "{casino_payout}2+3{/}", "{casino_result_win}+150{/}", "{casino_payout}2+6{/}", "{casino_result_loss}-20{/}"} { + for _, want := range []string{"{casino_result_win}5(+150){/}", "{casino_result_win}8(+80){/}", "{casino_result_loss}7(-20){/}"} { if !strings.Contains(table, want) { t.Fatal("missing", want, table) } } - // Bets paying on the same total combine into one row. + // Bets paying on the same total combine into one entry. tb2 := crapsFixture() tb2.join("alice") w2 := &testWallet{chips: 100} @@ -295,15 +296,16 @@ func TestCrapsRollTableHardPairLabels(t *testing.T) { tb2.bet("alice", "place 8", 12, w2) tb2.point = 8 table = tb2.rollTable(tb2.players.get("alice")) - if strings.Count(table, "{casino_payout}8{/}") != 1 || !strings.Contains(table, "{casino_result_win}+4{/}") { - t.Fatal("same-label payouts must combine", table) + if strings.Count(table, "8(") != 1 || !strings.Contains(table, "{casino_result_win}8(+4){/}") { + t.Fatal("same-total payouts must combine", table) } - // Hard bets alone on the come-out pay nothing and say so. + // Hard bets alone on the come-out are off: every total is dim. tb3 := crapsFixture() tb3.join("alice") w3 := &testWallet{chips: 100} tb3.bet("alice", "hard 8", 10, w3) - if text := tb3.rollTable(tb3.players.get("alice")); !strings.Contains(text, "OFF on the come-out") { + text := tb3.rollTable(tb3.players.get("alice")) + if !strings.Contains(text, "{dim}8(-){/}") || strings.Contains(text, "casino_result_win") || strings.Contains(text, "casino_result_loss") { t.Fatal(text) } } diff --git a/internal/casino/craps_projection.go b/internal/casino/craps_projection.go index c36f69f..1377452 100644 --- a/internal/casino/craps_projection.go +++ b/internal/casino/craps_projection.go @@ -95,53 +95,39 @@ func crapsBonusComplete(lo, hi int, seen map[int]bool, next int) bool { } return true } + +// rollTable previews the next roll as one compact line of every total 2-12 +// (1-6 on the single-die table): wins are bold green, losses bold red, and +// totals no open wager settles are dim. Hardway and hop bets are pair +// specific, so the best pair outcome stands in for that total. func (t *crapsTable) rollTable(p *crapsPlayer) string { - agg := map[string]int{} - pairsMatter := false - for _, bet := range p.bets { - if bet.kind == "hard" || bet.kind == "hop" { - pairsMatter = true - } + if len(p.bets) == 0 { + return "" } + best := map[int]int{} + found := map[int]bool{} for _, row := range t.projectionFor(p) { - label := fmt.Sprint(row.Total) - if pairsMatter { - label = row.Rolls - } - if row.Net != 0 { - agg[label] = row.Net + if !found[row.Total] || row.Net > best[row.Total] { + best[row.Total] = row.Net + found[row.Total] = true } } - if len(agg) == 0 { - if len(p.bets) == 0 { - return "No open wagers." - } - return "{casino_action}No wager settles on the next roll; contracts remain live. Place/buy/hardways are OFF on the come-out.{/}" + lo, hi := 2, 12 + if t.Config.Craps.variant() == "die_rich" { + lo, hi = 1, 6 } - labels := []string{} - for label := range agg { - labels = append(labels, label) - } - sort.Slice(labels, func(i, j int) bool { - ni, nj := agg[labels[i]], agg[labels[j]] - if (ni > 0) != (nj > 0) { - return ni > 0 - } - if ni != nj { - return ni > nj - } - return labels[i] < labels[j] - }) var sb strings.Builder - sb.WriteString("{casino_emphasis}ROLL RESULTS ON YOUR BETS{/}\n") - for _, label := range labels { - net := agg[label] - tag, amount := "casino_result_loss", fmt.Sprint(net) - if net > 0 { - tag, amount = "casino_result_win", "+"+amount + sb.WriteString("{casino_emphasis}ROLL OUTCOMES{/}:") + for total := lo; total <= hi; total++ { + token := fmt.Sprintf("%d(-)", total) + tag := "dim" + switch { + case found[total] && best[total] > 0: + token, tag = fmt.Sprintf("%d(+%d)", total, best[total]), "casino_result_win" + case found[total] && best[total] < 0: + token, tag = fmt.Sprintf("%d(%d)", total, best[total]), "casino_result_loss" } - fmt.Fprintf(&sb, " {casino_payout}%s{/}%s {%s}%s{/}\n", label, strings.Repeat(" ", max(1, 10-len(label))), tag, amount) + fmt.Fprintf(&sb, " {%s}%s{/}", tag, token) } - sb.WriteString("{casino_action}Hardways and hops name their pair; totals cover both orders.{/}") return sb.String() } diff --git a/internal/casino/craps_test.go b/internal/casino/craps_test.go index 603aedb..3d92e5e 100644 --- a/internal/casino/craps_test.go +++ b/internal/casino/craps_test.go @@ -250,6 +250,10 @@ func TestCrapsTimersControlsAndRefunds(t *testing.T) { t.Fatal("bets must remain open until the roll") } tb.action("a", "roll") + if tb.dice != [2]int{} { + t.Fatal("roll resolved before the shake") + } + tb.tickElapsed(3 * time.Second) if tb.dice == [2]int{} { t.Fatal("no roll") } @@ -262,6 +266,7 @@ func TestCrapsTimersControlsAndRefunds(t *testing.T) { t.Fatal("solo players must never be forced to roll") } tb.action("a", "roll") + tb.tickElapsed(3 * time.Second) if tb.dice == [2]int{} { t.Fatal("solo manual roll stalled") } diff --git a/internal/casino/craps_ux.go b/internal/casino/craps_ux.go index d0d8a62..f41ad67 100644 --- a/internal/casino/craps_ux.go +++ b/internal/casino/craps_ux.go @@ -2,7 +2,6 @@ package casino import ( "fmt" - "strings" ) func (t *crapsTable) commands(name string) []MenuCommand { @@ -32,7 +31,7 @@ func (t *crapsTable) commands(name string) []MenuCommand { } if p.HasBet { if !simplified { - if t.shooter() == p && (!t.multiplayer || t.roundElapsed >= crapsBetDelay) { + if t.shooter() == p && (!t.multiplayer || t.roundElapsed >= crapsBetDelay) && t.pendingRoll == 0 { commands = append(commands, MenuCommand{Command: "roll", Desc: "Shoot now"}) } if !p.autoRoll { @@ -87,39 +86,27 @@ func crapsBetLabel(b *crapsBet) string { // Numbers describe covered targets, not a promise that every listed roll wins // (don't/lay bets oppose their number; bonus bets need complete sequences). -// betSummary lists each open wager, then the dice pairs that beat them. The +// betSummary lists the dice pairs that settle the player's open wagers. The // roll table shares payout math with settlement (crapsNet), so the numbers -// never promise a win a real roll cannot pay. +// never promise a win a real roll cannot pay. The open-bet list itself is no +// longer shown: the settlement wager table already names every stake. func (t *crapsTable) betSummary(p *crapsPlayer) Event { - text := "{casino_emphasis}YOUR BETS{/}" - if len(p.bets) == 0 { - text += " No active bets." - } else { - for _, b := range p.bets { - label := crapsBetLabel(b) - if strings.HasPrefix(b.kind, "dont") || b.kind == "lay" { - label += " (against)" - } - if t.point == 0 && (b.kind == "place" || b.kind == "buy" || b.kind == "hard") { - label += " (off)" - } - text += fmt.Sprintf("\n {casino_action}%-24s{/} {casino_chips}%d{/}", label, b.stake.Total) - if b.odds.Total > 0 { - text += fmt.Sprintf(" + %d odds", b.odds.Total) - if t.point == 0 && b.kind == "come" { - text += " (odds off)" - } - } - } + return t.private(p.Name, t.rollTable(p)) +} + +// shooterHeading names the current shooter for the join, status and reminder +// menus. The board no longer carries its own Shooter line. +func (t *crapsTable) shooterHeading() string { + if shooter := t.shooter(); shooter != nil { + return "Shooter " + shooter.Name } - e := t.private(p.Name, text+"\n"+t.rollTable(p)) - e.ShowBalance = true - return e + return "Shooter" } func (t *crapsTable) reminder(name string) Event { - e := t.private(name, "Your move") + heading := t.shooterHeading() + e := t.private(name, heading) e.Color = "casino_menu" - e.Menu = &MenuView{Heading: "Your move", Commands: t.commands(name)} + e.Menu = &MenuView{ShowBalance: true, Heading: heading, Commands: t.commands(name)} return e } func (t *crapsTable) settlementEvent(p *crapsPlayer, lines []settlementLine, failed bool) Event { diff --git a/internal/casino/craps_wagers.go b/internal/casino/craps_wagers.go index d9af87f..1c6da2f 100644 --- a/internal/casino/craps_wagers.go +++ b/internal/casino/craps_wagers.go @@ -2,15 +2,13 @@ package casino import ( "fmt" + "strings" ) -// Craps wager tables are built from the live table state: a come-out roll -// offers the line bets, the one-roll props and (before the shooter's first -// roll) the bonus bets; a point adds come, odds, place/buy/lay and the -// hardways. The variants substitute their own single-bet lists. Every entry -// pairs the bet wording with its payout and a one-line win condition, so the -// list doubles as the game's brief rule reminder. Payouts are profit odds; -// winning stakes return alongside the profit. +// Craps wager tables are built from the live table state. Rows are grouped +// where two bets share the same payout (pass/don't pass, the place numbers, +// all free odds) so the list stays compact and the Win/action column rarely +// wraps. Payouts are profit odds; winning stakes return alongside the profit. func (t *crapsTable) wagerRows(name string) []WagerRow { c := t.Config.Craps rows := []WagerRow{} @@ -18,31 +16,30 @@ func (t *crapsTable) wagerRows(name string) []WagerRow { case "simplified": // One automatic roll of two dice; pass is the only target. rows = append(rows, - WagerRow{"pass", "up to 5:1", "One roll: 2 pays 3:1; 3/4 pay 1:1; 10/11 pay 2:1; 12 pays 5:1; 5-9 lose"}, + WagerRow{"pass", "up to 5:1", "One roll: 2 pays 3:1; 3/4 1:1; 10/11 2:1; 12 5:1; 5-9 lose"}, ) case "high_point": rows = append(rows, - WagerRow{"pass", "1:1", "Come-out 2/3 rolls again, 11/12 win; 4-10 make a point the next roll must EXCEED"}, + WagerRow{"pass", "1:1", "2/3 roll again; 11/12 win; 4-10 must be beaten next roll"}, ) case "die_rich": rows = append(rows, - WagerRow{"pass", "1:1", "One die: come-out 6 wins, 1 loses; 2-5 make a point repeated before a 1"}, + WagerRow{"pass", "1:1", "6 wins; 1 loses; 2-5 must repeat before a 1"}, ) case "new_york": rows = append(rows, - WagerRow{"pass", "1:1", "Come-out 7/11 wins; 2/3/12 loses; else the point repeats before a 7"}, + WagerRow{"pass", "1:1", "7/11 win, 2/3/12 lose; opposite bars 12"}, WagerRow{"dontpass", "1:1", "Opposite side; come-out 12 pushes"}, ) if t.point != 0 { rows = append(rows, crapsOddsRows(c)...) rows = append(rows, - WagerRow{"buy <n>", "true odds", "True-odds bet on 4/5/6/8/9/10; 5% stake commission, wins only"}, - WagerRow{"lay <n>", "true odds laid", "Bet AGAINST the number; 5% commission on winnings"}, + WagerRow{"buy / lay <n>", "true", "4/5/6/8/9/10; 5% win commission"}, ) } case "crapless": rows = append(rows, - WagerRow{"pass", "1:1", "Come-out only 7 wins; every other total becomes the point"}, + WagerRow{"pass", "1:1", "Come-out 7 wins; every other total makes the point"}, ) if t.point != 0 { rows = append(rows, @@ -51,94 +48,103 @@ func (t *crapsTable) wagerRows(name string) []WagerRow { rows = append(rows, crapsOddsRows(c)...) rows = append(rows, crapsPlaceRows(c)...) rows = append(rows, - WagerRow{"buy <n>", "true odds", "True-odds place bet; 5% stake commission, wins only"}, - WagerRow{"lay <n>", "true odds laid", "Bet against the number; 5% commission on winnings"}, - WagerRow{"field", fmt.Sprintf("12 pays %d:1", c.Field12), "One roll: 2 pays 2:1; 3/4/9/10/11 pay 1:1; 5/6/7/8 lose"}, - WagerRow{"hard 4 / hard 10", "7:1", "The point arrives as an identical pair"}, - WagerRow{"hard 6 / hard 8", "9:1", "The point arrives as an identical pair"}, - WagerRow{"seven", "4:1", "Next roll totals 7"}, - WagerRow{"craps", "7:1", "Next roll is 2, 3 or 12"}, - WagerRow{"eleven / ace-deuce", "15:1", "Next roll totals 11 / 3"}, - WagerRow{"aces / boxcars", "30:1", "Next roll is 2 / 12"}, - WagerRow{"horn", "varies", "Splits the stake equally among 2/3/11/12"}, - WagerRow{"hop <a> <b>", "15:1/30:1", "One-roll dice combination; 30:1 when both dice equal"}, + WagerRow{"buy / lay <n>", "true", "Place at true odds; 5% win commission"}, + WagerRow{"hard 4/10", "7:1", "Point arrives as an identical pair"}, + WagerRow{"hard 6/8", "9:1", "Point arrives as an identical pair"}, ) - } else { - rows = append(rows, crapsComeOutRows(c, t.rolled)...) } + rows = append(rows, crapsPropRows(c, false)...) default: // bank and diceless rows = append(rows, - WagerRow{"pass", "1:1", "Come-out 7/11 wins; 2/3/12 loses; else the point repeats before a 7"}, + WagerRow{"pass", "1:1", "7/11 win, 2/3/12 lose; opposite bars 12"}, WagerRow{"dontpass", "1:1", "Opposite side; come-out 12 pushes"}, ) if t.point != 0 { rows = append(rows, WagerRow{"come", "1:1", "A personal point with pass rules"}, - WagerRow{"dontcome", "1:1", "Don't come, same as don't pass; a 12 pushes"}, + WagerRow{"dontcome", "1:1", "Don't come; a 12 pushes"}, ) rows = append(rows, crapsOddsRows(c)...) rows = append(rows, crapsPlaceRows(c)...) rows = append(rows, - WagerRow{"buy <n>", "true odds", "True-odds place bet; 5% stake commission, wins only"}, - WagerRow{"lay <n>", "true odds laid", "Bet against the number; 5% commission on winnings"}, - WagerRow{"hard 4 / hard 10", "7:1", "The point arrives as an identical pair"}, - WagerRow{"hard 6 / hard 8", "9:1", "The point arrives as an identical pair"}, + WagerRow{"buy / lay <n>", "true", "Place at true odds; 5% win commission"}, + WagerRow{"hard 4/10", "7:1", "Point arrives as an identical pair"}, + WagerRow{"hard 6/8", "9:1", "Point arrives as an identical pair"}, ) } - rows = append(rows, crapsComeOutRows(c, t.rolled)...) + rows = append(rows, crapsPropRows(c, !t.rolled)...) } return rows } -// crapsComeOutRows is the one-roll part of the list, available in every -// multi-bet variant during every phase; bonus wagers drop out once the -// shooter has rolled. -func crapsComeOutRows(c CrapsConfig, rolled bool) []WagerRow { +// crapsPropRows is the one-roll section of the list: field, the proposition +// bets and (when bonuses are allowed and still open) the Fire and ATS bets. +func crapsPropRows(c CrapsConfig, bonuses bool) []WagerRow { rows := []WagerRow{ - WagerRow{"field", fmt.Sprintf("12 pays %d:1", c.Field12), "One roll: 2 pays 2:1; 3/4/9/10/11 pay 1:1; 5/6/7/8 lose"}, - WagerRow{"seven", "4:1", "Next roll totals 7"}, - WagerRow{"craps", "7:1", "Next roll is 2, 3 or 12"}, - WagerRow{"eleven / ace-deuce", "15:1", "Next roll totals 11 / 3"}, - WagerRow{"aces / boxcars", "30:1", "Next roll is 2 / 12"}, - WagerRow{"horn", "27:4 on 2/12", "Splits the stake equally among 2/3/11/12"}, - WagerRow{"hop <a> <b>", "15:1/30:1", "One-roll dice combination; 30:1 when both dice equal"}, + {"field", fmt.Sprintf("12 pays %d:1", c.Field12), "2 pays 2:1; 3/4/9/10/11 1:1; 5-8 lose"}, + {"seven", "4:1", "Next roll totals 7"}, + {"craps", "7:1", "Next roll is 2, 3 or 12"}, + {"eleven / ace-deuce", "15:1", "Next roll totals 11 / 3"}, + {"aces / boxcars", "30:1", "Next roll is 2 / 12"}, + {"horn", "27:4", "Splits the stake over 2/3/11/12"}, + {"hop <a> <b>", "15:1/30:1", "One-roll dice combination"}, } - if !rolled { - // Bonus bets close before the shooter's first roll. + if bonuses { rows = append(rows, - WagerRow{"fire", "24/249/999:1", "Shooter makes 4/5/6 distinct points before sevening out"}, - WagerRow{"small / tall", "34:1", "All of 2-6 (or 8-12) rolls before any 7"}, - WagerRow{"all", "175:1", "All of 2-6 AND 8-12 in the same hand before any 7"}, + WagerRow{"fire", "24/249/999:1", "4/5/6 distinct points before a 7"}, + WagerRow{"small / tall", "34:1", "All 2-6 or 8-12 before any 7"}, + WagerRow{"all", "175:1", "All 2-6 and 8-12 before any 7"}, ) } return rows } -// crapsPlaceRows lists one row per placeable number with its house payout. -// Crapless tables also accept the "impossible" numbers at extended odds. +// crapsPlaceRows lists one place row per distinct payout, so 4/10 share 9:5, +// 5/9 share 7:5 and 6/8 share 7:6. Crapless tables also accept the +// "impossible" numbers at extended odds. func crapsPlaceRows(c CrapsConfig) []WagerRow { numbers := []int{4, 5, 6, 8, 9, 10} if c.variant() == "crapless" { numbers = []int{2, 3, 4, 5, 6, 8, 9, 10, 11, 12} } - rows := []WagerRow{} + type group struct { + odds string + nums []int + } + var order []*group + byOdds := map[string]*group{} for _, n := range numbers { x, y := crapsPlaceOdds(n) - rows = append(rows, WagerRow{fmt.Sprintf("place %d", n), fmt.Sprintf("%d:%d", x, y), fmt.Sprintf("Number %d repeats before a 7", n)}) + key := fmt.Sprintf("%d:%d", x, y) + g := byOdds[key] + if g == nil { + g = &group{odds: key} + byOdds[key] = g + order = append(order, g) + } + g.nums = append(g.nums, n) + } + var rows []WagerRow + for _, g := range order { + names := make([]string, len(g.nums)) + for i, n := range g.nums { + names[i] = fmt.Sprint(n) + } + rows = append(rows, WagerRow{"place " + strings.Join(names, "/"), g.odds, "Repeats before a 7"}) } return rows } // crapsOddsRows describes the free-odds wagers with this table's odds cap. +// Pass and come odds are one group and don't odds another; the list column +// says simply "true" to keep the payout column narrow. func crapsOddsRows(c CrapsConfig) []WagerRow { - limit := "3-4-5x (don't 6x)" + limit := "3-4-5x" if c.Odds > 0 { limit = fmt.Sprintf("%dx", c.Odds) } return []WagerRow{ - {"odds pass", "true odds", "Extra stake behind your pass point, up to " + limit}, - {"odds come <n>", "true odds", "Extra stake behind a travelled come bet"}, - {"odds dontpass", "true odds laid", "Extra stake against the point, laid at inverse true odds"}, - {"odds dontcome <n>", "true odds laid", "Laid odds behind a don't come bet"}, + {"odds pass / come", "true", "Free odds behind the point, up to " + limit}, + {"odds dont <n>", "true", "Laid against the point at inverse odds"}, } } |
