Module:Skill

local model = require('Module:Data').model local yesno = require('Module:Yesno')

local index = {} local mt = { __index = function(t,k) local v = t[index][k] t[index][k] = nil return v	end, } local function track(t) local proxy = {} proxy[index] = t	setmetatable(proxy, mt) return proxy end

local function query(tables, fields, args) local skillModel = mw.loadData('Module:Data/Model/' .. tables) if fields == '*' then local t = {'_pageName', 'server'} for k,v in pairs(skillModel) do			t[#t+1] = k		end table.sort(t) fields = table.concat(t, ', ') end

local query = model.query or mw.ext.cargo.query local rows = query(tables, fields, args) local data = {} for i, row in ipairs(rows) do		local t = {} for k,v in pairs(row) do			if type(v) == 'table' then if #v > 0 then t[k] = v end elseif type(v) == 'string' then if v ~= '' then t[k] = v end elseif type(v) == 'boolean' then t[k] = yesno(v) or false else t[k] = v			end end data[#data+1] = t	end return data end

local p = {}

local enums = { AttackTypes = { [0] = "None", [1] = "PhyAttack", [2] = "MagAttack" },	ESelectType = { [0] = 'Cross', [1] = 'Diamond', [2] = 'Square', [3] = 'Laser', [4] = 'All', [5] = 'Wall', [6] = 'WallPlus', [7] = 'Bishop', [8] = 'Victory', [9] = 'LaserSpread', [10] = 'LaserWide', [11] = 'Horse', [12] = 'LaserTwin', [13] = 'LaserTriple', [14] = 'SquareOutline', },	ESkillType = { [0] = "Attack", [1] = "Skill", [2] = "Passive", [3] = "Item", [4] = "Reaction", },	EElement = { [0] = "None", [1] = "Fire", [2] = "Water", [3] = "Wind", [4] = "Thunder", [5] = "Shine", [6] = "Dark", },	SkillEffectTargets = { [0] = "Target", [1] = "Self" },	SkillEffectTypes = { [0] = "None", [1] = "Equipment", [2] = "Attack", [3] = "Defend", [4] = "Heal", [5] = "Buff", [6] = "Debuff", [7] = "Revive", [8] = "Shield", [9] = "ReflectDamage", [10] = "DamageControl", [11] = "FailCondition", [12] = "CureCondition", [13] = "DisableCondition", [14] = "GemsGift", [15] = "GemsIncDec", [16] = "Guard", [17] = "Teleport", [18] = "Changing", [19] = "RateHeal", [20] = "RateDamage", [21] = "PerfectAvoid", [22] = "Throw", [23] = "EffReplace", [24] = "SetTrick", [25] = "TransformUnit", [26] = "SetBreakObj", [27] = "ChangeWeather", [28] = "RateDamageCurrent", [29] = "TransformUnitTakeOverHP", [30] = "DynamicTransformUnit" },   SkillParamCalcTypes = { [0] = "Add", [1] = "Scale", [2] = "Fixed" },	ESkillTiming = { [0] = "Used", [1] = "Passive", [2] = "Wait", [3] = "Dead", [4] = "DamageCalculate", [5] = "DamageControl", [6] = "Reaction", [7] = "FirstReaction", [8] = "Auto", [9] = "Dying", [10] = "JudgeHP" },	ESkillTarget = { [0] = "Self", [1] = "SelfSide", [2] = "EnemySide", [3] = "UnitAll", [4] = "NotSelf", [5] = "GridNoUnit", [6] = "ValidGrid", [7] = "SelfSideNotSelf" },	eSkillTargetEx = { [0] = "None", [1] = "JumpInc", [2] = "JumpOnly" },   ShieldTypes = { [0] = "None", [1] = "UseCount", [2] = "Hp", [3] = "Limitter", [4] = "MAX" },   DamageTypes = { [0] = "None", [1] = "TotalDamage", [2] = "PhyDamage", [3] = "MagDamage" },   ShieldTypes = { [0] = "None", [1] = "UseCount", [2] = "Hp", [3] = "Limitter", [4] = "MAX" }, }

function p._page(iname) local data = query('Skill', '*', {where = 'iname = "'..iname..'" AND server = "gl"'})[1] data = track(data) local function printRow(t, label, key, enums) local v = data[key] content = v and enums and enums[v] or v		if content == 'None' then return end t:newline:tag('tr') :tag('th'):wikitext(label .. ' ('..key..')'):done :tag('td'):wikitext(content):done :tag('td'):wikitext(v):done end

local root = mw.html.create('table'):addClass('wikitable') printRow(root, 'Type', 'type', enums.ESkillType) printRow(root, 'Reaction Damage Type', 'react_d_type', enums.DamageTypes) printRow(root, 'DMG Type', 'atk_type', enums.AttackTypes) printRow(root, 'Shield Type', 'shield_type', enums.ShieldTypes) printRow(root, 'Shield Damage Type', 'shield_d_type', enums.DamageTypes) printRow(root, 'Element', 'elem', enums.EElement) printRow(root, 'Effect Type', 'eff_type', enums.SkillEffectTypes) printRow(root, 'Effect Calc', 'eff_calc', enums.SkillParamCalcTypes) printRow(root, 'Effect Value Min', 'eff_val_ini') printRow(root, 'Effect Value Max', 'eff_val_max') printRow(root, 'Target', 'target', enums.ESkillTarget) printRow(root, 'Min Range', 'rangemin') printRow(root, 'Max Range', 'rangemax') printRow(root, 'Select Range', 'sran', enums.ESelectType) printRow(root, 'Scope', 'scope') printRow(root, 'Select Scope', 'ssco', enums.ESelectType) printRow(root, 'Height', 'eff_h') printRow(root, 'Timing', 'timing', enums.ESkillTiming) printRow(root, 'TargetEx', 'target_ex', enums.eSkillTargetEx)

mw.log('http://alchemistcodedb.com/skill/'..iname:gsub('_', '-'):lower)

mw.logObject(data, 'unprocessed data') return tostring(root) end

function p.test mw.log(p._page('SK_US_SC_THUNDER_Lv1')) end

return p