From a4c09c2d38d1f3bc1d3ad4bdb0234bdea7c37e73 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 30 Sep 2026 16:16:17 -0400 Subject: feat: additional craps variants added, standardizard casino command hints --- internal/casino/craps_ux.go | 53 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 7 deletions(-) (limited to 'internal/casino/craps_ux.go') diff --git a/internal/casino/craps_ux.go b/internal/casino/craps_ux.go index 41f671a..948ab99 100644 --- a/internal/casino/craps_ux.go +++ b/internal/casino/craps_ux.go @@ -5,12 +5,51 @@ import ( "strings" ) -func (t *crapsTable) commands() []MenuCommand { - return []MenuCommand{ - {Command: "bet on ", Desc: "Place bets until the dice roll; table rules lists targets"}, - {Command: "roll / autoroll / stop", Desc: "Shoot / repeat on your turn / return to manual play"}, - {Command: "unbet | unbet all", Desc: "Remove one bet / every optional bet"}, - {Command: "table", Desc: "View the felt"}, +func (t *crapsTable) commands(name string) []MenuCommand { + commands := []MenuCommand{} + p := t.players.get(name) + if p != nil { + // Pass-only editions cannot accept another contract while a point or + // the player's existing pass bet is live. + if t.Config.Craps.allows("come") || t.Config.Craps.allows("buy") || (t.point == 0 && !p.HasBet) { + target := "" + if !t.Config.Craps.allows("buy") { + target = "pass" + } + commands = append(commands, MenuCommand{Command: "bet on " + target, Desc: "Place a wager; targets: table rules"}) + } + if p.HasBet { + if t.shooter() == p && (!t.multiplayer || t.roundElapsed >= crapsBetDelay) { + commands = append(commands, MenuCommand{Command: "roll", Desc: "Shoot now"}) + } + if !p.autoRoll { + commands = append(commands, MenuCommand{Command: "autoroll", Desc: "Roll automatically on your turn"}) + } + for _, b := range p.bets { + if !crapsContract(b.kind) || b.odds.Total > 0 { + commands = append(commands, MenuCommand{Command: "unbet / unbet all", Desc: "Return optional bets or odds"}) + break + } + } + } + stop := "Leave the table" + if p.HasBet { + stop = "Leave after your live bets settle" + } + if p.autoRoll { + stop = "Cancel autoroll; keep your bets" + } + commands = append(commands, MenuCommand{Command: "stop", Desc: stop}) + } + return append(commands, MenuCommand{Command: "table", Desc: "View the felt"}) +} + +func crapsContract(kind string) bool { + switch kind { + case "pass", "come", "fire", "small", "tall", "all": + return true + default: + return false } } func crapsBetLabel(b *crapsBet) string { @@ -62,7 +101,7 @@ func (t *crapsTable) betSummary(p *crapsPlayer) Event { func (t *crapsTable) reminder(name string) Event { e := t.private(name, "Your move") e.Color = "casino_menu" - e.Menu = &MenuView{Heading: "Your move", Commands: t.commands()} + e.Menu = &MenuView{Heading: "Your move", Commands: t.commands(name)} return e } func (t *crapsTable) settlementEvent(p *crapsPlayer, lines []settlementLine, failed bool) Event { -- cgit v1.2.3