Implement Stats Mode.
Also rewords some prompts. Might as well be thorough in accepting reasonable inputs.
This commit is contained in:
parent
25a9eed3f0
commit
5a2158f525
@ -87,7 +87,7 @@ func pickNextAction[C StatsCollection](p *Player[C]) (isCard bool, cardIdx int,
|
|||||||
max := displayHandMenu(p, handOffset)
|
max := displayHandMenu(p, handOffset)
|
||||||
|
|
||||||
divider()
|
divider()
|
||||||
fmt.Printf("Show just (M)essages, (S)tats, (A)ctions, make a choice (1-%d), or (Q)uit? >", max+1)
|
fmt.Printf("Show just (M)essages, (I)nfo Panels, (A)ctions, make a choice (1-%d), or (Q)uit? > ", max+1)
|
||||||
input := getResponse()
|
input := getResponse()
|
||||||
switch input {
|
switch input {
|
||||||
// Special cases
|
// Special cases
|
||||||
@ -95,7 +95,7 @@ func pickNextAction[C StatsCollection](p *Player[C]) (isCard bool, cardIdx int,
|
|||||||
cls()
|
cls()
|
||||||
displayMessageSection(p)
|
displayMessageSection(p)
|
||||||
wait()
|
wait()
|
||||||
case "s", "stat", "stats":
|
case "s", "stat", "stats", "i", "info", "p", "panel", "panels", "infopanel", "infopanels":
|
||||||
statsMode(p)
|
statsMode(p)
|
||||||
case "a", "act", "actions":
|
case "a", "act", "actions":
|
||||||
actionsMode(p)
|
actionsMode(p)
|
||||||
@ -157,7 +157,7 @@ func divider() {
|
|||||||
|
|
||||||
func confirmQuit() {
|
func confirmQuit() {
|
||||||
divider()
|
divider()
|
||||||
fmt.Println("Are you sure you want to quit? (Y/N) ")
|
fmt.Println("Are you sure you want to quit? (Y/N) > ")
|
||||||
s := getResponse()
|
s := getResponse()
|
||||||
if s == "y" || s == "yes" {
|
if s == "y" || s == "yes" {
|
||||||
fmt.Println("Bye!")
|
fmt.Println("Bye!")
|
||||||
@ -235,9 +235,9 @@ func promptCard[C StatsCollection](p *Player[C], card Card[C]) (optionIdx int, e
|
|||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if valid {
|
if valid {
|
||||||
fmt.Printf("Go (B)ack, (Q)uit, or enact a choice (1 - %d)? >", len(opts)+1)
|
fmt.Printf("Go (B)ack, (Q)uit, or enact a choice (1 - %d)? > ", len(opts)+1)
|
||||||
} else {
|
} else {
|
||||||
fmt.Print("Go (B)ack or (Q)uit? >")
|
fmt.Print("Go (B)ack or (Q)uit? > ")
|
||||||
}
|
}
|
||||||
read := getResponse()
|
read := getResponse()
|
||||||
switch read {
|
switch read {
|
||||||
@ -314,3 +314,41 @@ func displayCard[C StatsCollection](p *Player[C], card Card[C]) ([]CardOption[C]
|
|||||||
}
|
}
|
||||||
return opts, valid, errs.Emit()
|
return opts, valid, errs.Emit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func statsMode[C StatsCollection](p *Player[C]) error {
|
||||||
|
var errs ErrorCollector
|
||||||
|
for {
|
||||||
|
cls()
|
||||||
|
n := displayStatsMenu(p)
|
||||||
|
if n <= 0 {
|
||||||
|
fmt.Println("No info panels are available.")
|
||||||
|
wait()
|
||||||
|
return errs.Emit()
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
fmt.Printf("Go (B)ack, (Q)uit, or view an info panel (1-%d)? > ")
|
||||||
|
s := getResponse()
|
||||||
|
switch s {
|
||||||
|
case "b", "back":
|
||||||
|
return errs.Emit()
|
||||||
|
case "q", "quit":
|
||||||
|
confirmQuit()
|
||||||
|
default:
|
||||||
|
v, err := strconv.Atoi(s)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Sorry, I don't understand.")
|
||||||
|
wait()
|
||||||
|
} else if v <= 0 || v > n {
|
||||||
|
fmt.Println("There's no info panel with that index.")
|
||||||
|
} else {
|
||||||
|
err := displayOnePanel(p, p.InfoPanels[v-1])
|
||||||
|
errs.Add(err)
|
||||||
|
if IsSeriousError(err) {
|
||||||
|
return errs.Emit()
|
||||||
|
}
|
||||||
|
wait()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Loop to re-display info panels menu.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user