diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 13:04:13 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-07-24 12:22:10 -0400 |
| commit | 6f20f68f32d0b9b6ed8ba7fd09914602be3e5953 (patch) | |
| tree | 3b916a623d384e3786887ef72a87470766d1823e | |
| parent | fdd7d39e52a772ef4fc328cd3a4d5eda8457f6b4 (diff) | |
| download | muhqs-game-6f20f68f32d0b9b6ed8ba7fd09914602be3e5953.tar.gz muhqs-game-6f20f68f32d0b9b6ed8ba7fd09914602be3e5953.zip | |
do not consider houses as attackable tiles for ranged combat
| -rw-r--r-- | go/game/unit.go | 16 |
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 { |
