From 6eb0cde9c815527db2059a006ec9bbd664b6f65d Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Wed, 6 Aug 2025 09:34:33 +0200 Subject: consider houses when determining damage for a tile --- go/game/attack.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'go/game/attack.go') diff --git a/go/game/attack.go b/go/game/attack.go index e7d2e836..83ea6383 100644 --- a/go/game/attack.go +++ b/go/game/attack.go @@ -22,15 +22,27 @@ func (a Attack) Valid() bool { } // DamageForTile returns the damage inflicted by this attack to a tile -func (a Attack) DamageForTile(u *Unit, t *Tile) (int, bool) { +func (a Attack) DamageForTile(u *Unit, t *Tile) (d int, ok bool) { + o := u.Tile().Position + trgt := t.Position + dist := DistanceBetweenPositions(o, trgt) + if a.flexAttack != nil { - return a.flexAttack(u, t) + d, ok = a.flexAttack(u, t) + } else { + d = a.DamageInRange(dist) + ok = IsPositionInRange(o, trgt, a.MaxRange()) } - o := u.Tile().Position - trgt := t.Position - d := DistanceBetweenPositions(o, trgt) - return a.DamageInRange(d), IsPositionInRange(o, trgt, a.MaxRange()) + if !ok { + return + } + + if dist > 1 && t.Type == TileTypes.House { + return 0, false + } + + return } // MaxRange returns the biggest attackable range. -- cgit v1.2.3