Kamihime Project Wiki
Advertisement

Documentation for this module may be created at Module:Weapon Skill/doc

--[[ 
Used in the fields "skill_type", "skill2_type",
"skill_flb_type" and "skill_flb_type2" in 
the Template:Weapon_Infobox.

Samples: "assault xl", "pride l", "defender m", "vigoras s"

size is not necessary for single weapon skills as, and will
default to: "Small" for Rs, "Medium" for SRs, 
and "Large" for SSRs and SSR+s
--]]

local p = {}

function split(str, separator) 
    separator = separator or '%s' 
    local t = {} 

    for k, v in string.gmatch(str, "([^" .. separator .. "]*)(" .. separator .. "?)") do 
        table.insert(t, k) 
        if v == "" then 
            return t
        end
    end
end

function tableLength(t)
    local count = 0
    for _ in pairs(t) do count = count + 1 end

    return count
end

function getName(skillType, element, scale)
    local _rarities = { SSR = true, ["SSR+"] = true, SR = true, R = true }
    local _scales = { SSR = "l", ["SSR+"] = "l", SR = "m", R = "s" }

    if (_rarities[scale]) then scale = _scales[scale] end

    local extraLargeScales = {
        Fire = "Prominence",
        Water = "Glaciate",
        Thunder = "Lightning",
        Wind = "Tempest",
        Light = "Sacred",
        Dark = "Eclipse"
    }
    local largeScales = {
        Fire = "Inferno",
        Water = "Cocytus",
        Thunder = "Impulse",
        Wind = "Turbulence",
        Light = "Luminous",
        Dark = "Schwarz"
    }
    local mediumScales = {
        Fire = "Burning",
        Water = "Blizzard",
        Thunder = "Plasma",
        Wind = "Storm",
        Light = "Shine",
        Dark = "Abyss"
    }
    local smallScales = {
        Fire = "Fire",
        Water = "Aqua",
        Thunder = "Thunder",
        Wind = "Aero",
        Light = "Ray",
        Dark = "Dark"
    }
    local scales = {
        l = largeScales,
        m = mediumScales,
        s = smallScales,
        xl = extraLargeScales
    }

    return scales[scale][element] .. " " .. (skillType:gsub("^%l", string.upper))
end

function getDescription(skillType)
    local types = {
        --[[ Simples --]]
        ascension = "Recovery↑",
		assault = "ATK↑",
		barrage = "Triple Attack Rate↑",
		defender = "Max HP↑",
		elaborate = "Ability DMG↑",
		exceed = "Burst↑",
		pride = "ATK↑ commensurate to HP lost ratio",
		rush = "Double Attack Rate↑",
		stinger = "Crit Rate↑",
		technica = "Normal ATK↑",
		vigoras = "ATK↑ commensurate to left HP ratio",

        --[[ Composites --]]
        amplifier = "ATK↑ and Ability DMG↑",
		avalanche = "Combo Attack Rate↑",
		grace = "Max HP and Recovery↑",
		magnate = "Max HP↑ and Normal ATK↑",
		parkup = "Max HP↑ and Crit Rate↑",
		rampart = "Max HP↑ and ATK↑ commensurate to left HP ratio",
		resilience = "ATK↑ and Recovery↑",
		slug = "ATK↑ and Crit Rate↑",
		sprout = "Recovery↑ & DMG↑ to commensurate to left HP ratio",
		stewart = "Max HP↑ and with low HP, ATK↑",
		strength = "ATK↑ and Max HP↑",
		tactics = "Burst↑ and Ability DMG↑",
		transcend = "ATK↑ and Burst↑",
		triedge = "ATK↑ and Triple Attack Rate↑",
		triguard = "Max HP↑ and Triple Attack Rate↑",
		twinedge = "ATK↑ and Double Attack Rate↑",
		twinguard = "Max HP↑ and Double Attack Rate↑",
    }

    return types[skillType]
end

function p.icon(frame)
    local t = split(frame.args["skill_type"])

    return frame.args["element"] .. (t[1]:gsub("^%l", string.upper))
end

function p.name(frame)
    local t = split(frame.args["skill_type"])
    local accessor

    if tableLength(t) == 1 then
        accessor = frame.args["rarity"]
    else
        accessor = t[2]
    end

    return getName(t[1], frame.args["element"], accessor)
end

function p.desc(frame)
    local t = split(frame.args["skill_type"])
    local result = frame.args["element"] .. " Characters' " .. getDescription(t[1]:lower())
    local scale
    local accessor
    if tableLength(t) == 1 then
        scale = {
            R = "Small",
            SR = "Medium",
            SSR = "Large",
            ["SSR+"] = "Large"
        }
        accessor = frame.args["rarity"]
    else
        scale = {
            s = "Small",
            m = "Medium",
            l = "Large",
            xl = "Extra Large"
        }
        accessor = t[2]
    end

    return result .. " (" .. scale[accessor] .. ")"
end

return p
Advertisement