Module:Bribes: Difference between revisions

From IdleOn MMO Wiki
mNo edit summary
mNo edit summary
Line 14: Line 14:
</tr>]=]
</tr>]=]


function p.bribez()
function p.bribez(frame)
local Loops = require("Module:Loops")
local Loops = require("Module:Loops")
     local ret = ""
     local ret = ""

Revision as of 21:10, 8 March 2024

hewwo


local data = mw.loadJsonData('Module:Bribes/data.json')
local p = {}

local ROW_TEMPLATE = [=[<tr>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>]=]

local ROW_TEMPLATE_EXPANSION = [=[<tr>
<th>%s</th>
<th>%s</th>
<th>%s</th>
</tr>]=]

function p.bribez(frame)
	local Loops = require("Module:Loops")
    local ret = ""

    for _, bribe in ipairs(data) do
        local name = bribe.name
        local desc = bribe.desc
        local cost = bribe.cost
        cost = Loops.coinDisplay({ args = { coins = cost } })
        local intName = bribe.intName
        if intName == "BribeExpansion" then
            ret = ret .. string.format(
                ROW_TEMPLATE_EXPANSION,
                name,
                desc,
                cost
            )
        else
            ret = ret .. string.format(
                ROW_TEMPLATE,
                name,
                desc,
                cost
            )
        end
    end
    return ret
end
return p