aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino_hints_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/casino_hints_test.go')
-rw-r--r--internal/game/casino_hints_test.go62
1 files changed, 62 insertions, 0 deletions
diff --git a/internal/game/casino_hints_test.go b/internal/game/casino_hints_test.go
new file mode 100644
index 0000000..21739d2
--- /dev/null
+++ b/internal/game/casino_hints_test.go
@@ -0,0 +1,62 @@
+package game
+
+import (
+ "strings"
+ "testing"
+
+ "thehouseoficarus/internal/casino"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+// The default must be the low-noise "once" mode.
+func TestCasinoHintsDefaultIsOnce(t *testing.T) {
+ if got := player.New("alice").OptionString("casino_hints"); got != "once" {
+ t.Fatalf("casino_hints default=%q, want once", got)
+ }
+}
+
+// casino_hints on shows hints on every menu; once shows them at sit-down only;
+// off never does. "what" always lists the live hints regardless.
+func TestCasinoHintsOption(t *testing.T) {
+ for _, tc := range []struct {
+ mode string
+ join, after bool
+ }{
+ {"on", true, true},
+ {"once", true, false},
+ {"off", false, false},
+ } {
+ t.Run(tc.mode, func(t *testing.T) {
+ g, sess, conn := uxCasinoGame(t)
+ g.Hub = net.NewHub()
+ g.Hub.EnterRoom(sess, 1)
+ sess.Player.Options = map[string]any{"color": "none", "unicode": true, "casino_hints": tc.mode}
+ cfg := casino.TableConfig{ID: "roulette", Game: casino.GameRoulette, Roulette: casino.RouletteConfig{SpinTicks: 8}}
+ g.emitCasinoEvents(g.Casino.Join(1, cfg, sess.Player.Name))
+ if got := strings.Contains(string(conn.data), "bet N on BET"); got != tc.join {
+ t.Fatalf("join hints=%v, want %v: %q", got, tc.join, conn.data)
+ }
+ sess.ClearPrompt()
+ g.executeBet(sess, []string{"2", "2"}, "bet 2 2")
+ if !strings.Contains(string(conn.data), "You bet 2 on 2.") {
+ t.Fatalf("bet N N did not resolve: %q", conn.data)
+ }
+ for i := 0; i < 8; i++ {
+ conn.data = nil
+ g.CasinoTick()
+ }
+ if got := strings.Contains(string(conn.data), "bet N on BET"); got != tc.after {
+ t.Fatalf("post-settlement hints=%v, want %v: %q", got, tc.after, conn.data)
+ }
+ // "what" is an explicit request: it always lists the live hints
+ // and never the room's exits while seated.
+ conn.data = nil
+ g.executeVerbs(sess, nil, "what")
+ text := string(conn.data)
+ if !strings.Contains(text, "bet N on BET") || strings.Contains(text, "Exits:") || strings.Contains(text, "north") {
+ t.Fatalf("what at the table wrong: %q", text)
+ }
+ })
+ }
+}