diff options
Diffstat (limited to 'go/game/permanent.go')
| -rw-r--r-- | go/game/permanent.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/go/game/permanent.go b/go/game/permanent.go index b4090592..36c5e1ba 100644 --- a/go/game/permanent.go +++ b/go/game/permanent.go @@ -27,6 +27,10 @@ type Permanent interface { Attackable() bool AvailActions() []Action IsAvailableTile(*Tile) bool + + AddPermanentToPile(p Permanent) + OnPile(containing Permanent) + OnDrop(containing Permanent) } type PermanentBase struct { @@ -40,7 +44,7 @@ type PermanentBase struct { } func NewPermanentBase(card *Card, tile *Tile, owner *Player) PermanentBase { - if tile.Permanent != nil { + if tile != nil && tile.Permanent != nil { log.Fatalf("Tile at %v already occupied by %v", tile.Position, tile.Permanent) } @@ -129,3 +133,14 @@ func (p *PermanentBase) XEffect(effect string) (int, error) { func (p *PermanentBase) IsAvailableTile(tile *Tile) bool { return tile.IsAvailableForCard(p.card) } + +func (p *PermanentBase) AddPermanentToPile(a Permanent) { + p.pile = append(p.pile, a) +} +func (b *PermanentBase) OnPile(p Permanent) { p.Card().Impl.onPile(p) } +func (b *PermanentBase) OnDrop(p Permanent) { p.Card().Impl.onDrop(p) } + +func AddPermanentToPile(containing, p Permanent) { + containing.AddPermanentToPile(p) + p.OnPile(p) +} |
