aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-04 13:08:55 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:46:39 +0200
commitb1421b58a4fe2c79152026d03e63c8580976b745 (patch)
treefce2b2c65e4081c92b49cb1034d0846aeec9f12a
parent115f826f63be6f87d8b0ccec2d5d5d1623cc83e1 (diff)
downloadmuhqs-game-b1421b58a4fe2c79152026d03e63c8580976b745.tar.gz
muhqs-game-b1421b58a4fe2c79152026d03e63c8580976b745.zip
move unit upkeep code to Unit onUpkeep hook
-rw-r--r--go/game/player.go3
-rw-r--r--go/game/unit.go4
2 files changed, 5 insertions, 2 deletions
diff --git a/go/game/player.go b/go/game/player.go
index 0221eb34..b1cb6916 100644
--- a/go/game/player.go
+++ b/go/game/player.go
@@ -68,8 +68,7 @@ func (p *Player) Upkeep() {
// TODO: let players decide if they want to pay the upkeep
p.Resource -= unit.Upkeep
-
- unit.resetBaseActions()
+ unit.onUpkeep()
}
}
diff --git a/go/game/unit.go b/go/game/unit.go
index c24e3901..fba85f30 100644
--- a/go/game/unit.go
+++ b/go/game/unit.go
@@ -120,6 +120,10 @@ func (u *Unit) resetBaseActions() {
u.AvailAttackActions = DEFAULT_AVAIL_ATTACK_ACTIONS + u.additionalAttackActions
}
+func (u *Unit) onUpkeep() {
+ u.resetBaseActions()
+}
+
func (u *Unit) move(s *State, tile *Tile) {
u.tile.Permanent = nil
tile.Permanent = u