Editing Module:Abilities/details table

Jump to navigation Jump to search
Warning: You are not logged in. Once you make an edit, a temporary account will be created for you. Learn more. Log in or create an account to continue receiving notifications after this account expires, and to access other features.
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 hero_key = utils.get_hero_key(hero_name)
local ability = utils.get_ability_card_data(hero_name, ability_num)
local ability = utils.get_ability_card_data(hero_key, ability_num)
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 26: Line 25:
local scale_value = prop.Scale and prop.Scale.Value or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_type = prop.Scale and prop.Scale.Type or nil
rows = rows .. create_row(prop.Key, prop.Value, scale_type, scale_value, frame)  
rows = rows .. create_row(prop.Key, prop.Value, scale_type, scale_value)  
end
end
end
end
Line 35: Line 34:
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
rows = rows .. create_row(prop.Key, prop.Value, scale_type, scale_value, frame)
rows = rows .. create_row(prop.Key, prop.Value, scale_type, scale_value)
end
end
end
end
Line 46: Line 45:
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
rows = rows .. create_row(attr, prop.Value, scale_type, scale_value, frame)
rows = rows .. create_row(attr, prop.Value, scale_type, scale_value)
end
end
end
end
Line 55: Line 54:
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_type = prop.Scale and prop.Scale.Type or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
local scale_value = prop.Scale and prop.Scale.Value or nil
rows = rows .. create_row(attr, prop.Value, scale_type, scale_value, frame)
rows = rows .. create_row(attr, prop.Value, scale_type, scale_value)
end
end
end
end
Line 62: Line 61:
end
end


local UPGRADE_COST_MAP = {1, 2, 5}
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 hero_key = utils.get_hero_key(hero_name)
local ability = utils.get_ability_card_data(hero_name, ability_num)
local ability = utils.get_ability_card_data(hero_key, ability_num)
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 = '\n|-\n'
local rows = ''
for i, upgrade in pairs(ability.Upgrades) do
local upgrade = ability.Upgrades[tonumber(upgrade_num)]
local data_rows = ''
for key, value in pairs(upgrade) do
if key ~= 'DescKey' then
-- track number of attributes so we can assign the correct rowspan for the upgrade cost column
local scale_type = upgrade.Scale and upgrade.Scale.Type or nil
local num_of_attrs = 0
local scale_value = upgrade.Scale and upgrade.Scale.Value or nil
for key, value in pairs(upgrade) do
rows = rows .. create_row(key, value, scale_type, scale_value)
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
data_rows = data_rows .. create_row(key, value, scale_type, scale_value, frame, true)
num_of_attrs = num_of_attrs + 1
end
end
end
rows = rows .. string.format("\n!rowspan=%s style=\"background-color: #121212; color: #FFEFD7; text-align: center; text-wrap: nowrap;\" | [[File:Ability_point_unlock_icon.png|20px|link=Ability_Point]] '''%s'''\n", num_of_attrs, UPGRADE_COST_MAP[i])
rows = rows .. data_rows
end
end


Line 94: Line 83:
end
end


-- with_plus=true will include the "+" symbol before the number, as by default it will be omiitted
function create_row(key, value, scale_type, scale_value)
function create_row(key, value, scale_type, scale_value, frame, with_plus)
if key == nil or value == nil then
if key == nil or value == nil then
return ''
return ''
end
end
-- get localized label, if none exists, fallback to one that is based on the key
local label = lang._get_string(key)
local label = lang.get_string(key..'_label')
if label == nil then
if label == '' then
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, with_plus~=true)
local row = '|' .. label .. '||' .. 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
end
end
return row .. '\n|-\n'
return '\n|-\n'..row
end
end


Please note that all contributions to The Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Deadlock:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)
Preview page with this template