Module:Pantheon

-- -- Module for bestiary templates --

local m_cargo = require('Module:Cargo') local m_util = require('Module:Util') local getArgs = require('Module:Arguments').getArgs

local p = {}

-- -- Strings --

local i18n = { strings = { icon = 'Icon', name = 'Name', effect = 'Effect(s)', upgrade = 'Upgrade', capture = string.format('Capture %%s in %%s Map %s', m_util.html.poe_color('mod', '%s')), }, }

-- -- Helper functions and globals --

-- -- Cargo tables --

-- references are PantheonPanelLayout and PantheonSouls local tables = {}

tables.pantheon = { table = 'pantheon', order = {'id', 'is_major_god'}, fields = { id = { field = 'id', type = 'String', },       is_major_god = { field = 'is_major_god', type = 'Boolean', },   }, }

tables.pantheon_souls = { table = 'pantheon_souls', order = {'id', 'order', 'name', 'stat_text', 'target_area_id', 'target_monster_id', 'item_id'}, fields = { id = { field = 'id', type = 'String', },       ordinal = { field = 'ordinal', type = 'Integer', },       name = { field = 'name', type = 'String', },       stat_text = { field = 'stat_text', type = 'String', },       target_area_id = { field = 'target_area_id', type = 'String', },       target_monster_id = { field = 'target_monster_id', type = 'String', },       item_id = { field = 'item_id', type = 'String', },   }, }

tables.pantheon_stats = { table = 'pantheon_stats', order = {'pantheon_id', 'pantheon_order', 'ordinal', 'id', 'value'}, fields = { pantheon_id = { field = 'pantheon_id', type = 'String', },       pantheon_ordinal = { field = 'pantheon_ordinal', type = 'Integer', },       ordinal = { field = 'ordinal', type = 'Integer', },       id = { field = 'id', type = 'String', },       value = { field = 'value', type = 'Integer', },   } }

-- -- Page functions --

local p = {}

p.table_pantheon = m_cargo.declare_factory{data=tables.pantheon} p.table_pantheon_souls = m_cargo.declare_factory{data=tables.pantheon_souls} p.table_pantheon_stats = m_cargo.declare_factory{data=tables.pantheon_stats}

p.store_data = m_cargo.store_from_lua{tables=tables, module='Pantheon'}

function p.pantheon_table(frame) -- Get args tpl_args = getArgs(frame, {       parentFirst = true    }) frame = m_util.misc.get_frame(frame) local results = m_cargo.map_results_to_id{ results=m_cargo.query(           {'pantheon', 'pantheon_souls', 'areas'},            {                'pantheon.id',                 'pantheon_souls.name',                'pantheon_souls.ordinal',                'pantheon_souls.stat_text',                'pantheon_souls.target_area_id',                 'areas.name',            },            {                join='pantheon.id=pantheon_souls.id, pantheon_souls.target_area_id=areas.id',                where=tpl_args.q_where,                groupBy='pantheon_souls.name',                orderBy='pantheon_souls.id, pantheon_souls.ordinal',            }        ), field='pantheon.id', }   local tbl = mw.html.create('table') tbl :attr('class', 'wikitable') :tag('tr') :tag('th') :wikitext(i18n.strings.icon) :done :tag('th') :wikitext(i18n.strings.name) :done :tag('th') :wikitext(i18n.strings.effect) :done :tag('th') :wikitext(i18n.strings.upgrade) :done for _, rows in pairs(results) do       local subtbl = mw.html.create('table') subtbl :attr('class', 'wikitable') :attr('style', 'width:100%;height:100%;margin:0;') for i=2, #rows do           local row = rows[i] subtbl :tag('tr') :tag('td') :wikitext(string.format(i18n.strings.capture, row['pantheon_souls.name'], row['areas.name'], row['pantheon_souls.stat_text'])) :done end local row = rows[1] tbl :tag('tr') :tag('td') :wikitext( '' ) :done :tag('td') :wikitext(  .. row['pantheon_souls.name'] ..  ) :done :tag('td') :attr('class', 'tc -mod') :wikitext(row['pantheon_souls.stat_text']) :done :tag('td') :attr('style', 'padding:0;') :wikitext(tostring(subtbl)) end return tostring(tbl) end

-- -- End --

return p