1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package game
import (
"fmt"
"strings"
"thehouseoficarus/internal/color"
)
// The two packs have ranks 1-6, no suits. Distinct pack labels make the
// replacement model visible without suggesting a conventional poker shoe.
func renderCrapsCards(cards [2]int, mode string, unicode bool, style string) string {
if cards[0] < 1 || cards[0] > 6 || cards[1] < 1 || cards[1] > 6 {
return ""
}
top, bottom, bar := "+-------+", "+-------+", "|"
if unicode {
top, bottom, bar = "╭───────╮", "╰───────╯", "│"
}
spec := color.ColorSpec{Fg: 15, Bg: 0, Bold: true}
if style == "light" {
spec = color.ColorSpec{Fg: 0, Bg: 15, Bold: true}
}
var out strings.Builder
for row := 0; row < 5; row++ {
out.WriteString(" ")
for i, n := range cards {
line := top
switch row {
case 1:
line = fmt.Sprintf("%s PACK %c%s", bar, 'A'+i, bar)
case 2:
line = fmt.Sprintf("%s %d %s", bar, n, bar)
case 3:
line = bar + " " + bar
case 4:
line = bottom
}
out.WriteString(color.Render(mode, spec, line) + " ")
}
out.WriteByte('\n')
}
fmt.Fprintf(&out, " Cards total: %d | Both packs replaced and reshuffled each draw.\n", cards[0]+cards[1])
return out.String()
}
|