Module:Sandbox/LVL

From The Deadlock Wiki
Revision as of 18:21, 16 November 2025 by LVL (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Sandbox/LVL/doc

-- Module:Souls
-- Handles calculations related to Sinner's Sacrifice rewards.

local p = {}

-- CONFIGURATION
-- IMPORTANT: These values are taken from the NpcData templates. If the game is patched,
-- update these numbers here to update the calculator everywhere it's used.
local baseValue = 164 -- Corresponds to NpcData|neutral_sinners_sacrifice|GoldReward
local bonusPercent = 1.08 -- Corresponds to NpcData|neutral_sinners_sacrifice|GoldRewardBonusPercentPerMinute

-- This is the main calculation function called from wikitext.
function p.calculate(frame)
    -- Get the 'time' argument passed from the template.
    local timeArg = frame.args.time
    if not timeArg or timeArg == '' then
        return '<span class="error">Error: No time specified.</span>'
    end

    local time = tonumber(timeArg)
    if not time or time < 0 then
        return '<span class="error">Error: Invalid time. Please enter a positive number.</span>'
    end

    -- The calculation formula from the article.
    local totalValue = math.floor((baseValue + (baseValue * (bonusPercent / 100) * time)) * 2)

    -- Return the formatted result.
    -- We are manually adding the soul icon formatting here.
    return '[[File:Souls Icon.png|16x16px|Souls]] ' .. totalValue
end

return p