Module:Page/Job/sandbox2

local render_job_icon = require('Module:Render/Job')._icon local model  = require('Module:Data').model local cargo = require('Module:CargoUtil') local enums = require('Module:Data/Enums')

local p = {}

local pageNameByType = function(iname, pageType) if iname == nil then return nil end return 'Data:Game/MasterParam/'..pageType..'/' .. string.gsub(iname, '_', ' ') end

function p.jobSource(iname) local job_data = cargo.query{tables='EventObtainableJob', fields='_pageName', where = 'job_iname="'..iname..'"'} return (job_data[1] and job_data[1]['_pageName']) or nil end

function p.aiPriorityOutput(ai) if ai == nil then return '' end

local enums  = require('Module:Data/Enums')

local renderSkillPriority = function(root, skillKeys) if skillKeys == nil or #skillKeys < 1 then return end

root:tag('h3'):wikitext('Skill Priority') local ol = root:tag('ol') for index, key in ipairs(skillKeys) do           ol:tag('li'):wikitext((enums.SkillCategory[key] or key)) end

root:wikitext("\n\n") end

local renderBuffPriority = function(root, buffKeys, selfOnly) if buffKeys == nil or #buffKeys < 1 then return end

root:tag('h3'):wikitext('Buff Priority') if selfOnly and selfOnly == 1 then root:tag('b'):wikitext("Self Buffs only") root:wikitext("\n\n") end local ol = root:tag('ol') for index, key in ipairs(buffKeys) do           ol:tag('li'):wikitext((enums.statNameFromType(key) or key)) end

root:wikitext("\n\n") end

local renderConditionPriority = function(root, condKeys) if condKeys == nil or #condKeys < 1 then return end

root:tag('h3'):wikitext('Condition Priority') local ol = root:tag('ol') for index, key in ipairs(condKeys) do           ol:tag('li'):wikitext(enums.enchantTypeNameFromKey(key)) end root:wikitext("\n\n") end

local root = mw.html.create root:tag('h2'):wikitext('AI Priority') renderSkillPriority(root, ai.skil_prio) renderBuffPriority(root, ai.skil_prio, ai.buff_self) renderConditionPriority(root, ai.cond_prio) return tostring(root) end

local renderPage = function(iname, frame) local job = model.query("Job", "_pageName, iname, ac2d, mdl, type, wepmdl, master, origin, role, ai, artifact, fixabl, atk, atkskl, avoid, cri, def, dex, hp, inimp, jjmp, jmov, luk, mag, mnd, mp, spd", {where = 'iname="'..iname..'"'}) job = job[1] local getLoc = function(param) return model.getLoc(job._pageName, param) end

local output = {} job.name = getLoc('name') -- If the job inherits from another job, output that information if job.origin and job.origin ~= '' and job.origin ~= job.iname then table.insert(output, job.name..' is a variation of the '..render_job_icon({job.origin, size='small'})..' job.') end -- Output job info box --table.insert(output, p.jobInfoBox(job)) -- Output job mastery bonus if job.master and job.master ~= '' then table.insert(output, '== Job Mastery Bonus ==') table.insert(output, require("Module:JobMaster")._jobMasterBonusTable(iname)) end -- Output attack skill if job.atkskl and job.atkskl ~= '' then local attackSkillPage = pageNameByType(job.atkskl, 'Skill') local attackSkillName = model.getLoc(attackSkillPage, 'name') local attackSkillDesc = model.getLoc(attackSkillPage, 'expr')

table.insert(output, '== Attack ==') table.insert(output, ';'..attackSkillName) table.insert(output, ': '..attackSkillDesc) end -- Job/Page/Abilities table.insert(output, '== Abilities ==') table.insert(output, require("Module:Page/Job/Ability/sandbox").jobAbilityOutput(job)) -- Job/Page/JobUnits table.insert(output, '== Units With This Job ==') table.insert(output, require("Module:JobUnits")._jobUnitList(iname)) -- Job/Page/RelatedJobs table.insert(output, '== Related Jobs ==') table.insert(output, require("Module:JobRelationship")._relatedJobList(iname))

-- Job/Page/Equip table.insert(output, '== Equipment ==') table.insert(output, require("Module:JobEquipmentList/sandbox")._jobEquipmentList(iname)) -- AI   if job.ai and job.ai ~= '' then local ai = model.query("AI", "iname, buff_prio, cond_prio, skil_prio, buff_self", {where = 'iname="'..job.ai..'"'}) or {} if ai and ai[1] then table.insert(output, p.aiPriorityOutput(ai[1])) end end -- Category table.insert(output, '') return table.concat(output, "\n") end

local renderFuncs = {} renderFuncs.Icon = render_job_icon

local renderTransclude = function(iname, args) local type = mw.text.trim(args[1]) args[1] = iname return (renderFuncs[type] or renderFuncs.Name)(args) end

p.renderPage = renderPage

function p._main(iname, args) if args.isPage then return renderPage(iname) else return renderTransclude(iname, args) end end

function p.main(frame) local args = require("Module:Arguments").getArgs(frame) return p._main(args[1], args) end

return p