From 5dae3b7e97669bc6ad5dfc61bbb1903aeb03aaf3 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 8 Feb 2023 12:44:07 +0100 Subject: intermediate commit * detect tokens and do not add them to pile of cards * only add spells not already in exile to their owners discard pile * add the played card to onPlay callback --- go/game/card.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'go/game/card.go') diff --git a/go/game/card.go b/go/game/card.go index c1c74490..a6abffd1 100644 --- a/go/game/card.go +++ b/go/game/card.go @@ -80,7 +80,7 @@ type cardImplementation interface { onEntering(*Tile) onLeaving(*Tile) - onPlay(*State, *Player, *Targets) + onPlay(*State, *Card, *Player, *Targets) onPile(containing Permanent) onUnpile(containing Permanent) onDrop(dropped Permanent) @@ -98,12 +98,12 @@ func (*cardImplementationBase) freeActions(Permanent) []*FreeAction { return nil func (*cardImplementationBase) stateBasedActions(*State, Permanent) {} -func (*cardImplementationBase) onEntering(*Tile) {} -func (*cardImplementationBase) onLeaving(*Tile) {} -func (*cardImplementationBase) onPlay(*State, *Player, *Targets) {} -func (*cardImplementationBase) onPile(Permanent) {} -func (*cardImplementationBase) onUnpile(Permanent) {} -func (*cardImplementationBase) onDrop(Permanent) {} +func (*cardImplementationBase) onEntering(*Tile) {} +func (*cardImplementationBase) onLeaving(*Tile) {} +func (*cardImplementationBase) onPlay(*State, *Card, *Player, *Targets) {} +func (*cardImplementationBase) onPile(Permanent) {} +func (*cardImplementationBase) onUnpile(Permanent) {} +func (*cardImplementationBase) onDrop(Permanent) {} // Map of all card implementations var cardImplementations map[string]cardImplementation @@ -312,6 +312,17 @@ func (c *Card) IsPermanent() bool { c.Type == CardTypes.Potion } +func (c *Card) IsToken() bool { + if v, found := c.Values["token"]; found { + b, ok := v.(bool) + if !ok { + log.Fatalf("Invalid value for %s token value: %v", c.Name, v) + } + return b + } + return false +} + func (c *Card) IsBuyable() bool { return c.BuyCost != NOT_BUYABLE } -- cgit v1.2.3