Compare commits

..

2 Commits

Author SHA1 Message Date
fb5735d5b9
Multiple actions per turn
Allow a pattern of multiple actions per turn. Card options can "refund" an action to the player if they should be free, or zero out the remaining actions if they should force the turn to go directly to the simulation step.
2023-04-01 12:21:42 -07:00
cef0718cba
Cards can be urgent 2023-04-01 12:02:14 -07:00
2 changed files with 21 additions and 9 deletions

View File

@ -9,6 +9,10 @@ type Card[C StatsCollection] interface {
// a warning, the game crashes. // a warning, the game crashes.
Title(p *Player[C]) (Message, error) Title(p *Player[C]) (Message, error)
// Urgent reports whether the card is considered urgent. If
// the player hasa any
Urgent(p *Player[C]) bool
// EventText returns the text to display on the card. If it returns an // EventText returns the text to display on the card. If it returns an
// error that is not a warning, the game crashes. // error that is not a warning, the game crashes.
EventText(p *Player[C]) (Message, error) EventText(p *Player[C]) (Message, error)
@ -43,6 +47,7 @@ type CardOption[C StatsCollection] interface {
// A BasicCard is a Card with fixed title, text, options, and optional post-option callback. // A BasicCard is a Card with fixed title, text, options, and optional post-option callback.
type BasicCard[C StatsCollection] struct { type BasicCard[C StatsCollection] struct {
CardTitle Message CardTitle Message
IsUrgent bool
CardText Message CardText Message
CardOptions []CardOption[C] CardOptions []CardOption[C]
AfterOption func(p *Player[C], option CardOption[C]) error AfterOption func(p *Player[C], option CardOption[C]) error
@ -52,6 +57,10 @@ func (b *BasicCard[C]) Title(p *Player[C]) (Message, error) {
return b.CardTitle, nil return b.CardTitle, nil
} }
func (b *BasicCard[C]) Urgent(_ *Player[C]) bool {
return b.IsUrgent
}
func (b *BasicCard[C]) EventText(p *Player[C]) (Message, error) { func (b *BasicCard[C]) EventText(p *Player[C]) (Message, error) {
return b.CardText, nil return b.CardText, nil
} }

View File

@ -9,6 +9,9 @@ type Player[C StatsCollection] struct {
Deck *Deck[C] Deck *Deck[C]
Hand []Card[C] Hand []Card[C]
HandLimit int HandLimit int
ActionsPerTurn int
ActionsRemaining int
PermanentActions []Card[C]
Rules *RuleCollection[C] Rules *RuleCollection[C]
Rand rand.Rand Rand rand.Rand
Turn int Turn int