aboutsummaryrefslogtreecommitdiff
path: root/internal/casino
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino')
-rw-r--r--internal/casino/baccarat.go3
-rw-r--r--internal/casino/baccarat_test.go2
-rw-r--r--internal/casino/baccarat_wagers.go39
-rw-r--r--internal/casino/blackjack.go4
-rw-r--r--internal/casino/blackjack_test.go4
-rw-r--r--internal/casino/blackjack_wagers.go41
-rw-r--r--internal/casino/craps_ux.go4
-rw-r--r--internal/casino/craps_variants.go24
-rw-r--r--internal/casino/craps_wagers.go144
-rw-r--r--internal/casino/registry.go66
-rw-r--r--internal/casino/roulette.go5
-rw-r--r--internal/casino/roulette_wagers.go39
-rw-r--r--internal/casino/table.go21
-rw-r--r--internal/casino/table_hints.go86
-rw-r--r--internal/casino/table_ux.go54
-rw-r--r--internal/casino/wagers_test.go100
16 files changed, 604 insertions, 32 deletions
diff --git a/internal/casino/baccarat.go b/internal/casino/baccarat.go
index 50ac111..122deed 100644
--- a/internal/casino/baccarat.go
+++ b/internal/casino/baccarat.go
@@ -54,7 +54,8 @@ func (t *baccaratTable) menuEvent(name string) Event {
if p := t.players.get(name); p != nil && p.lastBet > 0 {
commands = append(commands, MenuCommand{Command: "bet", Desc: fmt.Sprintf("Repeat %d on %s (also: rebet)", p.lastBet, p.lastSpot)}, MenuCommand{Command: "bet <amount>", Desc: "Change amount; keep " + p.lastSpot})
}
- commands = append(commands, MenuCommand{Command: fmt.Sprintf("bet %d banker", t.Config.MinBet), Desc: "Choose banker (b), player (p), or tie (t)"}, MenuCommand{Command: "bet <amount> on <target>", Desc: "One wager per round; targets: table rules"}, MenuCommand{Command: "stop", Desc: "Leave; during a round, leave afterward"}, MenuCommand{Command: "table / sitout", Desc: "Check the table / skip betting until you rejoin"})
+ commands = append(commands, MenuCommand{Command: fmt.Sprintf("bet %d banker", t.Config.MinBet), Desc: "Choose banker (b), player (p), or tie (t)"}, MenuCommand{Command: "bet <amount> on <target>", Desc: "One wager per round; targets: list"}, MenuCommand{Command: "stop", Desc: "Leave; during a round, leave afterward"}, MenuCommand{Command: "table / sitout", Desc: "Check the table / skip betting until you rejoin"})
+ commands = withTableHints(commands, t.wagerRows())
e := t.betMenuEvent(name, commands)
if p := t.players.get(name); p != nil {
e.Menu.Repeat = p.lastBet > 0
diff --git a/internal/casino/baccarat_test.go b/internal/casino/baccarat_test.go
index dce1629..b767c74 100644
--- a/internal/casino/baccarat_test.go
+++ b/internal/casino/baccarat_test.go
@@ -382,7 +382,7 @@ func TestBaccaratMenuAndActions(t *testing.T) {
if menu == nil || !menu.ShowBalance || !strings.Contains(menu.Heading, "Baccarat / Commission | Limits") {
t.Fatalf("join menu=%+v, want a baccarat betting menu", menu)
}
- if len(menu.Commands) != 4 || menu.Commands[0].Command != "bet 1 banker" || menu.Commands[2].Command != "stop" {
+ if len(menu.Commands) != 6 || menu.Commands[0].Command != "bet 1 banker" || menu.Commands[2].Command != "stop" || menu.Commands[4].Command != "rules" || menu.Commands[5].Command != "list" {
t.Fatalf("baccarat menu commands=%+v", menu.Commands)
}
if events := table.action("alice", "hit"); !hasMessage(events, "no player actions") {
diff --git a/internal/casino/baccarat_wagers.go b/internal/casino/baccarat_wagers.go
new file mode 100644
index 0000000..cf2653e
--- /dev/null
+++ b/internal/casino/baccarat_wagers.go
@@ -0,0 +1,39 @@
+package casino
+
+import "fmt"
+
+// Baccarat's wager list names every outcome and optional side bet this
+// variant actually offers, with profit odds and the bare win condition.
+// The no-commission exceptions travel in the payout wording so the list
+// stays truthful for every edition.
+func (t *baccaratTable) wagerRows() []WagerRow {
+ rules := t.Rules
+ banker := "0.95:1 (5% commission)"
+ switch rules.Variant {
+ case BaccaratSuper6:
+ banker = "1:1 (Banker 6 pays 1:2)"
+ case BaccaratEZ:
+ banker = "1:1 (3-card 7 pushes)"
+ }
+ rows := []WagerRow{
+ {"player (p)", "1:1", "Player's last digit beats Banker's"},
+ {"banker (b)", banker, "Banker's last digit beats Player's"},
+ {"tie (t)", fmt.Sprintf("%g:1", rules.TiePayout), "Both hands finish equal"},
+ }
+ if rules.PairBets {
+ rows = append(rows,
+ WagerRow{"player_pair", "11:1", "First two Player cards share a rank"},
+ WagerRow{"banker_pair", "11:1", "First two Banker cards share a rank"},
+ )
+ }
+ if rules.Dragon7 {
+ rows = append(rows, WagerRow{"dragon_7", "40:1", "Banker wins with a three-card 7"})
+ }
+ if rules.Panda8 {
+ rows = append(rows, WagerRow{"panda_8", "25:1", "Player wins with a three-card 8"})
+ }
+ if rules.Super6Bet {
+ rows = append(rows, WagerRow{"super_6", "12:1", "Banker wins with 6"})
+ }
+ return rows
+}
diff --git a/internal/casino/blackjack.go b/internal/casino/blackjack.go
index bd5b86b..a047c71 100644
--- a/internal/casino/blackjack.go
+++ b/internal/casino/blackjack.go
@@ -123,6 +123,8 @@ func (t *blackjackTable) menuEvent(name string) Event {
{Command: "stop", Desc: "Leave; during a round, leave afterward"},
{Command: "table / sitout", Desc: "Check the table / skip betting until you rejoin"},
})
+ // Blackjack has a single wager target, so no list hint; rules rides along.
+ e.Menu.Commands = withTableHints(e.Menu.Commands, nil)
if p := t.players.get(name); p != nil {
e.Menu.Repeat = p.lastBet > 0
}
@@ -572,7 +574,7 @@ func (t *blackjackTable) turnMenuLocked(name string) Event {
if p.Connected && t.bettorCount() <= 1 {
deadline = t.ceiling.remaining()
}
- e.Menu = &MenuView{Heading: fmt.Sprintf("Your turn | %d ticks remaining", deadline), Commands: blackjackActionCommands(actions)}
+ e.Menu = &MenuView{Heading: fmt.Sprintf("Your turn | %d ticks remaining", deadline), Commands: withTableHints(blackjackActionCommands(actions), nil)}
for i := range e.Menu.Commands {
c := &e.Menu.Commands[i]
if c.Command == "double" || c.Command == "split" {
diff --git a/internal/casino/blackjack_test.go b/internal/casino/blackjack_test.go
index aff87c8..956298b 100644
--- a/internal/casino/blackjack_test.go
+++ b/internal/casino/blackjack_test.go
@@ -131,7 +131,7 @@ func TestBlackjackPromptNamesActiveHandAndOnlyOffersAvailableActions(t *testing.
t.Fatalf("prompt=%q", event.Message)
}
if event.Menu == nil || !strings.Contains(event.Menu.Heading, "Your turn |") || event.Menu.ShowBalance ||
- len(event.Menu.Commands) != 3 || event.Menu.Commands[0].Command != "hit" || event.Menu.Commands[1].Command != "stand" || event.Menu.Commands[2].Command != "double" {
+ len(event.Menu.Commands) != 4 || event.Menu.Commands[0].Command != "hit" || event.Menu.Commands[1].Command != "stand" || event.Menu.Commands[2].Command != "double" || event.Menu.Commands[3].Command != "rules" {
t.Fatalf("prompt menu=%+v", event.Menu)
}
}
@@ -142,7 +142,7 @@ func TestBlackjackMenuEventCarriesStructuredMenu(t *testing.T) {
if event.Menu == nil || !event.Menu.ShowBalance {
t.Fatalf("menu event=%+v", event.Menu)
}
- if len(event.Menu.Commands) != 4 || event.Menu.Commands[0].Command != "bet" || event.Menu.Commands[2].Command != "stop" {
+ if len(event.Menu.Commands) != 5 || event.Menu.Commands[0].Command != "bet" || event.Menu.Commands[2].Command != "stop" || event.Menu.Commands[4].Command != "rules" {
t.Fatalf("bet menu commands=%+v", event.Menu.Commands)
}
}
diff --git a/internal/casino/blackjack_wagers.go b/internal/casino/blackjack_wagers.go
new file mode 100644
index 0000000..23afac8
--- /dev/null
+++ b/internal/casino/blackjack_wagers.go
@@ -0,0 +1,41 @@
+package casino
+
+import "fmt"
+
+// Blackjack's only standing wager is bet <amount>, so outside the hand's
+// decision points its wager list is empty (which also suppresses the "list"
+// hint). During the insurance window and the player's own turn, the extra
+// wagers and wagers-that-return-money get listed: insurance, decline,
+// double, split and surrender — the same facts their own hints carry.
+func (t *blackjackTable) wagerRows(name string) []WagerRow {
+ p := t.players.get(name)
+ if p == nil {
+ return nil
+ }
+ if t.phase == blackjackInsurance && p.HasBet && !p.declinedInsurance && p.insurance == 0 && len(p.hands) > 0 {
+ return []WagerRow{
+ {"insurance", fmt.Sprintf("%g:1", t.Rules.InsurancePayout), fmt.Sprintf("Covers dealer blackjack; the stake costs %d", p.hands[0].bet/2)},
+ {"decline", "", "Continue without insurance (also the timeout default)"},
+ }
+ }
+ if t.phase == blackjackPlaying && t.activeName() == name && t.activeHand < len(p.hands) {
+ hand := p.hands[t.activeHand]
+ var rows []WagerRow
+ for _, action := range t.availableActions(p, hand) {
+ switch action {
+ case "hit":
+ rows = append(rows, WagerRow{"hit", "", "Take another card"})
+ case "stand":
+ rows = append(rows, WagerRow{"stand", "", "Keep your total"})
+ case "double":
+ rows = append(rows, WagerRow{"double", "1:1 on the added stake", fmt.Sprintf("Wager %d more, take exactly one card, stand", hand.bet)})
+ case "split":
+ rows = append(rows, WagerRow{"split", "1:1 on the added stake", fmt.Sprintf("Wager %d more; play the pair as two hands", hand.bet)})
+ case "surrender":
+ rows = append(rows, WagerRow{"surrender", "half returned", "Give up the original two-card hand"})
+ }
+ }
+ return rows
+ }
+ return nil
+}
diff --git a/internal/casino/craps_ux.go b/internal/casino/craps_ux.go
index 10f7fcb..b14354e 100644
--- a/internal/casino/craps_ux.go
+++ b/internal/casino/craps_ux.go
@@ -54,6 +54,10 @@ func (t *crapsTable) commands(name string) []MenuCommand {
stop = "Cancel autoroll; keep your bets"
}
commands = append(commands, MenuCommand{Command: "stop", Desc: stop})
+ // "rules" stays available to a seated player at every phase of every
+ // variant; "list" rides along whenever the wager table names more
+ // than one bet.
+ commands = withTableHints(commands, t.wagerRows(name))
}
return append(commands, MenuCommand{Command: "table", Desc: "View the felt"})
}
diff --git a/internal/casino/craps_variants.go b/internal/casino/craps_variants.go
index a3c078f..7d4d246 100644
--- a/internal/casino/craps_variants.go
+++ b/internal/casino/craps_variants.go
@@ -13,6 +13,30 @@ func (c CrapsConfig) variant() string {
}
return c.Variant
}
+
+// helpTopic names the help page the "rules" command opens: every house
+//
+// edition has its own page (Simplified Craps is a two-screen quick guide,
+// not a link into the bank-craps manual), except diceless which plays full
+// bank rules with cards instead of dice.
+func (c CrapsConfig) helpTopic() string {
+ switch c.variant() {
+ case "simplified":
+ return "simplified craps"
+ case "high_point":
+ return "high point craps"
+ case "die_rich":
+ return "die rich craps"
+ case "new_york":
+ return "new york craps"
+ case "crapless":
+ return "crapless craps"
+ case "diceless":
+ return "diceless craps"
+ default:
+ return "craps"
+ }
+}
func (c CrapsConfig) title() string {
switch c.variant() {
case "simplified":
diff --git a/internal/casino/craps_wagers.go b/internal/casino/craps_wagers.go
new file mode 100644
index 0000000..d9af87f
--- /dev/null
+++ b/internal/casino/craps_wagers.go
@@ -0,0 +1,144 @@
+package casino
+
+import (
+ "fmt"
+)
+
+// Craps wager tables are built from the live table state: a come-out roll
+// offers the line bets, the one-roll props and (before the shooter's first
+// roll) the bonus bets; a point adds come, odds, place/buy/lay and the
+// hardways. The variants substitute their own single-bet lists. Every entry
+// pairs the bet wording with its payout and a one-line win condition, so the
+// list doubles as the game's brief rule reminder. Payouts are profit odds;
+// winning stakes return alongside the profit.
+func (t *crapsTable) wagerRows(name string) []WagerRow {
+ c := t.Config.Craps
+ rows := []WagerRow{}
+ switch c.variant() {
+ case "simplified":
+ // One automatic roll of two dice; pass is the only target.
+ rows = append(rows,
+ WagerRow{"pass", "up to 5:1", "One roll: 2 pays 3:1; 3/4 pay 1:1; 10/11 pay 2:1; 12 pays 5:1; 5-9 lose"},
+ )
+ case "high_point":
+ rows = append(rows,
+ WagerRow{"pass", "1:1", "Come-out 2/3 rolls again, 11/12 win; 4-10 make a point the next roll must EXCEED"},
+ )
+ case "die_rich":
+ rows = append(rows,
+ WagerRow{"pass", "1:1", "One die: come-out 6 wins, 1 loses; 2-5 make a point repeated before a 1"},
+ )
+ case "new_york":
+ rows = append(rows,
+ WagerRow{"pass", "1:1", "Come-out 7/11 wins; 2/3/12 loses; else the point repeats before a 7"},
+ WagerRow{"dontpass", "1:1", "Opposite side; come-out 12 pushes"},
+ )
+ if t.point != 0 {
+ rows = append(rows, crapsOddsRows(c)...)
+ rows = append(rows,
+ WagerRow{"buy <n>", "true odds", "True-odds bet on 4/5/6/8/9/10; 5% stake commission, wins only"},
+ WagerRow{"lay <n>", "true odds laid", "Bet AGAINST the number; 5% commission on winnings"},
+ )
+ }
+ case "crapless":
+ rows = append(rows,
+ WagerRow{"pass", "1:1", "Come-out only 7 wins; every other total becomes the point"},
+ )
+ if t.point != 0 {
+ rows = append(rows,
+ WagerRow{"come", "1:1", "A personal point with pass rules"},
+ )
+ rows = append(rows, crapsOddsRows(c)...)
+ rows = append(rows, crapsPlaceRows(c)...)
+ rows = append(rows,
+ WagerRow{"buy <n>", "true odds", "True-odds place bet; 5% stake commission, wins only"},
+ WagerRow{"lay <n>", "true odds laid", "Bet against the number; 5% commission on winnings"},
+ WagerRow{"field", fmt.Sprintf("12 pays %d:1", c.Field12), "One roll: 2 pays 2:1; 3/4/9/10/11 pay 1:1; 5/6/7/8 lose"},
+ WagerRow{"hard 4 / hard 10", "7:1", "The point arrives as an identical pair"},
+ WagerRow{"hard 6 / hard 8", "9:1", "The point arrives as an identical pair"},
+ WagerRow{"seven", "4:1", "Next roll totals 7"},
+ WagerRow{"craps", "7:1", "Next roll is 2, 3 or 12"},
+ WagerRow{"eleven / ace-deuce", "15:1", "Next roll totals 11 / 3"},
+ WagerRow{"aces / boxcars", "30:1", "Next roll is 2 / 12"},
+ WagerRow{"horn", "varies", "Splits the stake equally among 2/3/11/12"},
+ WagerRow{"hop <a> <b>", "15:1/30:1", "One-roll dice combination; 30:1 when both dice equal"},
+ )
+ } else {
+ rows = append(rows, crapsComeOutRows(c, t.rolled)...)
+ }
+ default: // bank and diceless
+ rows = append(rows,
+ WagerRow{"pass", "1:1", "Come-out 7/11 wins; 2/3/12 loses; else the point repeats before a 7"},
+ WagerRow{"dontpass", "1:1", "Opposite side; come-out 12 pushes"},
+ )
+ if t.point != 0 {
+ rows = append(rows,
+ WagerRow{"come", "1:1", "A personal point with pass rules"},
+ WagerRow{"dontcome", "1:1", "Don't come, same as don't pass; a 12 pushes"},
+ )
+ rows = append(rows, crapsOddsRows(c)...)
+ rows = append(rows, crapsPlaceRows(c)...)
+ rows = append(rows,
+ WagerRow{"buy <n>", "true odds", "True-odds place bet; 5% stake commission, wins only"},
+ WagerRow{"lay <n>", "true odds laid", "Bet against the number; 5% commission on winnings"},
+ WagerRow{"hard 4 / hard 10", "7:1", "The point arrives as an identical pair"},
+ WagerRow{"hard 6 / hard 8", "9:1", "The point arrives as an identical pair"},
+ )
+ }
+ rows = append(rows, crapsComeOutRows(c, t.rolled)...)
+ }
+ return rows
+}
+
+// crapsComeOutRows is the one-roll part of the list, available in every
+// multi-bet variant during every phase; bonus wagers drop out once the
+// shooter has rolled.
+func crapsComeOutRows(c CrapsConfig, rolled bool) []WagerRow {
+ rows := []WagerRow{
+ WagerRow{"field", fmt.Sprintf("12 pays %d:1", c.Field12), "One roll: 2 pays 2:1; 3/4/9/10/11 pay 1:1; 5/6/7/8 lose"},
+ WagerRow{"seven", "4:1", "Next roll totals 7"},
+ WagerRow{"craps", "7:1", "Next roll is 2, 3 or 12"},
+ WagerRow{"eleven / ace-deuce", "15:1", "Next roll totals 11 / 3"},
+ WagerRow{"aces / boxcars", "30:1", "Next roll is 2 / 12"},
+ WagerRow{"horn", "27:4 on 2/12", "Splits the stake equally among 2/3/11/12"},
+ WagerRow{"hop <a> <b>", "15:1/30:1", "One-roll dice combination; 30:1 when both dice equal"},
+ }
+ if !rolled {
+ // Bonus bets close before the shooter's first roll.
+ rows = append(rows,
+ WagerRow{"fire", "24/249/999:1", "Shooter makes 4/5/6 distinct points before sevening out"},
+ WagerRow{"small / tall", "34:1", "All of 2-6 (or 8-12) rolls before any 7"},
+ WagerRow{"all", "175:1", "All of 2-6 AND 8-12 in the same hand before any 7"},
+ )
+ }
+ return rows
+}
+
+// crapsPlaceRows lists one row per placeable number with its house payout.
+// Crapless tables also accept the "impossible" numbers at extended odds.
+func crapsPlaceRows(c CrapsConfig) []WagerRow {
+ numbers := []int{4, 5, 6, 8, 9, 10}
+ if c.variant() == "crapless" {
+ numbers = []int{2, 3, 4, 5, 6, 8, 9, 10, 11, 12}
+ }
+ rows := []WagerRow{}
+ for _, n := range numbers {
+ x, y := crapsPlaceOdds(n)
+ rows = append(rows, WagerRow{fmt.Sprintf("place %d", n), fmt.Sprintf("%d:%d", x, y), fmt.Sprintf("Number %d repeats before a 7", n)})
+ }
+ return rows
+}
+
+// crapsOddsRows describes the free-odds wagers with this table's odds cap.
+func crapsOddsRows(c CrapsConfig) []WagerRow {
+ limit := "3-4-5x (don't 6x)"
+ if c.Odds > 0 {
+ limit = fmt.Sprintf("%dx", c.Odds)
+ }
+ return []WagerRow{
+ {"odds pass", "true odds", "Extra stake behind your pass point, up to " + limit},
+ {"odds come <n>", "true odds", "Extra stake behind a travelled come bet"},
+ {"odds dontpass", "true odds laid", "Extra stake against the point, laid at inverse true odds"},
+ {"odds dontcome <n>", "true odds laid", "Laid odds behind a don't come bet"},
+ }
+}
diff --git a/internal/casino/registry.go b/internal/casino/registry.go
index c53fe53..049d9f1 100644
--- a/internal/casino/registry.go
+++ b/internal/casino/registry.go
@@ -6,11 +6,12 @@ import (
)
// tableGameDef is the single registration point for a multiplayer table game.
-// A game's validation, rule defaults, and constructor live together here, so
-// adding a game is one entry instead of edits to three independent switches
-// (TableConfig.Validate, TableConfig.Normalize, and newTable) that could
-// silently drift apart. The rule structs stay on TableConfig; this does not
-// introduce a config union.
+// A game's validation, rule defaults, constructor, help topic, and rule text
+// live together here, so adding a game is one entry instead of edits to
+// many independent switches (TableConfig.Validate, TableConfig.Normalize,
+// newTable, RulesText, and the presentation router) that could silently drift
+// apart. The rule structs stay on TableConfig; this does not introduce a
+// config union.
type tableGameDef struct {
// validate checks a raw (pre-Normalize) table config.
validate func(TableConfig) error
@@ -25,6 +26,12 @@ type tableGameDef struct {
// new builds the game. It is called only after validate passes and the
// shared table config has been normalized.
new func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame
+ // ruleText names the shared rule text builder (TableConfig.RulesText
+ // dispatch, keeping the "rules" wording with the game's registration).
+ ruleText func(TableConfig) string
+ // helpTopic names the help page "rules" opens at this table. A game with
+ // per-edition pages derives them from its config (craps variants).
+ helpTopic func(TableConfig) string
}
// tableGames is populated in init, not in a var initializer: the constructors
@@ -40,6 +47,8 @@ func init() {
ruleBlockName: "craps",
hasRuleBlock: func(c TableConfig) bool { return c.Craps != (CrapsConfig{}) },
new: func(room int, c TableConfig, rng *rand.Rand) tableGame { return newCrapsTable(room, c, rng) },
+ ruleText: func(c TableConfig) string { return c.CrapsRulesText() },
+ helpTopic: func(c TableConfig) string { return c.Craps.helpTopic() },
},
GameRoulette: {
validate: func(c TableConfig) error {
@@ -60,6 +69,8 @@ func init() {
ruleBlockName: "roulette",
hasRuleBlock: func(c TableConfig) bool { return c.Roulette != (RouletteConfig{}) },
new: func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame { return newRouletteTable(roomID, cfg, rng) },
+ ruleText: rouletteRulesText,
+ helpTopic: func(TableConfig) string { return "roulette" },
},
GameBlackjack: {
validate: validateBlackjackTable,
@@ -69,6 +80,8 @@ func init() {
new: func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame {
return newBlackjackTable(roomID, cfg, rng)
},
+ ruleText: func(c TableConfig) string { return c.BlackjackRulesText() },
+ helpTopic: func(TableConfig) string { return "blackjack" },
},
GameBaccarat: {
validate: validateBaccaratTable,
@@ -78,6 +91,17 @@ func init() {
new: func(roomID int, cfg TableConfig, rng *rand.Rand) tableGame {
return newBaccaratTable(roomID, cfg, rng)
},
+ ruleText: func(c TableConfig) string { return c.BaccaratRulesText() },
+ helpTopic: func(c TableConfig) string {
+ switch c.Baccarat.Normalize().Variant {
+ case BaccaratSuper6:
+ return "super 6 baccarat"
+ case BaccaratEZ:
+ return "ez baccarat"
+ default:
+ return "baccarat"
+ }
+ },
},
}
}
@@ -97,3 +121,35 @@ func tableGameDefFor(game GameName) (tableGameDef, bool) {
var slotVariants = map[string]func() SlotProfile{
"huff_and_even_more_puff": DefaultHuffAndPuffProfile,
}
+
+// HelpTopic is the help page the "rules" command opens while seated at this
+// table: a variant's own short page where the game has one (Simplified Craps,
+// Super 6 …), the game's main page otherwise.
+func (c TableConfig) HelpTopic() string {
+ if def, ok := tableGameDefFor(c.Game); ok && def.helpTopic != nil {
+ return def.helpTopic(c)
+ }
+ return string(c.Game)
+}
+
+// rulesTextOnTable is the shared route from a table config to its rule text.
+func rulesTextOnTable(cfg TableConfig) string {
+ if def, ok := tableGameDefFor(cfg.Game); ok && def.ruleText != nil {
+ return def.ruleText(cfg)
+ }
+ return cfg.Label()
+}
+
+// rouletteRulesText is roulette's table rules text: the payout table is
+// drawn by the presentation layer (the payout reference needs the paying
+// game's felt), so the engine text covers the fixed odds and table facts.
+func rouletteRulesText(c TableConfig) string {
+ rules := c.Label() + "\nStraight numbers pay 35:1; splits 17:1; streets and trios 11:1; corners 8:1; lines 5:1.\n" +
+ "1to12/13to24/25to36 and rows 2:1; other outside bets 1:1; the American basket pays 6:1.\n" +
+ "Combos: bet 10 on split 1 2 | bet 10 on street 1 2 3 | bet 10 on corner 1 2 4 5 |\n" +
+ "bet 10 on line 1 2 3 4 5 6 | bet 10 on trio 0 1 2 | bet 10 on basket.\n"
+ if c.Roulette.Racetrack {
+ rules += "Racetrack (single zero): bet 10 on voisins | tiers | orphelins | jeu zero | neighbors 17.\n"
+ }
+ return rules + "Zero pockets lose all outside bets. One wager per spin. Use help roulette."
+}
diff --git a/internal/casino/roulette.go b/internal/casino/roulette.go
index 2453fed..1a9f936 100644
--- a/internal/casino/roulette.go
+++ b/internal/casino/roulette.go
@@ -493,7 +493,7 @@ func (t *rouletteTable) menuEvent(name string) Event {
commands := []MenuCommand{}
p := t.players.get(name)
if t.phase != phasePlaying && p != nil && !p.HasBet {
- commands = append(commands, MenuCommand{Command: "bet <amount> on <target>", Desc: "Place one wager; targets: help roulette"})
+ commands = append(commands, MenuCommand{Command: "bet <amount> on <target>", Desc: "Place one wager; targets: list"})
if p.lastBet > 0 {
commands = append(commands, MenuCommand{Command: "bet / rebet", Desc: "Repeat your previous wager"})
}
@@ -502,6 +502,9 @@ func (t *rouletteTable) menuEvent(name string) Event {
commands = append(commands, MenuCommand{Command: "sitout / stop", Desc: "Sit out / leave when your wager settles"})
}
commands = append(commands, MenuCommand{Command: "table", Desc: "View the layout"})
+ if p != nil {
+ commands = withTableHints(commands, t.wagerRows())
+ }
e := t.betMenuEvent(name, commands)
e.Snapshot = t.view()
return e
diff --git a/internal/casino/roulette_wagers.go b/internal/casino/roulette_wagers.go
new file mode 100644
index 0000000..7562582
--- /dev/null
+++ b/internal/casino/roulette_wagers.go
@@ -0,0 +1,39 @@
+package casino
+
+import "fmt"
+
+// Roulette offers one wager per spin, but the target catalogue is the whole
+// layout, so the state-based list doubles as the payout reference: every
+// legal target with its profit odds and its chance (pockets out of an
+// equally-likely wheel). Racetrack call bets join on tables that offer them.
+func (t *rouletteTable) wagerRows() []WagerRow {
+ pockets, basketOdds, basketPockets := 37, "8:1", 4
+ if t.Config.Roulette.DoubleZero {
+ pockets, basketOdds, basketPockets = 38, "6:1", 5
+ }
+ chance := func(n int) string { return fmt.Sprintf("%d/%d", n, pockets) }
+ rows := []WagerRow{
+ {"<number>", "35:1", "One pocket (" + chance(1) + ")"},
+ {"red / black", "1:1", "The color (" + chance(18) + ")"},
+ {"odd / even", "1:1", "The parity (" + chance(18) + ")"},
+ {"low / high", "1:1", "Low 1-18 / high 19-36 (" + chance(18) + ")"},
+ {"1to12 / 13to24 / 25to36", "2:1", "A dozen (" + chance(12) + ")"},
+ {"row1 / row2 / row3", "2:1", "A numbered row (" + chance(12) + ")"},
+ {"split <a> <b>", "17:1", "Two touching pockets (" + chance(2) + ")"},
+ {"street <a> <b> <c>", "11:1", "Three numbers in a street (" + chance(3) + ")"},
+ {"trio 0 <a> <b>", "11:1", "A zero-edge trio (" + chance(3) + ")"},
+ {"corner <a> <b> <c> <d>", "8:1", "A 2x2 square (" + chance(4) + ")"},
+ {"line <a> … <f>", "5:1", "Two adjoining streets (" + chance(6) + ")"},
+ {"basket", basketOdds, "0, 1, 2, 3 (+ 00) (" + chance(basketPockets) + ")"},
+ }
+ if t.Config.Roulette.Racetrack && !t.Config.Roulette.DoubleZero {
+ rows = append(rows,
+ WagerRow{"voisins", "5:3 or 1:1", "17 pockets around zero, 9 chips"},
+ WagerRow{"tiers", "2:1", "The 12 pockets opposite zero, 6 chips"},
+ WagerRow{"orphelins", "31:5 or 13:5", "The two orphan arcs, 5 chips"},
+ WagerRow{"zero / jeu zero", "8:1 or 7:2", "The 7 pockets nearest zero, 4 chips"},
+ WagerRow{"neighbors <n>", "3:1", "Pocket n plus four numbers each side, 9 chips"},
+ )
+ }
+ return rows
+}
diff --git a/internal/casino/table.go b/internal/casino/table.go
index ddf357f..719bed3 100644
--- a/internal/casino/table.go
+++ b/internal/casino/table.go
@@ -21,6 +21,12 @@ type tableGame interface {
idle() bool
status(name string) []Event
overview() string
+ // wagers is the game's live list of bets the player could make right
+ // now (the "list" command's data; empty when nothing is worth naming,
+ // which also suppresses the "list" hint). hints is the full live hint
+ // list, finished with the shared "rules" and (multi-wager) "list".
+ wagers(name string) []WagerRow
+ hints(name string) []MenuCommand
// base returns the table identity shared with the Table handle.
base() *tableBase
}
@@ -111,3 +117,18 @@ func (t *Table) idle() bool { return t.game.idle() }
// Status is a read-only view: it never restarts a deadline or changes a wager.
func (t *Table) Status(name string) []Event { return t.game.status(name) }
func (t *Table) Overview() string { return t.game.overview() }
+
+// RulesText is this table's full rule text (the "table rules" wording).
+func (t *Table) RulesText() string { return rulesTextOnTable(t.Config) }
+
+// HelpTopic is the help page the "rules" command opens while seated here.
+func (t *Table) HelpTopic() string { return t.Config.HelpTopic() }
+
+// Wagers is the game's live list of bets the player could make right now.
+// Empty when nothing is worth naming (a lone "bet <amount>" wager, a
+// committed round) — the same signal that suppresses the "list" hint.
+func (t *Table) Wagers(name string) []WagerRow { return t.game.wagers(name) }
+
+// Hints is the game's live hint list, finished with the shared "rules" and
+// (multi-wager) "list" entries so look and the menus advertise both.
+func (t *Table) Hints(name string) []MenuCommand { return t.game.hints(name) }
diff --git a/internal/casino/table_hints.go b/internal/casino/table_hints.go
new file mode 100644
index 0000000..00eea53
--- /dev/null
+++ b/internal/casino/table_hints.go
@@ -0,0 +1,86 @@
+package casino
+
+import "fmt"
+
+// Per-game live-hint registration: every game answers the same two views
+// through the tableGame interface — its full hint list (finished with the
+// shared "rules" and "list" entries) and its wager table — so the shared
+// table controls never need a per-game switch. All entries are seated only;
+// a standing player is not told how to bet at a game they have not joined.
+
+func (t *crapsTable) wagers(name string) []WagerRow { return t.wagerRows(name) }
+func (t *crapsTable) hints(name string) []MenuCommand { return t.commands(name) }
+
+func (t *rouletteTable) wagers(name string) []WagerRow { return t.wagerRows() }
+func (t *rouletteTable) hints(name string) []MenuCommand {
+ p := t.players.get(name)
+ if p == nil {
+ return nil
+ }
+ commands := []MenuCommand{}
+ if t.phase != phasePlaying && !p.HasBet {
+ commands = append(commands, MenuCommand{Command: "bet <amount> on <target>", Desc: "Place one wager; targets: list"})
+ if p.lastBet > 0 {
+ commands = append(commands, MenuCommand{Command: "bet / rebet", Desc: "Repeat your previous wager"})
+ }
+ }
+ commands = append(commands, MenuCommand{Command: "sitout / stop", Desc: "Sit out / leave when your wager settles"})
+ commands = append(commands, MenuCommand{Command: "table", Desc: "View the layout"})
+ return withTableHints(commands, t.wagerRows())
+}
+
+// blackjackHintsIdle are the shared controls for a bettor with no structured
+// menu right now (an in-flight round has no betting menu to reuse).
+func blackjackHintsIdle() []MenuCommand {
+ return []MenuCommand{
+ {Command: "table", Desc: "View the table"},
+ {Command: "sitout", Desc: "Sit out after this round"},
+ {Command: "stop", Desc: "Leave after this round"},
+ }
+}
+
+func (t *blackjackTable) wagers(name string) []WagerRow { return t.wagerRows(name) }
+func (t *blackjackTable) hints(name string) []MenuCommand {
+ if t.players.get(name) == nil {
+ return nil
+ }
+ var commands []MenuCommand
+ if menu := t.menuEvent(name); menu.Menu != nil && len(menu.Menu.Commands) > 0 {
+ // The real menu is authoritative: betting, insurance, turn actions
+ // or the committed-wager view, exactly as the round allows.
+ commands = menu.Menu.Commands
+ } else {
+ commands = blackjackHintsIdle()
+ }
+ return withTableHints(commands, t.wagerRows(name))
+}
+
+func (t *baccaratTable) wagers(name string) []WagerRow { return t.wagerRows() }
+func (t *baccaratTable) hints(name string) []MenuCommand {
+ if t.players.get(name) == nil {
+ return nil
+ }
+ return withTableHints(baccaratHintCommands(t, name), t.wagerRows())
+}
+
+// baccaratHintCommands mirrors menuEvent's branches without re-deriving the
+// menu view: a committed wager never advertises another bet.
+func baccaratHintCommands(t *baccaratTable, name string) []MenuCommand {
+ p := t.players.get(name)
+ if p != nil && p.HasBet {
+ return []MenuCommand{
+ {Command: "stop", Desc: "Leave; during a round, leave afterward"},
+ {Command: "table / sitout", Desc: "Check the table / skip betting until you rejoin"},
+ }
+ }
+ commands := []MenuCommand{}
+ if p != nil && p.lastBet > 0 {
+ commands = append(commands, MenuCommand{Command: "bet", Desc: fmt.Sprintf("Repeat %d on %s (also: rebet)", p.lastBet, p.lastSpot)}, MenuCommand{Command: "bet <amount>", Desc: "Change amount; keep " + p.lastSpot})
+ }
+ return append(commands,
+ MenuCommand{Command: fmt.Sprintf("bet %d banker", t.Config.MinBet), Desc: "Choose banker (b), player (p), or tie (t)"},
+ MenuCommand{Command: "bet <amount> on <target>", Desc: "One wager per round; targets: list"},
+ MenuCommand{Command: "stop", Desc: "Leave; during a round, leave afterward"},
+ MenuCommand{Command: "table / sitout", Desc: "Check the table / skip betting until you rejoin"},
+ )
+}
diff --git a/internal/casino/table_ux.go b/internal/casino/table_ux.go
index f4255be..768c041 100644
--- a/internal/casino/table_ux.go
+++ b/internal/casino/table_ux.go
@@ -5,29 +5,40 @@ import (
"strings"
)
-// RulesText is the shared rules view for table commands and room fixtures.
-func (c TableConfig) RulesText() string {
- switch c.Game {
- case GameBlackjack:
- return c.BlackjackRulesText()
- case GameBaccarat:
- return c.BaccaratRulesText()
- case GameCraps:
- return c.CrapsRulesText()
- case GameRoulette:
- rules := c.Label() + "\nStraight numbers pay 35:1; splits 17:1; streets and trios 11:1; corners 8:1; lines 5:1.\n" +
- "1to12/13to24/25to36 and rows 2:1; other outside bets 1:1; the American basket pays 6:1.\n" +
- "Combos: bet 10 on split 1 2 | bet 10 on street 1 2 3 | bet 10 on corner 1 2 4 5 |\n" +
- "bet 10 on line 1 2 3 4 5 6 | bet 10 on trio 0 1 2 | bet 10 on basket.\n"
- if c.Roulette.Racetrack {
- rules += "Racetrack (single zero): bet 10 on voisins | tiers | orphelins | jeu zero | neighbors 17.\n"
+// WagerRow is one line of a table's "list" of available bets, in the game's
+// current state: the bet wording (what follows "bet <amount> on"), its
+// payout, and a brief description of the win condition.
+type WagerRow struct {
+ Bet string
+ Payout string
+ Win string
+}
+
+const (
+ hintCommandRules = "rules"
+ hintCommandList = "list"
+)
+
+// withTableHints finishes any game's hint list: "rules" is always present
+// while seated at a table, and "list" follows when the game named more than
+// one wager a player might want to make (a lone bet is just "bet <amount>").
+// Games whose own menus already append these hints are not double-hinted.
+func withTableHints(commands []MenuCommand, wagerRows []WagerRow) []MenuCommand {
+ for _, c := range commands {
+ if c.Command == hintCommandRules {
+ return commands
}
- return rules + "Zero pockets lose all outside bets. One wager per spin. Use help roulette."
- default:
- return c.Label()
}
+ commands = append(commands, MenuCommand{Command: hintCommandRules, Desc: "This game's full help page"})
+ if len(wagerRows) > 1 {
+ commands = append(commands, MenuCommand{Command: hintCommandList, Desc: "List every bet available now, with payouts"})
+ }
+ return commands
}
+// RulesText is the shared rules view for table commands and room fixtures.
+func (c TableConfig) RulesText() string { return rulesTextOnTable(c) }
+
func (c TableConfig) Label() string {
if c.Game == GameRoulette {
label := "Roulette / Single zero"
@@ -83,11 +94,12 @@ func (c *tableCore[P]) warning(name, text string) Event {
func (c *tableCore[P]) committedMenu(name string) Event {
e := c.private(name, "Your wager is committed; waiting for the round.")
e.Color = "casino_menu"
- e.Menu = &MenuView{Heading: e.Message, Commands: []MenuCommand{
+ commands := []MenuCommand{
{Command: "table", Desc: "View the table"},
{Command: "sitout", Desc: "Sit out after this round"},
{Command: "stop", Desc: "Leave after this round"},
- }}
+ }
+ e.Menu = &MenuView{Heading: e.Message, Commands: withTableHints(commands, nil)}
return e
}
diff --git a/internal/casino/wagers_test.go b/internal/casino/wagers_test.go
new file mode 100644
index 0000000..9501c8a
--- /dev/null
+++ b/internal/casino/wagers_test.go
@@ -0,0 +1,100 @@
+package casino
+
+import "testing"
+
+// The "list" view doubles as the availability sheet: during the insurance
+// window it names the insurance stake and the decline, and during a turn it
+// names the wagers the current hand could still add (double/split/surrender).
+func TestBlackjackWagerListFollowsTheHand(t *testing.T) {
+ table := newBlackjackTable(1, TableConfig{ID: "blackjack", Game: GameBlackjack}, newTestRand())
+ w := &testWallet{credits: 100}
+ table.players.add("alice", &blackjackPlayer{
+ Participant: Participant{Name: "alice", HasBet: true, Connected: true, Wallet: w, Wager: Wager{Total: 10}},
+ hands: []*blackjackHand{{bet: 10, cards: []card{{rank: "10"}, {rank: "8"}}}},
+ })
+ table.dealer.cards = []card{{rank: "K"}, {rank: "A"}}
+ table.phase = blackjackInsurance
+ rows := table.wagers("alice")
+ if len(rows) != 2 || rows[0].Bet != "insurance" || rows[1].Bet != "decline" {
+ t.Fatalf("insurance rows=%+v", rows)
+ }
+ if rows[0].Payout != "2:1" || rows[0].Win != "Covers dealer blackjack; the stake costs 5" {
+ t.Fatalf("insurance wording=%+v", rows[0])
+ }
+
+ // A turn with a splittable pair and surrender available lists both
+ // wagers; a hit/stand-only hand lists none.
+ table.phase = blackjackPlaying
+ table.activePlayer = 0
+ table.activeHand = 0
+ table.players.get("alice").hands = []*blackjackHand{{bet: 10, cards: []card{{rank: "8"}, {rank: "8"}}}}
+ table.dealer.cards = []card{{rank: "K"}, {rank: "7"}}
+ surrender := true
+ table.Rules.Surrender = &surrender
+ if rows := table.wagers("alice"); len(rows) == 0 {
+ t.Fatal("turn rows missing")
+ }
+ table.Rules.Surrender = nil
+ table.players.get("alice").hands = []*blackjackHand{{bet: 10, cards: []card{{rank: "K"}, {rank: "6"}}}}
+ rows = table.wagers("alice")
+ if len(rows) != 3 || rows[0].Bet != "hit" || rows[2].Bet != "double" {
+ t.Fatalf("plain hand rows=%+v", rows)
+ }
+}
+
+// The betting phase has exactly one wager: no rows, and no "list" hint.
+func TestBlackjackBettingPhaseHidesList(t *testing.T) {
+ table := newBlackjackTable(1, TableConfig{ID: "blackjack", Game: GameBlackjack, BettingTicks: 10}, newTestRand())
+ table.join("a")
+ hints := table.hints("a")
+ for _, c := range hints {
+ if c.Command == "list" {
+ t.Fatal("list advertised with a single wager", hints)
+ }
+ if c.Command != "rules" {
+ continue
+ }
+ }
+ foundRules := false
+ for _, c := range hints {
+ if c.Command == "rules" {
+ foundRules = true
+ }
+ }
+ if !foundRules {
+ t.Fatal("rules hint missing", hints)
+ }
+}
+
+// Craps variants that take one target (pass only) never advertise "list".
+func TestCrapsSingleBetVariantsHideList(t *testing.T) {
+ for _, v := range []string{"simplified", "high_point", "die_rich"} {
+ tb := variantFixture(v)
+ tb.join("a")
+ for _, c := range tb.hints("a") {
+ if c.Command == "list" {
+ t.Fatal(v, "list advertised for a single-bet variant")
+ }
+ if c.Command == "rules" {
+ break
+ }
+ }
+ }
+}
+
+// Multi-bet variants advertise the "list" hint at every phase.
+func TestCrapsMultiBetVariantsAdvertiseList(t *testing.T) {
+ for _, v := range []string{"bank", "crapless", "new_york", "diceless"} {
+ tb := variantFixture(v)
+ tb.join("a")
+ found := false
+ for _, c := range tb.hints("a") {
+ if c.Command == "list" {
+ found = true
+ }
+ }
+ if !found {
+ t.Fatal(v, "list hint missing", tb.hints("a"))
+ }
+ }
+}