Editing Module:Abilities/details tableGive feedback
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
| Latest revision | Your text | ||
| Line 10: | Line 10: | ||
local hero_name = frame.args[1] | local hero_name = frame.args[1] | ||
local ability_num = frame.args[2] | local ability_num = frame.args[2] | ||
local ability = utils.get_ability_card_data(hero_name, ability_num) | |||
local ability = utils.get_ability_card_data( | |||
if(ability == nil) then error(string.format('Ability %s#%s not found', hero_name, ability_num)) end | if(ability == nil) then error(string.format('Ability %s#%s not found', hero_name, ability_num)) end | ||
| Line 62: | Line 61: | ||
end | end | ||
p.get_upgrade_table = function(frame) | p.get_upgrade_table = function(frame) | ||
local hero_name = frame.args[1] | local hero_name = frame.args[1] | ||
| Line 68: | Line 66: | ||
local upgrade_num = frame.args[3] | local upgrade_num = frame.args[3] | ||
local ability = utils.get_ability_card_data(hero_name, ability_num) | |||
local ability = utils.get_ability_card_data( | |||
if(ability == nil) then error(string.format('Ability %s#%s not found', hero_name, ability_num)) end | if(ability == nil) then error(string.format('Ability %s#%s not found', hero_name, ability_num)) end | ||
local rows = ' | local rows = '' | ||
local upgrade = ability.Upgrades[tonumber(upgrade_num)] | |||
for key, value in pairs(upgrade) do | |||
if key ~= 'DescKey' then | |||
local scale_type = upgrade.Scale and upgrade.Scale.Type or nil | |||
local scale_value = upgrade.Scale and upgrade.Scale.Value or nil | |||
rows = rows .. create_row(key, value, scale_type, scale_value, frame) | |||
end | end | ||
end | end | ||
| Line 94: | Line 83: | ||
end | end | ||
function create_row(key, value, scale_type, scale_value, frame) | |||
function create_row(key, value, scale_type, scale_value, frame | |||
if key == nil or value == nil then | if key == nil or value == nil then | ||
return '' | return '' | ||
end | end | ||
local label = lang._get_string(key..'_label') | |||
local label = lang. | if label == nil then | ||
if label == | label = commonutils.add_space_before_cap(key) | ||
label = commonutils.add_space_before_cap(key) | |||
end | end | ||
local formatted_value = utils.format_value_with_prepost(key, value, frame | local formatted_value = utils.format_value_with_prepost(key, value, frame) | ||
local row = '|' .. label .. '||' .. formatted_value | local row = '|' .. label .. '||' .. formatted_value | ||
if scale_type and scale_value then | if scale_type and scale_value then | ||
row = row .. '||' .. scale_type .. '||' .. scale_value .. '%' | row = row .. '||' .. scale_type .. '||' .. scale_value*100 .. '%' | ||
end | end | ||
return | return '\n|-\n'..row | ||
end | end | ||