From 3eb087201f46d887da7a965fd2510125e306743f Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 2 Apr 2023 00:09:17 -0700 Subject: [PATCH] more terminal utility functions --- cardsim/terminalui.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cardsim/terminalui.go b/cardsim/terminalui.go index 5f29064..0a7e19f 100644 --- a/cardsim/terminalui.go +++ b/cardsim/terminalui.go @@ -2,6 +2,7 @@ package cardsim import ( "fmt" + "os" "strconv" "strings" ) @@ -123,3 +124,22 @@ func pickNextAction[C StatsCollection](p *Player[C]) (isCard bool, cardIdx int, func cls() { fmt.Println("\033[H\033[2J") } + +func divider() { + fmt.Println() + fmt.Println(SectionBreak.String()) + fmt.Println() +} + +func confirmQuit() { + divider() + fmt.Println("Are you sure you want to quit? (Y/N) ") + var s string + fmt.Scanln(&s) + s = strings.TrimSpace(s) + s = strings.ToLower(s) + if strings.HasPrefix(s, "y") { + fmt.Println("Bye!") + os.Exit(0) + } +}