Module:Abilities/card: Difference between revisionsGive feedback
Updated to use some newer icons and/or use the colors that are in the game. |
Added support for melee scaling attributes to show the outcome with the hero's base melee value |
||
| Line 280: | Line 280: | ||
local main_boxes = {} | local main_boxes = {} | ||
for k, prop in pairs(props) do | for k, prop in pairs(props) do | ||
local value = prop.Value | |||
-- If it scales with melee damage, set the value using the hero's base melee to match in game visuals | |||
if prop.Scale and prop.Scale.Type == 'melee' then | |||
local hero = get_hero_data(hero_key) | |||
value = prop.Value + hero.LightMeleeDamage * prop.Scale.Value | |||
end | |||
-- Exclude 0 values | -- Exclude 0 values | ||
if | if value and value ~= 0 then | ||
local icon = get_icon(prop.Type) | local icon = get_icon(prop.Type) | ||
local main_box = frame:expandTemplate{ | local main_box = frame:expandTemplate{ | ||
| Line 288: | Line 295: | ||
title = prop.Title, | title = prop.Title, | ||
key = prop.Key, | key = prop.Key, | ||
value = | value = value, | ||
icon = icon.img, | icon = icon.img, | ||
icon_link = icon.link, | icon_link = icon.link, | ||
| Line 302: | Line 309: | ||
return main_boxes | return main_boxes | ||
end | |||
function get_hero_data(hero_key) | |||
local hero_data = mw.loadJsonData("Data:HeroData.json") | |||
local hero = hero_data[hero_key] | |||
if (hero == nil) then return "Hero Not Found" end | |||
return hero | |||
end | end | ||