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-08-20 15:57:28 +0200
commitca5c42546e00f92d502a59202f1975b1a2f95bbd (patch)
tree44b559a0de35059aa161b05fff1b08293334a54b
parent90527eda5adb0d0c2970731af51bb61def7a6ed8 (diff)
downloadmuhqs-game-ca5c42546e00f92d502a59202f1975b1a2f95bbd.tar.gz
muhqs-game-ca5c42546e00f92d502a59202f1975b1a2f95bbd.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 {