diff options
| author | historia <[not public]> | 2026-10-03 02:16:00 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-03 02:16:00 -0400 |
| commit | 6232d41e5639f9c38e47b2bb65266e343ca26e8f (patch) | |
| tree | ad0c1676838a6c7e162d3a5c055f914016dac803 /internal/game/casino_test.go | |
| parent | efccf58741ae43d9e891c6b743b146982b344ccf (diff) | |
| download | thehouseoficarus-6232d41e5639f9c38e47b2bb65266e343ca26e8f.tar.gz | |
feat: add casino_hints option and standardize casino command syntax
Diffstat (limited to 'internal/game/casino_test.go')
| -rw-r--r-- | internal/game/casino_test.go | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/internal/game/casino_test.go b/internal/game/casino_test.go index 2f72d07..0b82945 100644 --- a/internal/game/casino_test.go +++ b/internal/game/casino_test.go @@ -63,7 +63,7 @@ func TestExecuteBetRejectsInvalidMachineArgs(t *testing.T) { for _, args := range [][]string{{"banana"}, {"-5"}, {"10", "extra"}} { conn.data = nil g.executeBet(sess, args, "bet "+strings.Join(args, " ")) - if !strings.Contains(string(conn.data), "Use bet, bet <amount>, or bet max.") { + if !strings.Contains(string(conn.data), "Use bet, bet N, or bet max.") { t.Fatalf("bet %v: expected usage error, got %q", args, string(conn.data)) } } @@ -110,13 +110,18 @@ func TestExecuteBetParsesBaccaratSpots(t *testing.T) { if !strings.Contains(string(conn.data), "must be on player, banker, or tie") { t.Fatalf("bet 5 on 17: expected the table to receive the numeric spot, got %q", string(conn.data)) } - // Two amounts or two spots are usage errors. - for _, args := range [][]string{{"10", "20"}, {"player", "banker"}} { - conn.data = nil - g.executeBet(sess, args, "bet "+strings.Join(args, " ")) - if !strings.Contains(string(conn.data), "Use bet,") { - t.Fatalf("bet %v: expected usage error, got %q", args, string(conn.data)) - } + // A number after the amount is the target ("bet 10 20" == "bet 10 on + // 20"), so baccarat rejects the value rather than the syntax. + conn.data = nil + g.executeBet(sess, []string{"10", "20"}, "bet 10 20") + if !strings.Contains(string(conn.data), "must be on player, banker, or tie") { + t.Fatalf("bet 10 20: expected the table to receive the numeric spot, got %q", string(conn.data)) + } + // Two spots remain a usage error. + conn.data = nil + g.executeBet(sess, []string{"player", "banker"}, "bet player banker") + if !strings.Contains(string(conn.data), "Use bet,") { + t.Fatalf("bet player banker: expected usage error, got %q", string(conn.data)) } // A bare first bet asks for a target (via the rebet path). conn.data = nil @@ -129,22 +134,29 @@ func TestExecuteBetParsesBaccaratSpots(t *testing.T) { func TestCasinoMenuRendersAlignedColoredCommands(t *testing.T) { g := &Game{Casino: casino.NewManager(1)} conn := &casinoTestConn{} - sess := &net.Session{Player: player.New("alice"), Conn: conn} + p := player.New("alice") + p.Options = map[string]any{"casino_hints": "on"} + sess := &net.Session{Player: p, Conn: conn} g.loggedInChars = map[string]*net.Session{"alice": sess} menu := &casino.MenuView{Heading: "Your slot machine bet is set to 10.", ShowBalance: true, Commands: []casino.MenuCommand{ - {Command: "bet <amount>", Desc: "Set your wager"}, + {Command: "bet N", Desc: "Set your wager"}, {Command: "spin", Desc: "Spin using your current wager"}, }} msg := g.casinoPrivateMessage(sess, "casino_menu", menu, "Your slot machine bet is set to 10.") if !strings.Contains(regexp.MustCompile(`\x1b\[[0-9;]*m`).ReplaceAllString(msg, ""), "Available 0 (0 chips + 0 credits)") { t.Fatalf("missing balance line: %q", msg) } - // Commands are painted with the "command" color (0A bold). - if !strings.Contains(msg, "\033[1m\033[38;5;10mbet <amount>\033[0m") { - t.Fatalf("command not colored: %q", msg) + // Literal text uses the "command" color (0A bold); the N variable uses the + // distinct "command_variable" color (B4 bold). + if !strings.Contains(msg, color.FgCode("xterm256", 10)) || !strings.Contains(msg, color.FgCode("xterm256", 180)) { + t.Fatalf("command/variable not colored: %q", msg) + } + plain := regexp.MustCompile(`\x1b\[[0-9;]*m`).ReplaceAllString(msg, "") + if !strings.Contains(plain, "bet N") { + t.Fatalf("command text missing: %q", plain) } // Shorter commands are right-padded to align the descriptions. - if !strings.Contains(msg, "\033[1m\033[38;5;10mspin \033[0m Spin using your current wager") { + if !strings.Contains(msg, "\033[1m\033[38;5;10mspin \033[0m Spin using your current wager") { t.Fatalf("commands not aligned: %q", msg) } } |
