Kamihime Project Wiki
m (forgot another xl ref)
mNo edit summary
Line 62: Line 62:
 
m = mediumScales,
 
m = mediumScales,
 
s = smallScales,
 
s = smallScales,
xl = "Extra Large"
+
xl = extraLargeScales
 
}
 
}
   

Revision as of 06:53, 10 January 2020

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

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 --]]
        assault = "ATK↑",
        ascension = "Recovery↑",
        barrage = "Triple Attack Rate↑",
        defender = "Max HP↑",
        elaborate = "Ability DMG↑",
        exceed = "Burst↑",
        pride = "with low HP, ATK↑",
        rush = "Double Attack Rate↑",
        stinger = "Crit Rate↑",
        vigoras = "ATK↑ commensurate to left HP ratio",
        
        --[[ Composites --]]
        avalanche = "Combo Attack Rate↑",
        grace = "Max HP and Recovery↑",
        race = "Max HP↑ and with low HP, ATK↑",
        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",
        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