aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-01 17:24:54 -0400
committerhistoria <[not public]>2026-10-01 17:24:54 -0400
commit4e2a95503e4ea4c830510f5aea23fac7948ddc41 (patch)
tree690b06df9094480febfaaaf7d9fc71ef7b81848d /internal/game/casino.go
parentd762f8e1360cf38b8e11e69083c2dad59ec7130e (diff)
downloadthehouseoficarus-4e2a95503e4ea4c830510f5aea23fac7948ddc41.tar.gz
feat: set and autoset in pai gow, better showdown arrangement, better formatting
Diffstat (limited to 'internal/game/casino.go')
-rw-r--r--internal/game/casino.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/internal/game/casino.go b/internal/game/casino.go
index 66c90a1..b15c965 100644
--- a/internal/game/casino.go
+++ b/internal/game/casino.go
@@ -897,6 +897,54 @@ func cardsLine(mode string, cards []casino.CardView, size int, unicode bool, sty
return lines
}
+// renderCardRow lays cards side by side, each column padded to its own art
+// or label width, and appends an optional centered label row. minWidth lets
+// the caller force a floor (video poker's HELD labels need it) while Pai Gow
+// passes 0. It is the shared "cards with numbers underneath" presentation.
+func renderCardRow(cards []casino.CardView, labels []string, minWidth int, mode string, unicode bool, size int, style string, art *cardart.Store) []string {
+ if len(cards) == 0 {
+ return nil
+ }
+ artLines := make([][]string, len(cards))
+ widths := make([]int, len(cards))
+ height := 0
+ for i, card := range cards {
+ artLines[i] = cardsLine(mode, []casino.CardView{card}, size, unicode, style, art)
+ height = max(height, len(artLines[i]))
+ widths[i] = minWidth
+ for _, line := range artLines[i] {
+ widths[i] = max(widths[i], color.VisibleLen(line))
+ }
+ if i < len(labels) {
+ widths[i] = max(widths[i], color.VisibleLen(labels[i]))
+ }
+ }
+ lines := make([]string, 0, height+1)
+ for row := 0; row < height; row++ {
+ parts := make([]string, len(cards))
+ for i := range cards {
+ text := ""
+ if row < len(artLines[i]) {
+ text = artLines[i][row]
+ }
+ parts[i] = rouletteCenter(text, widths[i])
+ }
+ lines = append(lines, strings.Join(parts, " "))
+ }
+ if len(labels) > 0 {
+ parts := make([]string, len(cards))
+ for i := range cards {
+ text := ""
+ if i < len(labels) {
+ text = labels[i]
+ }
+ parts[i] = rouletteCenter(text, widths[i])
+ }
+ lines = append(lines, strings.Join(parts, " "))
+ }
+ return lines
+}
+
func cardRenderSize(unicode bool, size int) int {
if size == 1 {
return 1