From 592c8778525d9929a1291b67ca9bacfb268a75d6 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 2 Apr 2023 00:43:17 -0700 Subject: [PATCH] More display components. --- cardsim/terminalui.go | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/cardsim/terminalui.go b/cardsim/terminalui.go index d85edda..2dd56fa 100644 --- a/cardsim/terminalui.go +++ b/cardsim/terminalui.go @@ -71,6 +71,9 @@ func pickNextAction[C StatsCollection](p *Player[C]) (isCard bool, cardIdx int, divider() } handOffset := displayPermanentActionsMenu(p, actionsOffset) + if handOffset > actionsOffset { + fmt.Println() + } max := displayHandMenu(p, handOffset) divider() @@ -180,7 +183,31 @@ func displayStatsMenu[C StatsCollection](p *Player[C]) int { fmt.Println("Info Panels") fmt.Println("-----------") for i, s := range p.InfoPanels { - fmt.Printf("[%2d]: %s", i+1, s.Title(p).String()) + fmt.Printf("[%2d]: %s\n", i+1, s.Title(p).String()) } return len(p.InfoPanels) } + +func displayPermanentActionsMenu[C StatsCollection](p *Player[C], offset int) int { + if len(p.PermanentActions) == 0 { + return offset + } + fmt.Println("Always Available") + fmt.Println("----------------") + for i, s := range p.PermanentActions { + fmt.Printf("[%2d]: %s\n", i+offset+1, s.Title(p)) + } + return offset + len(p.PermanentActions) +} + +func displayHandMenu[C StatsCollection](p *Player[C], offset int) int { + if len(p.Hand) == 0 { + return offset + } + fmt.Println("Hand") + fmt.Println("----") + for i, s := range p.Hand { + fmt.Printf("[%2d]: %s\n", i+offset+1, s.Title(p)) + } + return offset + len(p.Hand) +}