Documentation for this module may be created at Module:FFRK Ability/doc

local p = {}
local getArgs = require("Dev:Arguments").getArgs
local icons = require("Module:FFRK Charicon")._charicon
local data = mw.loadData("Module:FFRK Ability/data")

local function parse(arg)
    local stat = ""
    local val = ""

    for s in string.gmatch(arg, "%S+") do
        stat = stat .. " " .. val
        val = s
    end

    return stat:sub(3), val
end

local function satisfies(name, stats, args)
    for _, arg in pairs(args) do
        local stat, val = parse(arg)

        if not stats[stat] or stats[stat] < tonumber(val) then
            return false
        end
    end

    return true
end

function p._ability(args)
    local chars = {}

    for name, stats in pairs(data.standard) do
        if satisfies(name, stats, args) then
            table.insert(chars, name)
        end
    end

    return icons(chars)
end

function p.ability(frame)
    local args = getArgs(frame)

    return p._ability(args)
end

function p._recordSphere(args)
    local chars = {}

    for name, stats in pairs(data.sphere) do
        if satisfies(name, stats, args) then
            table.insert(chars, name)
        end
    end

    return icons(chars)
end

function p.recordSphere(frame)
    local args = getArgs(frame)

    return p._recordSphere(args)
end

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