aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/craps_ux.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/craps_ux.go')
-rw-r--r--internal/casino/craps_ux.go53
1 files changed, 46 insertions, 7 deletions
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 <amount> on <target>", 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 <target> | 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 := "<target>"
+ if !t.Config.Craps.allows("buy") {
+ target = "pass"
+ }
+ commands = append(commands, MenuCommand{Command: "bet <amount> 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 <target> / 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 {