Module:AbilitySkill2/sandbox

local p = {}

require("Module:Database") local model = require("Module:Data").model

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

function p.AbilitySkillList(frame) local iname = frame.args[1] local cast = frame.args[2] return p._AbilitySkillList(iname, cast) end

function p._AbilitySkillList(iname, cast) if iname == nil then return 'Invalid parameter' end

local fieldList = {'_pageName, slot'} local maxSkill = 10 local skillList = {} for i=1,maxSkill do       table.insert(fieldList, "skl"..i)        table.insert(fieldList, "lv"..i)    end local ability = model.query("Ability", fieldList, {where = 'iname="'..iname..'" and server = "gl"'})[1] or {} if tonumber(ability.slot) == 0 then -- if it is an action ability table.insert(skillList, '|-') if cast then table.insert(skillList, '| Skill Name || Description || Charges || Jewel Cost || Cast Time') else table.insert(skillList, '| Skill Name || Description || Charges || Jewel Cost') end for i=1, maxSkill do   		local skillKey = 'skl'..i    		local lvlKey = 'lv'..i            if ability[lvlKey] ~= nil and ability[skillKey] ~= nil then local skill = model.query("Skill", "_pageName,cost,count,ct_spd_max", {where = 'iname="'..ability[skillKey]..'" and server = "gl"'})[1] or {}

local skillName = model.getLoc(skill._pageName, 'name') table.insert(skillList, '|-') table.insert(skillList, '|'..skillName) local skillExpr = model.getLoc(skill._pageName, 'expr') if ability[lvlKey] > 1 then table.insert(skillList,'|'..skillExpr.." (Learned at ability Lv"..ability[lvlKey]..")") else table.insert(skillList,'|'..skillExpr) end if skill.cost or skill.count then table.insert(skillList, '| style="text-align:center" |'..(skill.count or '–')) table.insert(skillList, '| style="text-align:center" |'..(skill.cost or '–')) if cast then table.insert(skillList, '| style="text-align:center" |'..(skill.ct_spd_max or '–')) end end end end else -- if it is a reaction or a support ability if ability['lv1'] and ability['skl1'] then local skill = model.query("Skill", "_pageName", {where = 'iname="'..ability['skl1']..'" and server = "gl"'})[1] or {} skillExpr = model.getLoc(skill._pageName, 'expr') table.insert(skillList, '|-') table.insert(skillList, '| colspan="5" |'..skillExpr) end end return table.concat(skillList, "\n") end

function p.castTime(iname) local fieldList = {'_pageName, slot'} local maxSkill = 10 local skillList = {} local cast = false for i=1,maxSkill do       table.insert(fieldList, "skl"..i)        table.insert(fieldList, "lv"..i)    end local ability = model.query("Ability", fieldList, {where = 'iname="'..iname..'" and server = "gl"'})[1] or {} for i=1,maxSkill do   	local skillKey = 'skl'..i    	if ability[skillKey] then local castTime = model.query("Skill", 'ct_spd_max', {where = 'iname="'..ability[skillKey]..'" and server = "gl"'})[1] if castTime.ct_spd_max and castTime.ct_spd_max ~= 0 then cast = true end end end return cast end

return p