Module:Abilities/card: Difference between revisions

m Use resource lookup for faster hero key retrieval
m move resource lookup load inside of function call
Line 5: Line 5:
local p = {}
local p = {}
local data = mw.loadJsonData("Data:AbilityCards.json")
local data = mw.loadJsonData("Data:AbilityCards.json")
local resourceLookup = mw.loadJsonData("Data:ResourceLookup.json")


-- Maps attr type to an appropriate image and page link
-- Maps attr type to an appropriate image and page link
Line 17: Line 16:
-- 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
return resourceLookup[hero_name:lower()].key
local resource_lookup = mw.loadJsonData("Data:ResourceLookup.json")
return resource_lookup[hero_name:lower()].key
end
end