Module:AbilityData/hero: Difference between revisionsGive feedback
m fixed link from Translation to Translte |
m get_hero_key and get_ability_num initial |
||
| Line 6: | Line 6: | ||
local p = {} | local p = {} | ||
function p.get_hero_key(ability_key) | |||
if type(ability_key) == 'table' and ability_key.args then | |||
local frame = ability_key | |||
ability_key = frame.args[1] | |||
end | |||
--O(1) search for it in hero data | |||
for hero_key, hero_data in pairs(heroes_data) do | |||
local abilities_data = hero_data["BoundAbilities"] | |||
for ability_num, ability_data in pairs(abilities_data) do | |||
if ability_key == ability_data["Key"] then | |||
return hero_key | |||
end | |||
end | |||
end | |||
end | |||
function p.get_ability_num(ability_key) | |||
if type(ability_key) == 'table' and ability_key.args then | |||
local frame = ability_key | |||
ability_key = frame.args[1] | |||
end | |||
--O(1) search for it in hero data | |||
for hero_key, hero_data in pairs(heroes_data) do | |||
local abilities_data = hero_data["BoundAbilities"] | |||
for ability_num, ability_data in pairs(abilities_data) do | |||
if ability_key == ability_data["Key"] then | |||
return ability_num | |||
end | |||
end | |||
end | |||
end | |||
-- Write each of the hero's ability cards in a tab of a tabber | -- Write each of the hero's ability cards in a tab of a tabber | ||