Module:Sandbox/Aurelain/SkillSummary

From Heroes of Might and Magic: Olden Era Official Wiki

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

-- This module is intended as a supporting muscle for the SkillSummary template.
local p = {}
local UtilQuery = require('Module:UtilQuery')

-- Displays a variable
------------------------------------------------------------------------------------------------------------------------
local function dump(target)
    return '<pre>' .. mw.dumpObject(target) .. '</pre>'
end

------------------------------------------------------------------------------------------------------------------------
function p.getCost(frame)
    local id = frame.args.id or ''
    local table = UtilQuery.run([[
        tables =
            Law = L,
            LawLevel = LL
        |join on =
            L.id = LL.law_id
        |where =
            L.id = '%s'
        |fields =
            GROUP_CONCAT(LL.cost SEPARATOR '~') = cost
    ]], id)
    local cost = (table[1] or { cost = '' }).cost
    return cost
end

return p