Module:Page/Job/Ability/sandbox

local model  = require('Module:Data').model local cargo = require('Module:CargoUtil') local enums = require('Module:Data/Enums') local skillList = require('Module:AbilitySkill2/sandbox')

local p = {}

local abilityBackground = { [0] = '#ef4401', [1] = '#64d818', [2] = '#9939f9' }

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

function p.castTime(job) cast = false if job.fixabl and job.fixabl ~= '' then cast = skillList.castTime(job.fixabl) or cast end local rows = cargo.query{ tables = 'JobRank', fields = 'idx, eqid1, eqid2, eqid3, eqid4, eqid5, eqid6, learn1, learn2', where = 'job_iname = "'..job.iname..'" and server = "gl"', }   for level, equipData in ipairs(rows) do        if equipData.learn1 and equipData.learn1 ~= '' then cast = skillList.castTime(equipData.learn1) or cast end end return cast end

function p.jobAbilityOutput(job) local abilityOutput = { '{| class="wikitable" style="width:calc(100% - 20px); background-color:#e0e0e0',   }    cast = p.castTime(job)    if job.fixabl and job.fixabl ~=  then    	local ability = cargo.query{    		tables = 'Ability, AbilityLoc',    		join = 'Ability.iname = AbilityLoc.iname',    		fields = 'name, expr',    		where = {    			'Ability.iname = "'..job.fixabl..'"',    			'server = "gl"',    			'lang="english"'    		}    	}[1]    	if ability then	        -- Main ability row	        table.insert(abilityOutput, '|-')	        table.insert(abilityOutput, '| colspan="5" style="background-color:#ef4401; text-align:center"|   '..(ability.name or )..'  '..(ability.expr or ''))	        table.insert(abilityOutput, '|- style="font-weight:bolder"')	        table.insert(abilityOutput, skillList._AbilitySkillList(job.fixabl, cast))	    end    end

-- Other rows (sub ability, reaction and support) local rows = cargo.query{ tables = 'JobRank', fields = 'idx, eqid1, eqid2, eqid3, eqid4, eqid5, eqid6, learn1, learn2', where = 'job_iname = "'..job.iname..'" and server = "gl"', }

for level, equipData in ipairs(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') local abilitySlot = model.query("Ability", {'_pageName', 'slot'}, {where = 'iname="'..equipData.learn1..'" and server = "gl"'})[1]['slot'] AbilityType = enums.EAbilitySlot[abilitySlot] table.insert(abilityOutput, '|-') -- Add the level in parentheses if level>2 if level > 2 then table.insert(abilityOutput, '| colspan="5" style="background-color:'..abilityBackground[abilitySlot]..'; text-align:center"| '..abilityName..'  '..abilityDesc..' (Learned at job rank '..(level-1)..')') else table.insert(abilityOutput, '| colspan="5" style="background-color:'..abilityBackground[abilitySlot]..'; text-align:center"| '..abilityName..'  '..abilityDesc) end

table.insert(abilityOutput, skillList._AbilitySkillList(equipData.learn1, cast)) end end table.insert(abilityOutput, '|}') return table.concat(abilityOutput, "\n") end

function p.test(frame) local args = require("Module:Arguments").getArgs(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="'..args[1]..'"'}) job = job[1] return p.jobAbilityOutput(job) end

return p