Documentation for this module may be created at Module:Page/Job/AI/sandbox/doc
local render_job_icon = require('Module:Render/Job')._icon
local model = require('Module:Data').model
local cargo = require('Module:CargoUtil')
local enums = require('Module:Data/Enums')
local p = {}
function p.renderSkillPriority(root, skillKeys)
if skillKeys == nil or #skillKeys < 1 then return end
root:tag('h3'):wikitext('SkillPriority')
local ol = root:tag('ol')
for i, key in ipairs(skillKeys) do
ol:tag('li'):wikitext((enums.SkillCategory[key] or key))
end
root:wikitext('\n\n')
end
function p.renderBuffPriority(root, buffKeys, selfOnly)
if buffKeys == nil or #buffKeys < 1 then return end
root:tag('h3'):wikitext('Buff Priority')
if selfOnly and selfOnly == 1 then
root:tag('b'):wikitext("Self Buffs only")
root:wikitext("\n\n")
end
local ol = root:tag('ol')
for index, key in ipairs(buffKeys) do
ol:tag('li'):wikitext((enums.statNameFromType(key) or key))
end
root:wikitext("\n\n")
end
function p.renderConditionPriority(root, condKeys)
if condKeys == nil or #condKeys < 1 then return end
root:tag('h3'):wikitext('Condition Priority')
local ol = root:tag('ol')
for index, key in ipairs(condKeys) do
ol:tag('li'):wikitext(enums.enchantTypeNameFromKey(key))
end
root:wikitext("\n\n")
end
function p.aiPriorityOutput(job)
if job == nil then return '' end
local ai = model.query("AI", "iname, buff_prio, cond_prio, skil_prio, buff_self", {where = 'iname="'..job.ai..'"'}) or {}
if not (ai and ai[1]) then return end
local root = mw.html.create()
header = root:tag('h2'):wikitext('AI Priority')
p.renderSkillPriority(header, ai.skil_prio)
p.renderBuffPriority(header, ai.skil_prio, ai.buff_self)
p.renderConditionPriority(header, ai.cond_prio)
return tostring(root)
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.aiPriorityOutput(job)
end
return p