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) }