Compare commits
No commits in common. "74ca51b21db3263f5ff194058d9f658d2defa1e2" and "25a9eed3f0d4ba1d15ca569daabaf69700117b69" have entirely different histories.
74ca51b21d
...
25a9eed3f0
@ -87,25 +87,18 @@ 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, (I)nfo Panels, (A)ctions, or consider an action (1-%d), or (Q)uit? > ", max)
|
fmt.Printf("Show just (M)essages, (S)tats, (A)ctions, make a choice (1-%d), or (Q)uit? >", max+1)
|
||||||
input := getResponse()
|
input := getResponse()
|
||||||
switch input {
|
switch input {
|
||||||
// Special cases
|
// Special cases
|
||||||
case "m", "msg", "message", "messages":
|
case "m", "msg", "message", "messages":
|
||||||
cls()
|
cls()
|
||||||
if displayMessageSection(p) {
|
displayMessageSection(p)
|
||||||
divider()
|
|
||||||
}
|
|
||||||
displayOnePanel(p, p.Prompt)
|
|
||||||
wait()
|
wait()
|
||||||
case "s", "stat", "stats", "i", "info", "p", "panel", "panels", "infopanel", "infopanels":
|
case "s", "stat", "stats":
|
||||||
statsMode(p)
|
statsMode(p)
|
||||||
case "a", "act", "actions":
|
case "a", "act", "actions":
|
||||||
var committed bool
|
actionsMode(p)
|
||||||
isCard, cardIdx, choiceIdx, committed, err = actionsMode(p)
|
|
||||||
if committed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
case "q", "quit", "exit":
|
case "q", "quit", "exit":
|
||||||
confirmQuit()
|
confirmQuit()
|
||||||
default:
|
default:
|
||||||
@ -113,22 +106,29 @@ func pickNextAction[C StatsCollection](p *Player[C]) (isCard bool, cardIdx int,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Sorry, I don't understand.")
|
fmt.Println("Sorry, I don't understand.")
|
||||||
wait()
|
wait()
|
||||||
} else if i > max {
|
return pickNextAction(p)
|
||||||
fmt.Println("That's not on this menu. If the menu is too big to read, choose a detail view.")
|
}
|
||||||
|
if i > max {
|
||||||
|
fmt.Println("That's not a valid action.")
|
||||||
wait()
|
wait()
|
||||||
} else if i <= actionsOffset {
|
return pickNextAction(p)
|
||||||
|
}
|
||||||
|
i -= 1
|
||||||
|
if i < actionsOffset {
|
||||||
cls()
|
cls()
|
||||||
displayOnePanel(p, p.InfoPanels[i-1])
|
displayOnePanel(p, p.InfoPanels[i])
|
||||||
wait()
|
wait()
|
||||||
} else if i < handOffset {
|
} else if i < handOffset {
|
||||||
i = i - actionsOffset - 1
|
cls()
|
||||||
|
i -= actionsOffset
|
||||||
option, promptErr := promptCard(p, p.PermanentActions[i])
|
option, promptErr := promptCard(p, p.PermanentActions[i])
|
||||||
if option >= 0 || IsSeriousError(promptErr) {
|
if option >= 0 || IsSeriousError(promptErr) {
|
||||||
return false, i, option, promptErr
|
return false, i, option, promptErr
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = i - handOffset - 1
|
cls()
|
||||||
option, promptErr := promptCard(p, p.Hand[i-handOffset-1])
|
i -= handOffset
|
||||||
|
option, promptErr := promptCard(p, p.Hand[i])
|
||||||
if option >= 0 || IsSeriousError(promptErr) {
|
if option >= 0 || IsSeriousError(promptErr) {
|
||||||
return true, i, option, nil
|
return true, i, option, nil
|
||||||
}
|
}
|
||||||
@ -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,95 +314,3 @@ 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.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func actionsMode[C StatsCollection](p *Player[C]) (isCard bool, cardIdx, choiceIdx int, committed bool, err error) {
|
|
||||||
var errs ErrorCollector
|
|
||||||
for {
|
|
||||||
cls()
|
|
||||||
pOff := displayPermanentActionsMenu(p, 0)
|
|
||||||
if pOff > 0 {
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
max := displayHandMenu(p, pOff)
|
|
||||||
|
|
||||||
if max <= 0 {
|
|
||||||
fmt.Println("There are no actions available and no cards in hand.")
|
|
||||||
fmt.Println("That's a problem. The game is stuck.")
|
|
||||||
confirmQuit()
|
|
||||||
errs.Add(WarningStalemate)
|
|
||||||
return false, -1, -1, true, errs.Emit()
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println()
|
|
||||||
fmt.Printf("Go (B)ack, (Q)uit, or consider an action (1-%d)? > ", max)
|
|
||||||
input := getResponse()
|
|
||||||
switch input {
|
|
||||||
case "b", "back":
|
|
||||||
return false, -1, -1, false, errs.Emit()
|
|
||||||
case "q", "quit":
|
|
||||||
confirmQuit()
|
|
||||||
default:
|
|
||||||
v, err := strconv.Atoi(input)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("Sorry, I don't understand.")
|
|
||||||
wait()
|
|
||||||
} else if v < 1 || v > max {
|
|
||||||
fmt.Println("That's not a card or action.")
|
|
||||||
wait()
|
|
||||||
} else if v <= pOff {
|
|
||||||
v--
|
|
||||||
optIdx, err := promptCard(p, p.PermanentActions[v])
|
|
||||||
errs.Add(err)
|
|
||||||
if optIdx >= 0 || IsSeriousError(err) {
|
|
||||||
return false, v, optIdx, true, errs.Emit()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
v = v - pOff - 1
|
|
||||||
optIdx, err := promptCard(p, p.Hand[v])
|
|
||||||
errs.Add(err)
|
|
||||||
if optIdx >= 0 || IsSeriousError(err) {
|
|
||||||
return true, v, optIdx, true, errs.Emit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Re-prompt to get a valid choice.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user