aboutsummaryrefslogtreecommitdiff
path: root/internal/game/sys_energy.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/sys_energy.go')
-rw-r--r--internal/game/sys_energy.go28
1 files changed, 12 insertions, 16 deletions
diff --git a/internal/game/sys_energy.go b/internal/game/sys_energy.go
index 7331fa8..1144793 100644
--- a/internal/game/sys_energy.go
+++ b/internal/game/sys_energy.go
@@ -41,38 +41,34 @@ func hasCapeOfAgility(p *player.Player) bool {
return ok && id == capeOfAgilityID
}
-// moveTicks returns how many ticks the upcoming move will take, and sets
-// p.MoveUsesEnergy to indicate whether completing the move should drain one
-// point of run energy.
+// moveTicks returns how many ticks the upcoming move will take and whether
+// completing the move should drain one point of run energy.
//
// - GodMode and Cape of Agility: instant (0 ticks), never drains energy.
// - A single move (north/e/w...): 1 tick if energy remains, otherwise 2.
// - The "walk" command: 2 ticks per step and never drains energy unless the
// player wears the complete Graceful outfit (or Cape of Agility), in which
// case it behaves like a single run move (1 tick with energy, 2 without).
-func (g *Game) moveTicks(p *player.Player, isWalk bool) int {
+//
+// The caller is responsible for storing the returned usesEnergy flag into
+// p.MoveUsesEnergy only when a move is genuinely about to enter flight — never
+// while a move is merely being stashed as a pending flee.
+func (g *Game) moveTicks(p *player.Player, isWalk bool) (int, bool) {
if p.GodMode {
- p.MoveUsesEnergy = false
- return 0
+ return 0, false
}
if hasCapeOfAgility(p) {
- p.MoveUsesEnergy = false
- return 0
+ return 0, false
}
if isWalk && gracefulCount(p) != 6 {
- // Plain walk: slow, no energy cost.
- p.MoveUsesEnergy = false
- return 2
+ return 2, false
}
- // Single move, or a run-walk enabled by the full Graceful set.
if p.HasRunEnergy() {
- p.MoveUsesEnergy = true
- return 1
+ return 1, true
}
- p.MoveUsesEnergy = false
- return 2
+ return 2, false
}
// isPlayerBusy reports whether the player is currently performing an action