Fix UI urgency handling.
Only cards can block other cards or actions from being used due to urgency, so only display the `[URGENT!]` header for cards. Debug actions can't be blocked, so skip the "urgency conflict" check for those.
This commit is contained in:
parent
2b788f517c
commit
65c01318f0
@ -149,19 +149,19 @@ func pickNextAction[C StatsCollection](p *Player[C]) (actionType EnactableType,
|
|||||||
wait()
|
wait()
|
||||||
} else if i <= actionsOffset {
|
} else if i <= actionsOffset {
|
||||||
i = i - debugOffset - 1
|
i = i - debugOffset - 1
|
||||||
option, promptErr := promptCard(p, p.DebugActions[i])
|
option, promptErr := promptCard(p, p.DebugActions[i], DebugActionEnactable)
|
||||||
if option >= 0 || IsSeriousError(promptErr) {
|
if option >= 0 || IsSeriousError(promptErr) {
|
||||||
return DebugActionEnactable, i, option, promptErr
|
return DebugActionEnactable, i, option, promptErr
|
||||||
}
|
}
|
||||||
} else if i <= handOffset {
|
} else if i <= handOffset {
|
||||||
i = i - actionsOffset - 1
|
i = i - actionsOffset - 1
|
||||||
option, promptErr := promptCard(p, p.PermanentActions[i])
|
option, promptErr := promptCard(p, p.PermanentActions[i], PermanentActionEnactable)
|
||||||
if option >= 0 || IsSeriousError(promptErr) {
|
if option >= 0 || IsSeriousError(promptErr) {
|
||||||
return PermanentActionEnactable, i, option, promptErr
|
return PermanentActionEnactable, i, option, promptErr
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = i - handOffset - 1
|
i = i - handOffset - 1
|
||||||
option, promptErr := promptCard(p, p.Hand[i])
|
option, promptErr := promptCard(p, p.Hand[i], CardEnactable)
|
||||||
if option >= 0 || IsSeriousError(promptErr) {
|
if option >= 0 || IsSeriousError(promptErr) {
|
||||||
return CardEnactable, i, option, nil
|
return CardEnactable, i, option, nil
|
||||||
}
|
}
|
||||||
@ -281,10 +281,10 @@ func displayNumberedTitles[C StatsCollection, T Titled[C]](p *Player[C], cards [
|
|||||||
|
|
||||||
// promptCard asks the player to take an action on a card. Returns the option
|
// promptCard asks the player to take an action on a card. Returns the option
|
||||||
// they chose, or -1 if there was a serious error or they cancelled selection.
|
// they chose, or -1 if there was a serious error or they cancelled selection.
|
||||||
func promptCard[C StatsCollection](p *Player[C], card Card[C]) (optionIdx int, err error) {
|
func promptCard[C StatsCollection](p *Player[C], card Card[C], cardType EnactableType) (optionIdx int, err error) {
|
||||||
// Iterate until the player makes a valid choice.
|
// Iterate until the player makes a valid choice.
|
||||||
for {
|
for {
|
||||||
opts, valid, err := displayCard(p, card, true)
|
opts, valid, err := displayCard(p, card, cardType, true)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
@ -322,11 +322,11 @@ func promptCard[C StatsCollection](p *Player[C], card Card[C]) (optionIdx int, e
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func displayCard[C StatsCollection](p *Player[C], card Card[C], canAct bool) ([]CardOption[C], bool, error) {
|
func displayCard[C StatsCollection](p *Player[C], card Card[C], cardType EnactableType, canAct bool) ([]CardOption[C], bool, error) {
|
||||||
cls()
|
cls()
|
||||||
t := card.Title(p).String()
|
t := card.Title(p).String()
|
||||||
urgent := card.Urgent(p)
|
urgent := card.Urgent(p)
|
||||||
if urgent {
|
if urgent && cardType == CardEnactable {
|
||||||
t = "[URGENT!] " + t
|
t = "[URGENT!] " + t
|
||||||
}
|
}
|
||||||
fmt.Println(t)
|
fmt.Println(t)
|
||||||
@ -342,7 +342,7 @@ func displayCard[C StatsCollection](p *Player[C], card Card[C], canAct bool) ([]
|
|||||||
fmt.Println()
|
fmt.Println()
|
||||||
fmt.Println(SectionBreak.String())
|
fmt.Println(SectionBreak.String())
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
if !urgent && p.HasUrgentCards() {
|
if !urgent && cardType != DebugActionEnactable && p.HasUrgentCards() {
|
||||||
fmt.Println("<You have more urgent matters to attend to! You cannot act on this right now.>")
|
fmt.Println("<You have more urgent matters to attend to! You cannot act on this right now.>")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
canAct = false
|
canAct = false
|
||||||
@ -457,13 +457,13 @@ func actionsMode[C StatsCollection](p *Player[C], canAct bool) (actionType Enact
|
|||||||
} else if v <= dOff {
|
} else if v <= dOff {
|
||||||
v--
|
v--
|
||||||
if canAct {
|
if canAct {
|
||||||
optIdx, err := promptCard(p, p.DebugActions[v])
|
optIdx, err := promptCard(p, p.DebugActions[v], DebugActionEnactable)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if optIdx >= 0 || IsSeriousError(err) {
|
if optIdx >= 0 || IsSeriousError(err) {
|
||||||
return DebugActionEnactable, v, optIdx, errs.Emit()
|
return DebugActionEnactable, v, optIdx, errs.Emit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, _, err := displayCard(p, p.DebugActions[v], false)
|
_, _, err := displayCard(p, p.DebugActions[v], DebugActionEnactable, false)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return DebugActionEnactable, -1, -1, errs.Emit()
|
return DebugActionEnactable, -1, -1, errs.Emit()
|
||||||
@ -473,13 +473,13 @@ func actionsMode[C StatsCollection](p *Player[C], canAct bool) (actionType Enact
|
|||||||
} else if v <= pOff {
|
} else if v <= pOff {
|
||||||
v = v - dOff - 1
|
v = v - dOff - 1
|
||||||
if canAct {
|
if canAct {
|
||||||
optIdx, err := promptCard(p, p.PermanentActions[v])
|
optIdx, err := promptCard(p, p.PermanentActions[v], PermanentActionEnactable)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if optIdx >= 0 || IsSeriousError(err) {
|
if optIdx >= 0 || IsSeriousError(err) {
|
||||||
return PermanentActionEnactable, v, optIdx, errs.Emit()
|
return PermanentActionEnactable, v, optIdx, errs.Emit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, _, err := displayCard(p, p.PermanentActions[v], false)
|
_, _, err := displayCard(p, p.PermanentActions[v], PermanentActionEnactable, false)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return PermanentActionEnactable, -1, -1, errs.Emit()
|
return PermanentActionEnactable, -1, -1, errs.Emit()
|
||||||
@ -489,13 +489,13 @@ func actionsMode[C StatsCollection](p *Player[C], canAct bool) (actionType Enact
|
|||||||
} else {
|
} else {
|
||||||
v = v - pOff - 1
|
v = v - pOff - 1
|
||||||
if canAct {
|
if canAct {
|
||||||
optIdx, err := promptCard(p, p.Hand[v])
|
optIdx, err := promptCard(p, p.Hand[v], CardEnactable)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if optIdx >= 0 || IsSeriousError(err) {
|
if optIdx >= 0 || IsSeriousError(err) {
|
||||||
return CardEnactable, v, optIdx, errs.Emit()
|
return CardEnactable, v, optIdx, errs.Emit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_, _, err := displayCard(p, p.Hand[v], false)
|
_, _, err := displayCard(p, p.Hand[v], CardEnactable, false)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return CardEnactable, -1, -1, errs.Emit()
|
return CardEnactable, -1, -1, errs.Emit()
|
||||||
@ -552,21 +552,21 @@ func review[C StatsCollection](p *Player[C]) error {
|
|||||||
displayOnePanel(p, p.InfoPanels[i-1])
|
displayOnePanel(p, p.InfoPanels[i-1])
|
||||||
} else if i <= actionsOffset {
|
} else if i <= actionsOffset {
|
||||||
i = i - debugOffset - 1
|
i = i - debugOffset - 1
|
||||||
_, _, err := displayCard(p, p.DebugActions[i], false)
|
_, _, err := displayCard(p, p.DebugActions[i], DebugActionEnactable, false)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return errs.Emit()
|
return errs.Emit()
|
||||||
}
|
}
|
||||||
} else if i <= handOffset {
|
} else if i <= handOffset {
|
||||||
i = i - actionsOffset - 1
|
i = i - actionsOffset - 1
|
||||||
_, _, err := displayCard(p, p.PermanentActions[i], false)
|
_, _, err := displayCard(p, p.PermanentActions[i], PermanentActionEnactable, false)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return errs.Emit()
|
return errs.Emit()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i = i - handOffset - 1
|
i = i - handOffset - 1
|
||||||
_, _, err := displayCard(p, p.Hand[i], false)
|
_, _, err := displayCard(p, p.Hand[i], CardEnactable, false)
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
if IsSeriousError(err) {
|
if IsSeriousError(err) {
|
||||||
return errs.Emit()
|
return errs.Emit()
|
||||||
|
Loading…
Reference in New Issue
Block a user