17,105
edits
m (Clone from Module:Items) |
mNo edit summary |
||
Line 1: | Line 1: | ||
-- Used for testing Lua related bits without the possibility of impacting modules that are actively generating page content | -- Used for testing Lua related bits without the possibility of impacting modules that are actively generating page content | ||
-- TODO: | |||
-- Special attack description processing | |||
-- Anything else combat related | |||
--This module contains all sorts of functions for getting data on items | --This module contains all sorts of functions for getting data on items | ||
Line 9: | Line 12: | ||
local MonsterData = mw.loadData('Module:Monsters/data') | local MonsterData = mw.loadData('Module:Monsters/data') | ||
local ItemData = mw.loadData('Module: | local ItemData = mw.loadData('Module:AuronTest/data') | ||
local SkillData = mw.loadData('Module:Skills/data') | local SkillData = mw.loadData('Module:Skills/data') | ||
Line 104: | Line 107: | ||
end | end | ||
return result | return result | ||
end | |||
-- Input: equipmentStats property of an item in the format { { ["key"] = "stabAttackBonus", ["value"] = 2 }, ... } | |||
-- Output: Table in the format { ["stabAttackBonus"] = 2, ... } | |||
function p._processEquipmentStats(equipStats) | |||
local out = {} | |||
if type(equipStats) == 'table' then | |||
for i, stat in pairs(equipStats) do | |||
local k, v = stat["key"], stat["value"] | |||
if out[k] == nil then | |||
out[k] = v | |||
else | |||
out[k] = out[k] + v | |||
end | |||
end | |||
end | |||
return out | |||
end | end | ||
Line 109: | Line 129: | ||
local result = item[StatName] | local result = item[StatName] | ||
--Special Overrides: | --Special Overrides: | ||
if StatName | -- Equipment stats first | ||
if Shared.contains(ItemData.EquipmentStatKeys, StatName) then | |||
local equipStats = p._processEquipmentStats(item.equipmentStats) | |||
if equipStats[StatName] == nil then | |||
result = nil | result = nil | ||
else | else | ||
result = | result = equipStats[StatName] | ||
end | end | ||
elseif StatName == 'attackType' then | elseif StatName == 'attackType' then | ||
Line 169: | Line 179: | ||
skill = Constants.getSkillID(skill) | skill = Constants.getSkillID(skill) | ||
end | end | ||
local result = 0 | local result = 0 | ||
Line 249: | Line 257: | ||
end | end | ||
end | end | ||
function p.getWeaponAttackType(frame) | function p.getWeaponAttackType(frame) |