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.go84
1 files changed, 84 insertions, 0 deletions
diff --git a/internal/casino/craps_ux.go b/internal/casino/craps_ux.go
new file mode 100644
index 0000000..41f671a
--- /dev/null
+++ b/internal/casino/craps_ux.go
@@ -0,0 +1,84 @@
+package casino
+
+import (
+ "fmt"
+ "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 crapsBetLabel(b *crapsBet) string {
+ names := map[string]string{"pass": "Pass", "dontpass": "Don't pass", "come": "Come", "dontcome": "Don't come", "ace-deuce": "Ace-deuce", "small": "All Small", "tall": "All Tall", "all": "All", "fire": "Fire"}
+ label := names[b.kind]
+ if label == "" {
+ label = gameTitle(GameName(b.kind))
+ }
+ if b.kind == "hop" {
+ return fmt.Sprintf("Hop [%d + %d]", b.number/10, b.number%10)
+ }
+ if b.number != 0 {
+ label += fmt.Sprintf(" [%d]", b.number)
+ }
+ return label
+}
+
+// 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
+// roll table shares payout math with settlement (crapsNet), so the numbers
+// never promise a win a real roll cannot pay.
+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)"
+ }
+ }
+ }
+ }
+ e := t.private(p.Name, text+"\n"+t.rollTable(p))
+ e.ShowBalance = true
+ return e
+}
+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()}
+ return e
+}
+func (t *crapsTable) settlementEvent(p *crapsPlayer, lines []settlementLine, failed bool) Event {
+ text := ""
+ if len(lines) > 0 {
+ text = settlementText(lines)
+ }
+ if failed {
+ if text != "" {
+ text += "\n"
+ }
+ text += payoutFailedMessage()
+ }
+ e := t.private(p.Name, text)
+ if len(lines) > 0 {
+ e.Color = settlementTag(lines)
+ }
+ return e
+}