Module:Heroes/getter
Jump to navigation
Jump to search
This module has no documentation. If you know how to use this module, please add some.
Module:Heroes/getter/doc
local p = {}
local currentData = mw.loadData('Module:Heroes/data')
local builder = require('Module:SimpleHTMLBuilder')
local function get(hero, key, key2, key3)
local data = currentData[hero]
local val = data and data[key] or nil
if key2 and type(val) == 'table' then
val = val[key2]
if key3 and type(val) == 'table' then
val = val[key3]
end
end
return val, hero
end
function p.apiname(hero)
return get(hero, 'apiname') or hero
end
function p.image(hero)
return get(hero, 'image')
end
function p.portrait(hero)
return get(hero, 'portrait') or p.image(hero)
end
function p.icon(hero)
return get(hero, 'icon')
end
function p.released(hero)
return get(hero, 'released')
end
function p.amber(hero)
return get(hero, 'amber')
end
function p.platinum(hero)
return get(hero, 'platinum')
end
function p.difficulty(hero)
return get(hero, 'difficulty')
end
function p.classes(hero)
return get(hero, 'classes')
end
function p.roles(hero)
return get(hero, 'roles')
end
function p.range_type(hero)
return get(hero, 'range_type')
end
-----------------------
-- Chart Stats
-----------------------
function p.ability_power(hero)
return get(hero, 'ability_power')
end
function p.durability(hero)
return get(hero, 'durability')
end
function p.basic_attack(hero)
return get(hero, 'basic_attack')
end
function p.mobility(hero)
return get(hero, 'mobility')
end
-----------------------
-- Abilities
-----------------------
function p.LMB(hero, arg_notes) return p.createAbility(hero, "LMB", arg_notes) end
function p.RMB(hero, arg_notes) return p.createAbility(hero, "RMB", arg_notes) end
function p.Q(hero, arg_notes) return p.createAbility(hero, "Q", arg_notes) end
function p.E(hero, arg_notes) return p.createAbility(hero, "E", arg_notes) end
function p.R(hero, arg_notes) return p.createAbility(hero, "R", arg_notes) end
function p.Passive(hero, arg_notes) return p.createAbility(hero, "Passive", arg_notes) end
function p.createAbility(arg_hero, arg_ability, arg_notes)
local ability = get(arg_hero, 'abilities', arg_ability)
if ability then
local currentFrame = mw.getCurrentFrame()
local name = ability.name
local icon = ability.icon
local description = ability.description
local details = ''
local cooldown = ''
if ability.cooldown then
local cooldownTbl = {}
for i, v in ipairs(ability.cooldown) do
cooldownTbl[i] = tostring(v)
end
cooldown = table.concat(cooldownTbl, '/')
end
local mana = ''
if ability.mana then
local manaTbl = {}
for i, v in ipairs(ability.mana) do
manaTbl[i] = tostring(v)
end
mana = table.concat(manaTbl, '/')
end
if arg_ability == 'LMB' then
details = '{{Key|LMB}} {{Label|default|Basic Attack}}'
end
if arg_ability == 'RMB' then
details = '{{Key|RMB}} {{Label|default|Alternate}}'
end
if arg_ability == 'Q' then
details = '{{Key|Q}} {{Label|default|Primary}}'
end
if arg_ability == 'E' then
details = '{{Key|E}} {{Label|default|Secondary}}'
end
if arg_ability == 'R' then
details = '{{Key|R}} {{Label|default|Ultimate}}'
end
if arg_ability == 'Passive' then
details = '{{Label|default|Passive}}'
end
return currentFrame:expandTemplate{title = "Hero/ability", args = {
['name'] = name,
['icon'] = icon,
['cooldown'] = cooldown,
['mana'] = mana,
['description'] = currentFrame:preprocess(description),
['details'] = currentFrame:preprocess(details),
['notes'] = arg_notes
}}
end
end
-----------------------
-- Stats
-----------------------
function p.physical_power(hero) return get(hero, 'stats', 'physical_power') end
function p.physical_power_growth(hero) return get(hero, 'stats', 'physical_power_growth') end
function p.attack_speed(hero) return get(hero, 'stats', 'attack_speed') end
function p.attack_speed_growth(hero) return get(hero, 'stats', 'attack_speed_growth') end
function p.physical_armor(hero) return get(hero, 'stats', 'physical_armor') end
function p.physical_armor_growth(hero) return get(hero, 'stats', 'physical_armor_growth') end
function p.magical_armor(hero) return get(hero, 'stats', 'magical_armor') end
function p.magical_armor_growth(hero) return get(hero, 'stats', 'magical_armor_growth') end
function p.max_health(hero) return get(hero, 'stats', 'max_health') end
function p.max_health_growth(hero) return get(hero, 'stats', 'max_health_growth') end
function p.max_mana(hero) return get(hero, 'stats', 'max_mana') end
function p.max_mana_growth(hero) return get(hero, 'stats', 'max_mana_growth') end
function p.health_regeneration(hero) return get(hero, 'stats', 'health_regeneration') end
function p.health_regeneration_growth(hero) return get(hero, 'stats', 'health_regeneration_growth') end
function p.mana_regeneration(hero) return get(hero, 'stats', 'mana_regeneration') end
function p.mana_regeneration_growth(hero) return get(hero, 'stats', 'mana_regeneration_growth') end
function p.basic_attack_time(hero) return get(hero, 'stats', 'basic_attack_time') end
function p.attack_range(hero) return get(hero, 'stats', 'attack_range') end
function p.movement_speed(hero) return get(hero, 'stats', 'movement_speed') end
function p.cleave(hero) return get(hero, 'stats', 'cleave') end
---- Recommended ----
function p.recommended(hero)
return get(hero, 'recommended')
end
function p.support(hero)
return get(hero, 'recommended', 'support')
end
function p.carry(hero)
return get(hero, 'recommended', 'carry')
end
function p.midlane(hero)
return get(hero, 'recommended', 'midlane')
end
function p.offlane(hero)
return get(hero, 'recommended', 'offlane')
end
function p.jungle(hero)
return get(hero, 'recommended', 'jungle')
end
return p
Category:
- Modules with no documentation