diff options
| author | historia <[not public]> | 2026-10-02 01:54:37 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-02 01:54:37 -0400 |
| commit | d3a305d1d7962f82af2397760cf8008758bddd1d (patch) | |
| tree | f91f0deb342c20f2993e5366f772c3432648f426 /internal/game/casino_rules_list_test.go | |
| parent | 8eea0e4e06a4aaa6a18edabd9897d3bea1ea2ca0 (diff) | |
| download | thehouseoficarus-d3a305d1d7962f82af2397760cf8008758bddd1d.tar.gz | |
feat: better 'list' bet table, multiple bets in baccarat
Diffstat (limited to 'internal/game/casino_rules_list_test.go')
| -rw-r--r-- | internal/game/casino_rules_list_test.go | 84 |
1 files changed, 66 insertions, 18 deletions
diff --git a/internal/game/casino_rules_list_test.go b/internal/game/casino_rules_list_test.go index 3d91ecf..e83c277 100644 --- a/internal/game/casino_rules_list_test.go +++ b/internal/game/casino_rules_list_test.go @@ -85,6 +85,28 @@ func TestRulesOutsideCasinoFallsBackToGuide(t *testing.T) { } // TestListFollowsGameState covers the list contract end to end: come-out +// listTargets returns the bet names rendered in the first table column, +// working for both the unicode and ASCII table borders. +func listTargets(text string) map[string]bool { + targets := map[string]bool{} + for _, line := range strings.Split(text, "\n") { + line = strings.TrimSpace(line) + if !strings.HasPrefix(line, "║") && !strings.HasPrefix(line, "|") { + continue + } + line = strings.TrimPrefix(strings.TrimPrefix(line, "║"), "|") + for _, sep := range []string{"│", "|"} { + if at := strings.Index(line, sep); at >= 0 { + line = line[:at] + } + } + if cell := strings.TrimSpace(line); cell != "" { + targets[cell] = true + } + } + return targets +} + // lists the line and one-roll bets, a point adds place/odds rows, bonus // bets close after the first roll, and single-bet editions print one line. func TestListFollowsGameState(t *testing.T) { @@ -95,13 +117,14 @@ func TestListFollowsGameState(t *testing.T) { conn.data = nil g.executeList(sess, nil, "list") text := stripANSI(string(conn.data)) - for _, want := range []string{"bet <amount> on pass", "bet <amount> on dontpass", "bet <amount> on field", "bet <amount> on craps", "bet <amount> on fire"} { - if !strings.Contains(text, want) { + targets := listTargets(text) + for _, want := range []string{"pass", "dontpass", "field", "craps", "fire"} { + if !targets[want] { t.Fatalf("come-out list missing %q: %q", want, text) } } for _, gone := range []string{"place 6", "odds pass"} { - if strings.Contains(text, gone) { + if targets[gone] { t.Fatalf("come-out list advertised %q: %q", gone, text) } } @@ -111,37 +134,39 @@ func TestListFollowsGameState(t *testing.T) { conn.data = nil g.executeList(sess, nil, "list") text = stripANSI(string(conn.data)) - if !strings.Contains(text, "place 6") || !strings.Contains(text, "odds pass") { + targets = listTargets(text) + if !targets["place 6"] || !targets["odds pass"] { t.Fatalf("point list missing place/odds: %q", text) } - if strings.Contains(text, "bet <amount> on pass\n") || strings.Contains(text, "fire") { + if targets["fire"] { t.Fatalf("point list still advertising closed bets: %q", text) } } -// TestListSingleBetGamesStayBrief: editions with one wager (Simplified) and -// one-wager games (blackjack) answer in one line, no table. -func TestListSingleBetGamesStayBrief(t *testing.T) { +// TestListSingleBetGamesRenderOneRow: editions with one wager (Simplified) +// and one-wager games (blackjack) answer with a one-row table. +func TestListSingleBetGamesRenderOneRow(t *testing.T) { room := "name: Simple\ncasino_tables:\n - id: simple\n game: craps\n craps:\n variant: simplified\n" g, sess, conn := casinoCrapsGame(t, room) g.executePlay(sess, []string{"craps"}, "play craps") conn.data = nil g.executeList(sess, nil, "list") text := stripANSI(string(conn.data)) - if strings.Contains(text, "Bet") && strings.Contains(text, "Pays") && strings.Contains(text, "Win if") { - t.Fatalf("single-bet game rendered a table: %q", text) + if !strings.Contains(text, "Odds") { + t.Fatalf("single-bet list did not render the table header: %q", text) } - if !strings.Contains(text, "bet <amount> on pass") { - t.Fatalf("single-bet line missing the wager: %q", text) + if targets := listTargets(text); !targets["pass"] { + t.Fatalf("single-bet table missing the wager: %q", text) } - // Blackjack: one wager, no table, and the list command still answers. + // Blackjack: one wager, one row, and the list command still answers. room = "name: BJ\ncasino_tables:\n - id: bj\n game: blackjack\n" g, sess, conn = casinoCrapsGame(t, room) g.executePlay(sess, []string{"bj"}, "play bj") conn.data = nil g.executeList(sess, nil, "list") - if text := stripANSI(string(conn.data)); !strings.Contains(text, "only wager") { + text = stripANSI(string(conn.data)) + if targets := listTargets(text); !targets["bet <amount>"] { t.Fatalf("blackjack list: %q", text) } } @@ -225,8 +250,9 @@ func TestListRouletteAndBaccarat(t *testing.T) { conn.data = nil g.executeList(sess, nil, "list") text := stripANSI(string(conn.data)) - for _, want := range []string{"bet <amount> on <number>", "bet <amount> on red / black", "bet <amount> on voisins", "bet <amount> on basket"} { - if !strings.Contains(text, want) { + targets := listTargets(text) + for _, want := range []string{"<number>", "red / black", "voisins", "basket"} { + if !targets[want] { t.Fatalf("roulette list missing %q: %q", want, text) } } @@ -237,9 +263,31 @@ func TestListRouletteAndBaccarat(t *testing.T) { conn.data = nil g.executeList(sess, nil, "list") text = stripANSI(string(conn.data)) - for _, want := range []string{"bet <amount> on banker (b)", "1:1 (3-card 7 pushes)", "bet <amount> on dragon_7", "bet <amount> on panda_8"} { - if !strings.Contains(text, want) { + targets = listTargets(text) + for _, want := range []string{"banker", "dragon_7", "panda_8"} { + if !targets[want] { t.Fatalf("baccarat list missing %q: %q", want, text) } } + if !strings.Contains(text, "1:1 (3-card 7 pushes)") { + t.Fatalf("baccarat list dropped the EZ banker rule: %q", text) + } +} + +// The commission is implied by the 0.95:1 ratio and must not be repeated. +func TestListBaccaratDropsCommissionProse(t *testing.T) { + g, sess, conn := casinoCrapsGame(t, "name: B\ncasino_tables:\n - id: b\n game: baccarat\n") + g.executePlay(sess, []string{"b"}, "play b") + conn.data = nil + g.executeList(sess, nil, "list") + text := stripANSI(string(conn.data)) + if strings.Contains(text, "commission") { + t.Fatalf("list repeated the implied commission: %q", text) + } + if targets := listTargets(text); !targets["banker"] { + t.Fatalf("baccarat list lost the banker row: %q", text) + } + if !strings.Contains(text, "0.95:1") { + t.Fatalf("baccarat list lost the banker ratio: %q", text) + } } |
