diff options
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. |
