From 7f4ba6774db54e8bb427024dca05c7c16efa7039 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 22 Jul 2025 11:09:44 -0400 Subject: implement house tile effect --- go/game/permanent.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'go/game/permanent.go') 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 } -- cgit v1.2.3