Documentation for this module may be created at Module:XII enemy AI/doc

-- <nowiki>
-- This module is used with {{FFXII Enemy AI}} template, allowing for an
-- infinite number of parameters.
local p = {}
local getArgs = require("Dev:Arguments").getArgs

function p.main(frame)
    local args = getArgs(frame)
    local tbl = mw.html.create("table")
        :addClass("FFXII")
        :addClass("article-table")
        :tag("tr")
            :addClass("a")
            :tag("th")
                :attr("colspan", 3)
                :wikitext("Abilities")
                :done()
            :done()
        :tag("tr")
            :addClass("a")
            :tag("th")
                :css("width", "10%")
                :wikitext("Type")
                :done()
            :tag("th")
                :css("width", "20%")
                :wikitext("Name")
                :done()
            :tag("th")
                :wikitext("Condition")
                :done()
            :done()

    for _, header in ipairs{"Magicks", "Technicks", "Augments", "Items"} do
        local prefix = header:sub(1, -2):lower()

        if args[prefix .. "name1"] then
            local rowNo = 1
            local header

            while args[prefix .. "name" .. rowNo] do
                local row = tbl:tag("tr")

                if rowNo == 1 then
                    header = row:tag("th")
                        :addClass("b")
                        :wikitext(header)
                end

                row:tag("td")
                    :wikitext(args[prefix .. "name" .. rowNo])

                row:tag("td")
                    :wikitext(args[prefix .. "cond" .. rowNo] or "None")

                rowNo = rowNo + 1
            end

            header:attr("rowspan", rowNo - 1)
        end
    end

    tbl:tag("tr")
        :addClass("a")
        :tag("th")
            :attr("colspan", 3)
            :wikitext("Properties")
            :done()

    tbl:tag("tr")
        :addClass("a")
        :tag("th")
            :css("width", "30%")
            :wikitext("Type")
            :attr("colspan", 2)
            :done()
        :tag("th")
            :wikitext("Property")
            :done()

    for _, v in ipairs{"Targeting", "Linking", "Attacks", "Pursuit"} do
        tbl:tag("tr")
            :tag("th")
                :attr("colspan", 2)
                :addClass("b")
                :wikitext(v)
                :done()
            :tag("td")
                :wikitext(args[v:lower()])
                :done()
    end

    if args.propertytype1 then
        local i = 1

        while args["propertytype" .. i] do
            tbl:tag("tr")
                :tag("th")
                    :attr("colspan", 2)
                    :addClass("b")
                    :wikitext(args["propertytype" .. i])
                    :done()
                :tag("td")
                    :wikitext(args["property" .. i] or "None")
                    :done()

            i = i + 1
        end
    end

    if args.info then
        tbl:tag("tr")
            :tag("th")
                :attr("colspan", 2)
                :addClass("b")
                :wikitext("Other Information")
                :done()
            :tag("td")
                :wikitext(args.info)
                :done()
    end

    return tbl
end

return p
Community content is available under CC-BY-SA unless otherwise noted.