Module:Abilities/card: Difference between revisions

Jump to navigation Jump to search
note
m Refactored get_scalar func naming
Line 11: Line 11:


-- List of scaling type attributes
-- List of scaling type attributes
local scalingTypes = {
local SCALING_ICON_MAP = {
     ["spirit"] = { class = "spirit", icon = "File:Spirit scaling.png", link = "Spirit Power#Spirit Power Scaling", size = "40px" },
     ["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" },
     ["stats_count"] = { class = "spirit", icon = "File:Spirit scaling.png", link = "Spirit Power#Spirit Power Scaling", size = "40px" },
Line 22: Line 22:
}
}


-- get scaling attribute
-- get scaling icon attribute associated with a specified scale type
function p.get_scalar(frame)
function p.get_scalar(frame)
     local args = frame.args
     local args = frame.args


     local scaling = args[1]     -- first parameter
     local scaleType = args[1]  
     local attribute = args[2]     -- second parameter
     local attribute = args[2]


     local scaling = scalingTypes[scaling]
     local scalingIcon = SCALING_ICON_MAP[scaleType]


     if scaling then
     if scalingIcon then
         return scaling[attribute] or "Missing scaling type in Module:Abilities/card"
         return scalingIcon[attribute] or "Missing scaling type in Module:Abilities/card"
     end
     end