Module:Abilities/icon: Difference between revisionsGive feedback
Jump to navigation
Jump to search
m Move p.get_attr_icon to here |
mNo edit summary |
||
| Line 57: | Line 57: | ||
-- get scaling icon attributes associated with a specified scale type | -- get scaling icon attributes associated with a specified scale type | ||
function getScalarIcon( | function getScalarIcon(scaleType, attribute) | ||
local scalingIcon = SCALING_ICON_MAP[scaleType] | local scalingIcon = SCALING_ICON_MAP[scaleType] | ||
Revision as of 08:52, 15 May 2026
Overview
Icon related functions for ability cards
Usage
Submodules
Abilities - Simple functions. Eg. getting ability name
Abilities/utils - Common internal functions that are shared amongst any Abilities/ modules
Abilities/card - Generates hero ability cards
Abilities/icon - Functions for retrieving ability and attribute icon data
Abilities/details table (WIP) - Generates details table to show raw ability data
local p = {}
-- Maps attr type to an appropriate image and page link
-- Optional icon size, will be defaulted on the template
local ATTR_TYPE_ICON_MAP = require("Module:Icon/attr")
function getAttrIcon(attrType)
local mappedAttr = ATTR_TYPE_ICON_MAP[attrType]
local img = nil
local link = ''
local size = ''
local color = 'Grey'
if mappedAttr then
img = mappedAttr.img
link = mappedAttr.link
size = mappedAttr.size
color = mappedAttr.color or color
end
if img == nil then
return nil
end
return {img=img, link=link, color=color, size=size}
end
function p.getAttrIcon(attrType)
return getAttrIcon(attrType)
end
function p.getAttrIconFile(frame)
local args = frame.args
local attrType = args[1]
local attr_type = frame.args[1]
local icon = getAttrIcon(attr_type)
if icon == nil then
return ''
end
return string.format('[[File:%s|%s|18px|link=%s]]', icon.img or '', icon.size or '', icon.link or '')
end
-- List of scaling type attributes
local SCALING_ICON_MAP = {
["spirit"] = { class = "spirit", icon = "File:Spirit scaling.png", link = "Spirit Power#Spirit Power Scaling", size = "40px" },
["stats_count"] = { class = "spirit", icon = "File:Spirit scaling.png", link = "Spirit Power#Spirit Power Scaling", size = "40px" },
["weapon_power"] = { class = "weapon", icon = "File:Weapon scaling.png", link = "Weapon Damage#Weapon Damage Scaling", size = "40px" },
["weapon_damage_increase"] = { class = "weapon", icon = "File:Weapon scaling.png", link = "Weapon Damage#Weapon Damage Scaling", size = "40px" },
["melee"] = { class = "weapon", icon = "File:Melee scaling.png", link = "Melee Damage#Abilities", size = "40px" },
["heavy_melee"] = { class = "weapon", icon = "File:Melee scaling.png", link = "Melee Damage#Abilities", size = "40px" },
["power_increase"] = { class = "boon", icon = "File:Boon scaling.png", link="Boon", size = "25px" }, -- Boon icon has to be smaller than others
["duration"] = { class = "default" }, -- Use "default" if the scaling is unused
}
-- get scaling icon attributes associated with a specified scale type
function getScalarIcon(scaleType, attribute)
local scalingIcon = SCALING_ICON_MAP[scaleType]
if scalingIcon then
return scalingIcon[attribute] or "Missing scaling type in Module:Abilities/icon"
end
return ""
end
function p._getScalarIcon(scaleType, attribute)
return getScalarIcon(scaleType, attribute)
end
function p.getScalarIcon(frame)
local args = frame.args
local scaleType = args[1]
local attribute = args[2]
return getScalarIcon(scaleType, attribute)
end
return p