Module:JobPageContent

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

local jobMaster = require("Module:JobMaster") local abilitySkill = require("Module:AbilitySkill") local jobUnits = require("Module:JobUnits") local jobRelationship = require("Module:JobRelationship") local jobEquip = require("Module:JobEquipmentList")

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

local p = {}

local getArgs = require("Module:Arguments").getArgs

function p.jobInfoBox(job) local output = { '{| class="wikitable jobInfoBox" style="float:right; margin-left: 15px;margin-bottom:0;"', '| style="padding:0;width:128px;white-space: nowrap" | '..render_job_icon({job.iname, data=job, size='large', name='none'}), '! style="padding:12px;font-size:140%;" | '..job.name..' Job ', '|-',       '| colspan="2" style="padding:0" |', '{| class="wikitable jobInfoBoxInner" style="margin: 0; width: 100%"', '|-',       '| Move', '| '..job.jmov or 0, '| Jump', '| '..job.jjmp or 0, '|-',       '| Avoid', '| '..job.avoid or 0, '| Initial Jewels', '| '..(100 + (job.inimp or 0))..'%', '|-',       '| HP', '| '..job.hp or 0, '| Jewels', '| '..job.mp or 0, '|-',       '| PATK', '|'..job.atk or 0, '| PDEF', '|'..job.def or 0, '|-',       '| MATK', '| '..job.mag or 0, '| MDEF', '| '..job.mnd or 0, '|-',       '| DEX', '| '..job.dex or 0, '| AGI', '| '..job.spd or 0, '|-',       '| CRIT', '| '..job.cri or 0, '| LUCK', '| '..job.luk or 0, '|}',       '|}',    }    return table.concat(output, "\n") end

function p.jobAbilityOutput(job) local abilityOutput = {} if job.fixabl and job.fixabl ~= '' then local abilityPageName = pageNameByType(job.fixabl, 'Ability') local abilityName = model.getLoc(abilityPageName, 'name') local abilityDesc = model.getLoc(abilityPageName, 'expr') table.insert(abilityOutput, '=='..abilityName..'==') table.insert(abilityOutput, abilityDesc) table.insert(abilityOutput, abilitySkill._AbilitySkillList(job.fixabl)) end -- local jobEquipList = mw.loadData("Module:Data/MasterParam/JobEquip") local rows = cargo.query{ tables = 'JobRank', fields = 'idx, eqid1, eqid2, eqid3, eqid4, eqid5, eqid6, learn1, learn2', where = 'job_iname = "'..job.iname..'" and server = "gl"', }   -- if jobEquipList[job.iname] then for level,equipData in pairs(rows) do           if equipData.learn1 and equipData.learn1 ~= '' then local abilityPageName = pageNameByType(equipData.learn1, 'Ability') local abilityName = model.getLoc(abilityPageName, 'name') local abilityDesc = model.getLoc(abilityPageName, 'expr') table.insert(abilityOutput, '=='..abilityName..'==') table.insert(abilityOutput, abilityDesc)

if level > 2 then table.insert(abilityOutput, '; Learned at Rank '..(level - 1)) end

table.insert(abilityOutput, abilitySkill._AbilitySkillList(equipData.learn1)) end end -- end return table.concat(abilityOutput, "\n") end

function p.renderPage(frame) local args = getArgs(frame, {       parentFirst = true,    }) local iname = args[1] return p._renderPage(iname) end function p._renderPage(iname) local jobs = 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..'"'}) local job = jobs[1] if job == nil then return '`'..iname..'` not found in Job table.' end 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=') -- TODO: Make input consistent (i.e. no need for fallback) so that we don't have to pass in table. table.insert(output, 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, p.jobAbilityOutput(job)) -- Job/Page/JobUnits table.insert(output, '=Units With This Job=') table.insert(output, jobUnits._jobUnitList(iname)) -- Job/Page/RelatedJobs table.insert(output, '=Related Jobs=') table.insert(output, jobRelationship._relatedJobList(iname))

-- Job/Page/Equip table.insert(output, '=Equipment=') table.insert(output, jobEquip._jobEquipmentList(iname)) -- Category table.insert(output, '') return table.concat(output, "\n") end

return p