Introduce InfoPanel.

InfoPanels are information displays that do not cost actions. One of them (the Prompt) is shown at the main menu; others can be made available as options in the menu, ether on an ongoing basis or for the current/next turn only.
This commit is contained in:
Kistaro Windrider 2023-04-01 12:30:39 -07:00
parent fb5735d5b9
commit 7f8dcd63d6
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8
2 changed files with 28 additions and 12 deletions

13
cardsim/infopanel.go Normal file
View File

@ -0,0 +1,13 @@
package cardsim
// An InfoPanel displays some set of stats to the player. It does
// not consume an action. It must not advance the state of the game
// in any way.
type InfoPanel[C StatsCollection] interface {
// Title returns the title of this InfoPanel, which is also used as the
// label presented to the player to access this panel.
Title(p *Player[C]) (Message, error)
// Info returns the contents of this InfoPanel.
Info(p *Player[C]) ([]Message, error)
}

View File

@ -12,8 +12,11 @@ type Player[C StatsCollection] struct {
ActionsPerTurn int ActionsPerTurn int
ActionsRemaining int ActionsRemaining int
PermanentActions []Card[C] PermanentActions []Card[C]
InfoPanels []InfoPanel[C]
Prompt InfoPanel[C]
Rules *RuleCollection[C] Rules *RuleCollection[C]
Rand rand.Rand Rand rand.Rand
Turn int Turn int
PendingMessages []Message TemporaryMessages []Message
TemporaryPanels []InfoPanel[C]
} }