Implement a very crude "game" as a test. Also updates Player.

This commit is contained in:
2023-04-02 19:01:40 -07:00
parent 2875dc5af8
commit 2480a1631b
6 changed files with 308 additions and 14 deletions

View File

@ -49,7 +49,8 @@ type CardOption[C StatsCollection] interface {
// a warning, the game crashes.
//
// After an option is enacted, the card is deleted. If a card should be
// repeatable, Enact must return it to the deck (on every option).
// repeatable, Enact must return it to the deck (on every option) or
// the card needs to reinsert itself with its Then function.
Enact(p *Player[C]) (Message, error)
// Enabled returns whether this option can curently be enacted.
@ -63,7 +64,8 @@ type BasicCard[C StatsCollection] struct {
IsUrgent bool
CardText Message
CardOptions []CardOption[C]
AfterOption func(p *Player[C], option CardOption[C]) error
// AfterOption is given the card itself as its first argument.
AfterOption func(c Card[C], p *Player[C], option CardOption[C]) error
}
// Title implements Card.
@ -91,7 +93,7 @@ func (b *BasicCard[C]) Then(p *Player[C], option CardOption[C]) error {
if b.AfterOption == nil {
return nil
}
return b.AfterOption(p, option)
return b.AfterOption(b, p, option)
}
// Drawn implements Card.