diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-08-06 09:34:33 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:34 +0200 |
| commit | 6eb0cde9c815527db2059a006ec9bbd664b6f65d (patch) | |
| tree | 18ef881ee8ef07713421c53d319780494f2e4124 /go/game/attack.go | |
| parent | deee4b76b6ab1a94e5578818aba4b94e22e6ac89 (diff) | |
| download | muhqs-game-6eb0cde9c815527db2059a006ec9bbd664b6f65d.tar.gz muhqs-game-6eb0cde9c815527db2059a006ec9bbd664b6f65d.zip | |
consider houses when determining damage for a tile
Diffstat (limited to 'go/game/attack.go')
| -rw-r--r-- | go/game/attack.go | 24 |
1 files changed, 18 insertions, 6 deletions
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. |
