aboutsummaryrefslogtreecommitdiff
path: root/internal/player/player.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/player/player.go')
-rw-r--r--internal/player/player.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/player/player.go b/internal/player/player.go
index d78ae9d..ef3acb3 100644
--- a/internal/player/player.go
+++ b/internal/player/player.go
@@ -184,6 +184,7 @@ type Player struct {
MoveDirection string `yaml:"-"`
MoveTarget int `yaml:"-"`
MovePendingTrigger *behavior.Trigger `yaml:"-"`
+ MoveUsesEnergy bool `yaml:"-"`
VisualTickCurrent int `yaml:"-"`
AutotriggerMod string `yaml:"-"`
QueuedTrigger string `yaml:"-"`
@@ -191,6 +192,8 @@ type Player struct {
HazardTimer int `yaml:"-"`
PendingDangerDir string `yaml:"-"`
Battery float64 `yaml:"battery"`
+ RunEnergy int `yaml:"run_energy,omitempty"`
+ RunEnergyAccum int `yaml:"-"`
ActiveTechs map[string]bool `yaml:"-"`
QuickTech string `yaml:"quick_tech,omitempty"`
TechActivatedSinceTick map[string]bool `yaml:"-"`
@@ -231,6 +234,7 @@ func (p *Player) ClearMoveState() {
p.MoveDirection = ""
p.MoveTarget = 0
p.MovePendingTrigger = nil
+ p.MoveUsesEnergy = false
}
func (p *Player) OptionBool(name string) bool {
@@ -352,6 +356,7 @@ func New(name string) *Player {
p.Skills[Hitpoints] = XPForLevel(10)
p.HP = p.MaxHP()
p.Battery = p.MaxBattery()
+ p.RunEnergy = p.MaxRunEnergy()
return p
}
@@ -467,6 +472,25 @@ func (p *Player) MaxBattery() float64 {
return float64(p.Level(Technology))
}
+// MaxRunEnergy is 3x the player's Agility level (the OSRS-inspired cap).
+func (p *Player) MaxRunEnergy() int {
+ return 3 * p.Level(Agility)
+}
+
+func (p *Player) HasRunEnergy() bool {
+ return p.RunEnergy > 0
+}
+
+// ClampRunEnergy caps current run energy to the player's current maximum.
+// Called whenever the Agility level can change (XP gains) since leveling up
+// raises the cap but should not auto-refill the missing energy.
+func (p *Player) ClampRunEnergy() {
+ max := p.MaxRunEnergy()
+ if p.RunEnergy > max {
+ p.RunEnergy = max
+ }
+}
+
func (p *Player) HasActiveTech(techID string) bool {
if p.ActiveTechs == nil {
return false