Type the player bonus element data and config

`data` on an element is the GuiData store keyed by element, not the
value being stored.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-07 15:31:18 +00:00
co-authored by Claude Opus 5
parent 8ae1144585
commit fd2f5a9589
+6 -3
View File
@@ -22,13 +22,16 @@ local Elements = {}
--- @field _cost_scale number --- @field _cost_scale number
--- For perf calculate the division of scale against cost ahead of time --- For perf calculate the division of scale against cost ahead of time
for _, bonus_data in pairs(config.player_bonus) do --- @type table<string, ExpGui_PlayerBonus.bonus_data>
local player_bonus = config.player_bonus
for _, bonus_data in pairs(player_bonus) do
bonus_data._cost_scale = bonus_data.cost / bonus_data.scale bonus_data._cost_scale = bonus_data.cost / bonus_data.scale
end end
--- Progress bar which displays how much of a bonus has been used --- Progress bar which displays how much of a bonus has been used
--- @class ExpGui_PlayerBonus.elements.bonus_used: ExpElement --- @class ExpGui_PlayerBonus.elements.bonus_used: ExpElement
--- @field data number --- @field data table<LuaGuiElement, number>
--- @overload fun(parent: LuaGuiElement): LuaGuiElement --- @overload fun(parent: LuaGuiElement): LuaGuiElement
Elements.bonus_used = Gui.define("player_bonus/bonus_used") Elements.bonus_used = Gui.define("player_bonus/bonus_used")
:track_all_elements() :track_all_elements()
@@ -441,7 +444,7 @@ end
function Elements.container.calculate_cost(player) function Elements.container.calculate_cost(player)
local cost = 0 local cost = 0
local player_data = Elements.container.data[player] local player_data = Elements.container.data[player]
for _, bonus_data in pairs(config.player_bonus) do for _, bonus_data in pairs(player_bonus) do
cost = cost + (player_data[bonus_data.name] or 0) * bonus_data._cost_scale cost = cost + (player_data[bonus_data.name] or 0) * bonus_data._cost_scale
end end
return cost return cost