move meter to system (temporary)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-03-03 20:05:49 +01:00
parent 03b6567c08
commit c39e0ece35
5 changed files with 24 additions and 21 deletions

View File

@@ -42,7 +42,7 @@ Screen.register({
local m = Context.meters
local max_val = Meter.get_max()
local decay_pct = Timer.get_decay_percentage()
local decay_pct = Meter.get_decay_percentage()
local decay_text = string.format("-%d%%", decay_pct)
local combo_mult = Meter.get_combo_multiplier()
local combo_pct = math.floor((combo_mult - 1) * 100)

View File

@@ -9,3 +9,10 @@ end
function Day.register_handler(handler)
table.insert(_day_increase_handlers, handler)
end
Day.register_handler(function()
local m = Context.meters
m.ism = math.max(0, m.ism - METER_DECAY_PER_DAY)
m.wpm = math.max(0, m.wpm - METER_DECAY_PER_DAY)
m.bm = math.max(0, m.bm - METER_DECAY_PER_DAY)
end)

View File

@@ -2,6 +2,7 @@
local METER_MAX = 1000
local METER_DEFAULT = 500
local METER_GAIN_PER_CHORE = 100
local METER_DECAY_PER_DAY = 20
local COMBO_BASE_BONUS = 0.02
local COMBO_MAX_BONUS = 0.16
local COMBO_TIMEOUT_FRAMES = 600
@@ -52,6 +53,20 @@ function Meter.get_max()
return METER_MAX
end
--- Sets the decay amount applied to all meters per day.
--- @within Meter
--- @param amount number Amount to subtract from each meter.
function Meter.set_decay(amount)
METER_DECAY_PER_DAY = amount
end
--- Gets the meter decay as a percentage of the max meter value.
--- @within Meter
--- @return number The decay percentage per day.
function Meter.get_decay_percentage()
return math.floor(METER_DECAY_PER_DAY / METER_MAX * 100)
end
--- Gets combo multiplier.
--- @within Meter
--- @return number The current combo multiplier.

View File

@@ -1,7 +1,6 @@
--- @section Timer
local timer_duration = 1800
local timer_decay_per_revolution = 20
--- Gets initial timer values.
--- @within Timer
@@ -21,25 +20,10 @@ function Timer.set_duration(frames)
timer_duration = frames
end
--- Sets the decay amount applied to all meters per revolution.
--- @within Timer
--- @param amount number Amount to subtract from each meter.
function Timer.set_decay(amount)
timer_decay_per_revolution = amount
end
--- Gets the timer decay as a percentage of the max meter value.
--- @within Timer
--- @return number The decay percentage per revolution.
function Timer.get_decay_percentage()
return math.floor(timer_decay_per_revolution / Meter.get_max() * 100)
end
--- Updates the timer and handles revolution events.
--- @within Timer
function Timer.update()
if not Context or not Context.game_in_progress or not Context.meters or not Context.timer then return end
local m = Context.meters
local t = Context.timer
local in_minigame = string.find(Window.get_current_id(), "^minigame_") ~= nil
@@ -48,9 +32,6 @@ function Timer.update()
if t.progress >= 1 then
Day.increase()
t.progress = t.progress - 1
m.ism = math.max(0, m.ism - timer_decay_per_revolution)
m.wpm = math.max(0, m.wpm - timer_decay_per_revolution)
m.bm = math.max(0, m.bm - timer_decay_per_revolution)
end
end
end