diff options
Diffstat (limited to 'go/game/permanent.go')
| -rw-r--r-- | go/game/permanent.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/go/game/permanent.go b/go/game/permanent.go index 76f2325d..19d65bb6 100644 --- a/go/game/permanent.go +++ b/go/game/permanent.go @@ -27,13 +27,17 @@ type Permanent interface { adjustMarks(PermanentMark, int) IsDestroyed() bool - Attackable() bool String() string CurrentlyAvailActions() []Action AvailActions() []Action IsAvailableTile(*Tile) bool + // Attackable reports if a permanent is attackable. + Attackable() bool + // RangeProtected reports if a permanent is attackable in ranged combat. + RangeProtected() bool + fight(p Permanent) adjustDamage(damage int) addTmpEffect(tmpEffect string) @@ -193,6 +197,19 @@ func (p *permanentBase) IsAvailableTile(tile *Tile) bool { return tile.IsAvailableForCard(p.card) } +// Attackable reports if a permanent is attackable. +// Only permanents represented on the map are attackable. +func (p *permanentBase) Attackable() bool { + return p.Tile() != nil +} + +// RangeProtected reports if the permanent is attackable in range combat. +// If the permanent has no Tile then it is not represented on the map and is not attackable at all. +// House tiles protect from ranged combat. +func (p *permanentBase) RangeProtected() bool { + return !p.Attackable() || p.Tile().Type == TileTypes.House +} + func (p *permanentBase) setContainingPerm(containing Permanent) { p.containingPerm = containing } func (p *permanentBase) addPermanentToPile(a Permanent) { p.pile = append(p.pile, a) } func (p *permanentBase) clearPile() { p.pile = nil } |
