diff options
| author | historia <[not public]> | 2026-09-30 03:55:37 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-30 03:55:37 -0400 |
| commit | 735428f0667f67c12fdf3caca872d7dc65e2ce26 (patch) | |
| tree | 92c9931f223bfd50ced4f1954130d879640a435b /internal/game/casino_test.go | |
| parent | ffc7b582e9c14fdc2e579b9239b5ff7ad9a0d90a (diff) | |
| download | thehouseoficarus-735428f0667f67c12fdf3caca872d7dc65e2ce26.tar.gz | |
feat: restyle roulette presentation
Diffstat (limited to 'internal/game/casino_test.go')
| -rw-r--r-- | internal/game/casino_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
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) + } +} |
