aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-22 13:04:13 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-07-24 12:22:10 -0400
commit6f20f68f32d0b9b6ed8ba7fd09914602be3e5953 (patch)
tree3b916a623d384e3786887ef72a87470766d1823e
parentfdd7d39e52a772ef4fc328cd3a4d5eda8457f6b4 (diff)
downloadmuhqs-game-6f20f68f32d0b9b6ed8ba7fd09914602be3e5953.tar.gz
muhqs-game-6f20f68f32d0b9b6ed8ba7fd09914602be3e5953.zip
do not consider houses as attackable tiles for ranged combat
-rw-r--r--go/game/unit.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/go/game/unit.go b/go/game/unit.go
index 85c6b97c..c7528224 100644
--- a/go/game/unit.go
+++ b/go/game/unit.go
@@ -117,7 +117,21 @@ func (u *Unit) AttackableTiles(m *Map) []*Tile {
if u.tile == nil {
return nil
}
- return TilesInRange(m, u, u.Attack.MaxRange())
+
+ tilesInRange := TilesInRange(m, u, u.Attack.MaxRange())
+ if u.Attack.MaxRange() == 1 {
+ return tilesInRange
+ }
+
+ // House tiles are not attackable from $anges > 1
+ aTiles := []*Tile{}
+ for _, t := range tilesInRange {
+ if DistanceBetweenPositions(t.Position, u.tile.Position) > 1 && t.Type == TileTypes.House {
+ continue
+ }
+ aTiles = append(aTiles, t)
+ }
+ return aTiles
}
func (u *Unit) AttackablePermanents(m *Map) []Permanent {