diff options
Diffstat (limited to 'internal/game/render_roulette.go')
| -rw-r--r-- | internal/game/render_roulette.go | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/internal/game/render_roulette.go b/internal/game/render_roulette.go index 218a91f..a0f1e04 100644 --- a/internal/game/render_roulette.go +++ b/internal/game/render_roulette.go @@ -16,8 +16,10 @@ import ( func renderRouletteSnapshot(s *casino.RouletteSnapshot, mode string, unicode bool, size int) string { switch s.Phase { case "playing": - // A blank line on either side keeps the wheel from crowding the prose. - return "\n" + renderRouletteWheel(s.Wheel, mode, unicode) + "\n" + if s.SpinFrame == 0 { + return "" + } + return renderRouletteSpin(s, mode, unicode) case "result": return "\n" + renderRouletteResult(s.Pockets, mode, unicode, size) + "\n" default: @@ -27,6 +29,27 @@ func renderRouletteSnapshot(s *casino.RouletteSnapshot, mode string, unicode boo } } +// A scrolling strip works in telnet scrollback without cursor-control escapes. +func renderRouletteSpin(s *casino.RouletteSnapshot, mode string, unicode bool) string { + var line strings.Builder + for i, pocket := range s.SpinPockets { + fg, _ := roulettePocketColor(pocket) + if fg == 0 { + fg = 8 // visible charcoal rather than invisible black on a dark terminal + } + text := "█" + if !unicode { + text = "#" + } + if i == s.BallPosition { + line.WriteString(roulettePaint(mode, ".", fg)) + } else { + line.WriteString(color.Render(mode, color.ColorSpec{Fg: fg, Bg: -1}, text)) + } + } + return line.String() +} + func rouletteInk(mode, text string) string { return color.Render(mode, color.ColorSpec{Fg: 15, Bg: -1}, text) } |
