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/state.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'go/game/state.go') diff --git a/go/game/state.go b/go/game/state.go index d5a9bfc6..16670263 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -644,11 +644,25 @@ func (s *LocalState) destroyPermanent(p Permanent) { s.events = append(s.events, Event{eventType: EventTypes.Destruction, affected: []any{p}}) } +// fight implements the effect of two permanents fighting. func (s *LocalState) fight(p1, p2 Permanent) { p1.fight(p2) p2.fight(p1) } +// attack implements the effects of a permanent p1 attacking another permanent p2. +func (s *LocalState) attack(p1, p2 Permanent) { + if p1 == p2 { + log.Panic("A unit can not attack itself") + } + d := DistanceBetweenPermanents(p1, p2) + if d > 1 && p2.RangeProtected() { + log.Panic("Range protected unit can only be attacked in melee combat") + } + + s.fight(p1, p2) +} + func (s *LocalState) switchPermanents(p1 Permanent, p2 Permanent) { t1 := TileOrContainingPermTile(p1) t2 := TileOrContainingPermTile(p2) -- cgit v1.2.3