Module:Infobox item: Difference between revisions

No edit summary
Added icons for status effects
Line 15: Line 15:
local tostring = tostring
local tostring = tostring
local type = type
local type = type
-- Status Effect Icon Map
local STATUS_EFFECT_ICON_MAP = {
    StatusEffectDisarmed = {img='Status_Disarm.png',        link='Disarm',  color='Red'},
    StatusEffectEMP      = {img='Status_Silence.png',      link='Silence',  color='Purple'},
    StatusEffectInvisible= {img='Invisible.png',            link='Invisible',color='Green'},
    StatusEffectStun    = {img='Status_Stun.png',          link='Stun',    color='NoColor'},
    StatusEffectSlow    = {img='Status_Movement_Slow.png', link='Slow',    color='Purple'},
}


-- Pre-computed constants
-- Pre-computed constants
Line 297: Line 306:
         icon_str = format("{{Icon/%s|[[File:%s|%spx|link=%s]]}}", color, img, 18, link or "")
         icon_str = format("{{Icon/%s|[[File:%s|%spx|link=%s]]}}", color, img, 18, link or "")
     end
     end
    return {
        icon = icon_str,
        link = link
    }
end
--------------------------------------------------------------------------------
-- Status Effect Icon helper
--------------------------------------------------------------------------------
local function resolve_status_effect_icon(prop_key)
    local effect_config = STATUS_EFFECT_ICON_MAP[prop_key]
    if not effect_config then return nil end
    local color = effect_config.color or "NoColor"
    local img = effect_config.img or "GenericProperty.png"
    local link = effect_config.link
    -- Construct icon using the defined color template
    local icon_str = format(
        "{{Icon/%s|[[File:%s|18px|link=%s]]}}",
        color, img, link or ""
    )


     return {
     return {
Line 422: Line 455:


     return append_conditional(val_str, allow_conditional, usage_flags)
     return append_conditional(val_str, allow_conditional, usage_flags)
end
--------------------------------------------------------------------------------
-- Status Effect formatting helper
--------------------------------------------------------------------------------
local function format_status_effect(prop_key)
    local lang_str = format("[[{{#invoke:Lang|get_string|Citadel_%s}}]]", prop_key)
        .. " [[{{#invoke:Lang|get_string|Citadel_StatusEffect}}]]"
   
    -- Get icon for this status effect
    local icon_style = resolve_status_effect_icon(prop_key)
    if icon_style and icon_style.icon then
        return icon_style.icon .. " " .. lang_str
    end
   
    return lang_str
end
end


Line 553: Line 603:
         main_formatter = function(obj)
         main_formatter = function(obj)
             if obj.Key:match("^StatusEffect") then
             if obj.Key:match("^StatusEffect") then
                 return format(STATUS_FMT, obj.Key)
                 return format_status_effect(obj.Key)
             end
             end
             return format_value_enhanced(
             return format_value_enhanced(
Line 561: Line 611:
         end
         end
         alt_formatter = function(obj)
         alt_formatter = function(obj)
            if obj.Key:match("^StatusEffect") then
                return format_status_effect(obj.Key)
            end
             return format_value_enhanced(
             return format_value_enhanced(
                 resolved_name, obj.Key, obj.Value, obj.Type,
                 resolved_name, obj.Key, obj.Value, obj.Type,
Line 570: Line 623:
         main_formatter = function(obj)
         main_formatter = function(obj)
             if obj.Key:match("^StatusEffect") then
             if obj.Key:match("^StatusEffect") then
                 return format(STATUS_FMT, obj.Key)
                 return format_status_effect(obj.Key)
             end
             end
             return format_value(
             return format_value(
Line 578: Line 631:
         end
         end
         alt_formatter = function(obj)
         alt_formatter = function(obj)
            if obj.Key:match("^StatusEffect") then
                return format_status_effect(obj.Key)
            end
             return format_value(
             return format_value(
                 obj.Key, obj.Value, obj.Type, obj.LocTokenOverride,
                 obj.Key, obj.Value, obj.Type, obj.LocTokenOverride,