Module:Abilities/card: Difference between revisions

Jump to navigation Jump to search
m use utils for getting ability card data
Sur (talk | contribs)
m created write_ability_card_from_ability_key for use from an ability page (not a hero page)
Line 55: Line 55:
end
end


--from hero key*
function p.get_ability_card_from_key(hero_key, ability_num, add_link, notes)
function p.get_ability_card_from_key(hero_key, ability_num, add_link, notes)
if type(hero_key) == 'table' and hero_key.args then
if type(hero_key) == 'table' and hero_key.args then
Line 94: Line 95:
}
}
}
}
end
--for use from an ability page (ability pages are WIP), not hero pages
function p.write_ability_card_from_ability_key(frame)
local ability_key = frame.args[1]
if ability_key == nil then return "ability_key '" .. ability_key "' not provided" end
-- Determine the hero and ability number
local found_hero_key
local found_ability_num
for hero_key, card_data in pairs(data) do
if found_hero_key == nil or found_ability_num == nil then
for ability_num, ability_data in pairs(card_data) do
if ability_num ~= "Name" then
if ability_data['Key'] == ability_key then
found_hero_key = hero_key
found_ability_num = ability_num
break
end -- hero_key and ability_num found
end
end
end
end
if found_ability_num == nil or found_hero_key == nil then return "ability_key " .. ability_key .. " is not used by any heroes" end
-- Get notes for this ability
local notes_source_page_name = utils.get_notes_source_page_name(ability_key)
local notes_str = frame:preprocess("{{"..notes_source_page_name.."}}")
-- Create the ability card
return p.get_ability_card_from_key(found_hero_key, found_ability_num, true, notes_str)
end
end