Module:AbilitySkill2

local p = {}

require("Module:Database") local dataModel = 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] return p._AbilitySkillList(iname) end

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

local fieldList = {'_pageName'} local maxSkill = 10 local skillList = {} for i=1,maxSkill do       table.insert(fieldList, "skl"..i)        table.insert(fieldList, "lv"..i)    end

local ability = dataModel.query("Ability", fieldList, {where = 'iname="'..iname..'" and server = "gl"'})[1] or {} for i=1,maxSkill do       local skillKey = 'skl'..i        local lvlKey = 'lv'..i        if ability[lvlKey] == nil then -- mw.log(lvlKey..' is nil') elseif ability[skillKey] == nil then -- mw.log(skillKey..' is nil') else -- mw.log('Lvl '..ability[lvlKey]..', Skill: '..ability[skillKey]) local skill = dataModel.query("Skill", "_pageName,cost,count,ct_spd_max", {where = 'iname="'..ability[skillKey]..'" and server = "gl"'})[1] or {} -- mw.logObject(skill)

local skillName = dataModel.getLoc(skill._pageName, 'name') table.insert(skillList, '|-') table.insert(skillList, '|'..skillName) local skillExpr = dataModel.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, '|'..(skill.count or 0)) table.insert(skillList, '|'..(skill.cost or 0)) if skill.ct_spd_max and skill.ct_spd_max > 0 then table.insert(skillList, '|'..skill.ct_spd_max) end end end end return table.concat(skillList, "\n") end

return p