From 9666676766bf21364f4fc4d0d1d336e72f2a91b4 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 6 Oct 2026 12:57:23 -0400 Subject: refactor: split casino.go, dedup helpers, remove audit docs --- internal/game/render_slots.go | 86 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 internal/game/render_slots.go (limited to 'internal/game/render_slots.go') diff --git a/internal/game/render_slots.go b/internal/game/render_slots.go new file mode 100644 index 0000000..82c57e7 --- /dev/null +++ b/internal/game/render_slots.go @@ -0,0 +1,86 @@ +package game + +import ( + "strings" + + "thehouseoficarus/internal/casino" + "thehouseoficarus/internal/color" +) + +func renderSlotSnapshot(snapshot *casino.SlotSnapshot, mode string, unicode bool) string { + if snapshot == nil { + return "" + } + left, junction, right, horizontal, vertical := '+', '+', '+', '-', '|' + bottomLeft, bottomJunction, bottomRight := '+', '+', '+' + if unicode { + left, junction, right, horizontal, vertical = '\u250c', '\u252c', '\u2510', '\u2500', '\u2502' + bottomLeft, bottomJunction, bottomRight = '\u2514', '\u2534', '\u2518' + } + separator := string(left) + for reel := 0; reel < 5; reel++ { + if reel > 0 { + separator += string(junction) + } + separator += strings.Repeat(string(horizontal), 9) + } + separator += string(right) + lines := []string{casinoFrame(mode, separator)} + frameVertical := casinoFrame(mode, string(vertical)) + for row := 0; row < 3; row++ { + line := frameVertical + for reel := 0; reel < 5; reel++ { + value := "..." + if reel < snapshot.StoppedReels { + value = snapshot.Grid[row][reel] + } + // Pad to the fixed 7-cell reel width; a malformed profile could + // otherwise make this negative and panic. Validation caps the id + // length, so this is a defence-in-depth backstop. + pad := 7 - len(value) + if pad < 0 { + pad = 0 + } + line += " " + colorSlotSymbol(mode, value) + strings.Repeat(" ", pad) + " " + frameVertical + } + lines = append(lines, line) + } + bottom := string(bottomLeft) + for reel := 0; reel < 5; reel++ { + if reel > 0 { + bottom += string(bottomJunction) + } + bottom += strings.Repeat(string(horizontal), 9) + } + bottom += string(bottomRight) + lines = append(lines, casinoFrame(mode, bottom)) + return strings.Join(lines, "\n") +} + +func casinoFrame(mode, text string) string { + spec := color.NoColor() + spec.Fg = 244 + return color.Render(mode, spec, text) +} + +func colorSlotSymbol(mode, symbol string) string { + spec := color.NoColor() + spec.Fg = 250 + switch symbol { + case "straw": + spec.Fg = 220 + case "stick": + spec.Fg = 46 + case "brick": + spec.Fg = 196 + case "hat": + spec.Fg = 201 + case "wolf": + spec.Fg = 39 + case "scatter": + spec.Fg = 226 + default: + spec.Dim = true + } + return color.Render(mode, spec, symbol) +} -- cgit v1.2.3