aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/casino_test.go')
-rw-r--r--internal/game/casino_test.go42
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)
+ }
+}