diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-22 18:35:16 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:28 +0200 |
| commit | c6c0d42964c73c6b8eac656c401939a7fef5bbe8 (patch) | |
| tree | d58da238be0e9093d3b51e3aeabc2fd7fe815b69 /go/game/attack.go | |
| parent | 2218b9e0029f662aaccf7c16dcab3ba1e91bf4cb (diff) | |
| download | muhqs-game-c6c0d42964c73c6b8eac656c401939a7fef5bbe8.tar.gz muhqs-game-c6c0d42964c73c6b8eac656c401939a7fef5bbe8.zip | |
implement tower tile effect
Diffstat (limited to 'go/game/attack.go')
| -rw-r--r-- | go/game/attack.go | 18 |
1 files changed, 18 insertions, 0 deletions
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" |
