diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 11:09:44 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 12:54:28 -0400 |
| commit | 7f4ba6774db54e8bb427024dca05c7c16efa7039 (patch) | |
| tree | 81db9aae21b6d410f32ff8947800593afd4fd38c /go/game/state.go | |
| parent | eb2fc0af7db8614024f6d73093ccb0825c8a1cc0 (diff) | |
| download | muhqs-game-7f4ba6774db54e8bb427024dca05c7c16efa7039.tar.gz muhqs-game-7f4ba6774db54e8bb427024dca05c7c16efa7039.zip | |
implement house tile effect
Diffstat (limited to 'go/game/state.go')
| -rw-r--r-- | go/game/state.go | 14 |
1 files changed, 14 insertions, 0 deletions
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) |
