diff options
Diffstat (limited to 'go/game/permanent.go')
| -rw-r--r-- | go/game/permanent.go | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/go/game/permanent.go b/go/game/permanent.go index 37111c4d..7a9988e1 100644 --- a/go/game/permanent.go +++ b/go/game/permanent.go @@ -1,10 +1,66 @@ package game -type Permanent struct { +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 + Pile []Permanent Controller *Player Owner *Player } + +func NewPermanentBase(card *Card, tile *Tile, owner *Player) PermanentBase { + if tile.Permanent != nil { + log.Fatal("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 +} |
