From 7f8dcd63d649dbe0b78f514ec10b304d6ae55368 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 1 Apr 2023 12:30:39 -0700 Subject: [PATCH] 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. --- cardsim/infopanel.go | 13 +++++++++++++ cardsim/player.go | 27 +++++++++++++++------------ 2 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 cardsim/infopanel.go diff --git a/cardsim/infopanel.go b/cardsim/infopanel.go new file mode 100644 index 0000000..fdbed04 --- /dev/null +++ b/cardsim/infopanel.go @@ -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) +} diff --git a/cardsim/player.go b/cardsim/player.go index 169c328..0f2316f 100644 --- a/cardsim/player.go +++ b/cardsim/player.go @@ -4,16 +4,19 @@ import "math/rand" // Player stores all gameplay state for one player. type Player[C StatsCollection] struct { - Stats C - Name string - Deck *Deck[C] - Hand []Card[C] - HandLimit int - ActionsPerTurn int - ActionsRemaining int - PermanentActions []Card[C] - Rules *RuleCollection[C] - Rand rand.Rand - Turn int - PendingMessages []Message + Stats C + Name string + Deck *Deck[C] + Hand []Card[C] + HandLimit int + ActionsPerTurn int + ActionsRemaining int + PermanentActions []Card[C] + InfoPanels []InfoPanel[C] + Prompt InfoPanel[C] + Rules *RuleCollection[C] + Rand rand.Rand + Turn int + TemporaryMessages []Message + TemporaryPanels []InfoPanel[C] }