aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/craps_projection.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/craps_projection.go')
-rw-r--r--internal/casino/craps_projection.go64
1 files changed, 25 insertions, 39 deletions
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()
}