Module:Abilities/card: Difference between revisions

mNo edit summary
mNo edit summary
Tag: Manual revert
Line 9: Line 9:


function get_hero_key(hero_name)
function get_hero_key(hero_name)
if not hero_name or hero_name == "" then return nil end
if hero_name == nil then return nil end
 
-- if name starts with "hero_", use it directly as the key
-- if name starts with "hero_", use it directly as the key
if string.sub(hero_name, 1, 5) == "hero_" then return hero_name end
if string.sub(hero_name, 1, 5) == "hero_" then return hero_name end
 
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
if not resource_lookup then return nil end
return resource_lookup[hero_name:lower()].key
 
local key = tostring(hero_name):lower()
local entry = resource_lookup[key]
 
if not entry then
return nil
end
 
return entry.key
end
end