package game import ( "fmt" "log" ) type Permanent interface { GetCard() *Card GetTile() *Tile GetDamage() int GetPile() []Permanent GetController() *Player GetOwner() *Player String() string Fight(p Permanent) AddDamage(damage int) IsDestroyed() bool Attackable() bool GetAvailActionPrototypes() []ActionPrototype } type PermanentBase struct { Card *Card Tile *Tile Damage int Pile []Permanent Controller *Player Owner *Player } func NewPermanentBase(card *Card, tile *Tile, owner *Player) PermanentBase { if tile.Permanent != nil { log.Fatalf("Tile at %v already occupied by %v", tile.Position, tile.Permanent) } return PermanentBase{card, tile, 0, []Permanent{}, owner, owner} } func (p *PermanentBase) GetCard() *Card { return p.Card } func (p *PermanentBase) GetTile() *Tile { return p.Tile } func (p *PermanentBase) GetDamage() int { return p.Damage } func (p *PermanentBase) GetPile() []Permanent { return p.Pile } func (p *PermanentBase) GetController() *Player { return p.Controller } func (p *PermanentBase) GetOwner() *Player { return p.Owner } func (p *PermanentBase) String() string { return fmt.Sprintf("%s's %s@%s", p.GetController().Name, p.GetCard().Name, p.GetTile().Position.String()) } func (p *PermanentBase) AddDamage(damage int) { p.Damage += damage }