Module:Items/getter
Jump to navigation
Jump to search
Documentation
This module has no documentation. If you know how to use this module, please add some.
Module:Items/getter/doclocal p = {}
local currentData = mw.loadData('Module:Items/data')
local builder = require('Module:SimpleHTMLBuilder')
--[[local function get(item)
return data[item] or {}
end ]]--
local function get(item, key, key2, key3)
local data = currentData[item]
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, item
end
function p.id(item)
return get(item, 'id')
end
function p.image(item)
return get(item, 'image')
end
function p.buy(item)
local b = get(item, 'buy')
if b then
return b
else
return 0
end
end
function p.sell(item)
local s = get(item, 'sell')
if s then
return s
else
return math.floor(p.buy(item) * 0.7 * 10 + 0.5) / 10
end
end
function p.combine(item)
local recipe = get(item, 'recipe')
if recipe then
local i = 0
for _,value in pairs(recipe) do
i = i + p.buy(value)
end
return (p.buy(item)) - i
end
end
function p.class(item)
return get(item, 'class')
end
function p.type(item) -- table
return get(item, 'type')
end
function p.benefit(item)
return get(item, 'benefit')
end
function p.requiredlevel(item)
return get(item, 'requiredlevel')
end
function p.removed(item)
return get(item, 'removed')
end
function p.slot(item)
return get(item, 'slot')
end
function p.tier(item)
local tier = get(item, 'tier')
if tier then
if tier == 0 then
return nil
else
return tier
end
end
end
function p.recommendedfor(item) -- table
return get(item, 'recommendedfor')
end
function p.recommendedagainst(item) -- table
return get(item, 'recommendedagainst')
end
function p.buildsinto(item) -- table
return get(item, 'buildsinto')
end
function p.recipe(item) -- table
return get(item, 'recipe')
end
-- Effects ----------------------------
function p.effects(item)
return get(item, 'effects')
end
function p.createEffect(item, effect)
local effect = get(item, 'effects', effect)
if effect then
local currentFrame = mw.getCurrentFrame()
local name = effect.name
local description = effect.description
local cooldown = effect.cooldown
local condition = effect.condition
local effectBox = builder.create('table')
effectBox:cssText('border: 1px solid var(--theme-border-color); border-collapse: collapse;')
local headerRow = builder.create('tr')
local headerCell = headerRow:tag('td')
headerCell:cssText('background: var(--theme-box-background); padding: 5px 10px 5px 10px;')
local hres = ''
if effect == get(item, 'effects', 'active') then
hres = hres .. '{{c|yellow|Active - }}'
end
hres = hres .. '{{c|yellow|'..name..'}}'
if cooldown then
hres = hres .. '{{c|yellow| - '..cooldown..' CD}}'
end
if condition then
hres = hres .. '{{c|yellow| -}} {{c|condition|'..condition..':}}'
else
hres = hres .. '{{c|yellow|:}}'
end
headerCell
:wikitext(currentFrame:preprocess(hres))
:done()
headerRow:done()
local descRow = builder.create('tr')
local descCell = descRow:tag('td')
if description then
descCell
:cssText('padding: 5px 10px 5px 10px;')
:wikitext(currentFrame:preprocess(description))
:done()
descRow:done()
end
effectBox:node(headerRow)
effectBox:node(descRow)
return effectBox:allDone()
end
end
function p.active(item) return get(item, 'effects', 'active') end --p.createEffect(item, "active") end
function p.passive(item) return get(item, 'effects', 'passive') end --p.createEffect(item, "passive") end
function p.passive2(item) return get(item, 'effects', 'passive2') end --p.createEffect(item, "passive2") end
function p.passive3(item) return get(item, 'effects', 'passive3') end --p.createEffect(item, "passive3") end
-- Stats ------------------------------
function p.stats(item) return get(item, 'stats') end
function p.abilityhaste(item) return get(item, 'stats', 'abilityhaste') end
function p.attackspeed(item) return get(item, 'stats', 'attackspeed') end
function p.criticalchance(item) return get(item, 'stats', 'criticalchance') end
function p.goldpersecond(item) return get(item, 'stats', 'goldpersecond') end
function p.healshieldincrease(item) return get(item, 'stats', 'healshieldincrease') end
function p.healthregeneration(item) return get(item, 'stats', 'healthregeneration') end
function p.lifesteal(item) return get(item, 'stats', 'lifesteal') end
function p.magicalarmor(item) return get(item, 'stats', 'magicalarmor') end
function p.magicallifesteal(item) return get(item, 'stats', 'magicallifesteal') end
function p.magicalpenetration(item) return get(item, 'stats', 'magicalpenetration') end
function p.magicalpower(item) return get(item, 'stats', 'magicalpower') end
function p.manaregeneration(item) return get(item, 'stats', 'manaregeneration') end
function p.maxhealth(item) return get(item, 'stats', 'maxhealth') end
function p.maxmana(item) return get(item, 'stats', 'maxmana') end
function p.movementspeed(item) return get(item, 'stats', 'movementspeed') end
function p.omnivamp(item) return get(item, 'stats', 'omnivamp') end
function p.physicalarmor(item) return get(item, 'stats', 'physicalarmor') end
function p.physicalpenetration(item) return get(item, 'stats', 'physicalpenetration') end
function p.physicalpower(item) return get(item, 'stats', 'physicalpower') end
function p.tenacity(item) return get(item, 'stats', 'tenacity') end
return p
Category:
- Modules with no documentation