diff options
Diffstat (limited to 'internal/game/casino_house_edge.go')
| -rw-r--r-- | internal/game/casino_house_edge.go | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/internal/game/casino_house_edge.go b/internal/game/casino_house_edge.go index 1abbcac..de0036b 100644 --- a/internal/game/casino_house_edge.go +++ b/internal/game/casino_house_edge.go @@ -76,8 +76,8 @@ func (g *Game) casinoListRows(sess *net.Session, t *casino.Table, wagers []casin // Different target returns need distinct rows, not a list of unlabeled RTPs. for _, part := range row.edge.Parts { entry := row - if strings.Contains(wager.Bet, "<n>") { - entry.bet = strings.ReplaceAll(wager.Bet, "<n>", part.Label) + if bet, ok := expandBetNumber(wager.Bet, part.Label); ok { + entry.bet = bet } else if part.Label != "" { // The label refines the shared win text (hop's doubles), so append // it: the base phrase stays "Next roll is a/b (doubles)". @@ -90,6 +90,24 @@ func (g *Game) casinoListRows(sess *net.Session, t *casino.Table, wagers []casin return rows } +// expandBetNumber replaces the standalone number variable N in a grouped +// wager row ("buy N", "odds dont N") with one concrete number. It reports +// false when the row has no N token, leaving the label to refine the win text. +func expandBetNumber(bet, number string) (string, bool) { + fields := strings.Fields(bet) + found := false + for i, f := range fields { + if f == "N" { + fields[i] = number + found = true + } + } + if !found { + return bet, false + } + return strings.Join(fields, " "), true +} + // Explicit list-only presentation. Wrap plain cells before applying color and // handing them to the existing ANSI-aware table renderer; never truncate rules. // The table stands alone: list names no heading and no balance above it, and @@ -174,7 +192,11 @@ func (g *Game) showCasinoListTable(sess *net.Session, betHeader string, rows []c category = "casino_action" } physical[i] = parts[line] - if category != "" { + switch category { + case "command": + physical[i] = g.colorizeCommand(sess, physical[i]) + case "": + default: physical[i] = g.colorize(sess, category, physical[i]) } } |
