From c6c0d42964c73c6b8eac656c401939a7fef5bbe8 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 22 Jul 2025 18:35:16 -0400 Subject: implement tower tile effect --- go/game/attack.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'go/game/attack.go') diff --git a/go/game/attack.go b/go/game/attack.go index 9be465f2..6b33e8d9 100644 --- a/go/game/attack.go +++ b/go/game/attack.go @@ -32,6 +32,24 @@ func (a Attack) DamageInRange(r int) int { return a.attacks[r-1] } +// Ranged reports if the attack has more range than 1. +func (a Attack) Ranged() bool { + return a.MaxRange() > 1 +} + +// Extend increases the MaxRange by amount. +func (a *Attack) Extend(amount int) { + d := a.DamageInRange(a.MaxRange()) + for range amount { + a.attacks = append(a.attacks, d) + } +} + +// Shorten decreases the MaxRange by amount. +func (a *Attack) Shorten(amount int) { + a.attacks = a.attacks[:len(a.attacks)-amount] +} + func (a Attack) String() string { if INVALID_ATTACK(a) { return "invalid attack" -- cgit v1.2.3