From 735428f0667f67c12fdf3caca872d7dc65e2ce26 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 30 Sep 2026 03:55:37 -0400 Subject: feat: restyle roulette presentation --- internal/game/casino_test.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'internal/game/casino_test.go') diff --git a/internal/game/casino_test.go b/internal/game/casino_test.go index 3a1fc41..2f72d07 100644 --- a/internal/game/casino_test.go +++ b/internal/game/casino_test.go @@ -246,3 +246,45 @@ func TestRenderBlackjackSnapshotUsesCompactASCIIArt(t *testing.T) { t.Fatalf("light card edges flipped: top=%q bottom=%q", plainLines[1], plainLines[7]) } } + +// Casino settlements carry inline color tags for the outcome and each bet. +// The presentation layer must expand them per recipient (white prose, green +// win, red loss) rather than leaking the raw tags. +func TestCasinoProseExpandsSettlementTags(t *testing.T) { + g := &Game{} + p := player.New("alice") + p.Options = map[string]any{"color": "xterm256"} + sess := &net.Session{Player: p} + got := g.casinoProse(sess, "casino_result_loss", + "{casino_result_loss}LOSS{/} {casino_payout}-1 credit{/}\n {casino_action}red:{/} {casino_result_loss}-1 credit{/}") + if strings.Contains(got, "{") { + t.Fatalf("raw tag leaked into rendered text: %q", got) + } + for _, want := range []string{"LOSS", "-1 credit", "red:"} { + if !strings.Contains(got, want) { + t.Fatalf("missing %q in %q", want, got) + } + } + // White label, red loss, and the payout color on the headline total. + if !strings.Contains(got, color.FgCode("xterm256", 255)) { + t.Fatalf("bet label is not white: %q", got) + } + if !strings.Contains(got, color.FgCode("xterm256", 196)) { + t.Fatalf("loss is not bold red: %q", got) + } + if !strings.Contains(got, color.StyleCode("bold")) { + t.Fatalf("loss/amount is not bold: %q", got) + } +} + +// The landing pocket is the only bolded part of the spin announcement. +func TestCasinoProseBoldsLandingPocket(t *testing.T) { + g := &Game{} + p := player.New("alice") + p.Options = map[string]any{"color": "xterm256"} + sess := &net.Session{Player: p} + got := g.casinoProse(sess, "casino_action", "The ball lands in {casino_emphasis}20{/}!") + if !strings.Contains(got, color.StyleCode("bold")+color.FgCode("xterm256", 255)+"20") { + t.Fatalf("landing pocket is not bold white: %q", got) + } +} -- cgit v1.2.3