Implement a very crude "game" as a test. Also updates Player.
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user