Anonymous

Module:Sandbox/AuronTest: Difference between revisions

From Melvor Idle
m
no edit summary
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:Items/data')
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 == 'stabAttackBonus' then
  -- Equipment stats first
     if item.attackBonus == nil then  
   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 = item.attackBonus[1]
       result = equipStats[StatName]
    end
  elseif StatName == 'slashAttackBonus' then
    if item.attackBonus == nil then
      result = nil
    else
      result = item.attackBonus[2]
    end
  elseif StatName == 'blockAttackBonus' then
    if item.attackBonus == nil then
      result = nil
    else
      result = item.attackBonus[3]
     end
     end
   elseif StatName == 'attackType' then
   elseif StatName == 'attackType' then
Line 169: Line 179:
     skill = Constants.getSkillID(skill)
     skill = Constants.getSkillID(skill)
   end
   end
  mw.log(item.name..', '..modifier)


   local result = 0
   local result = 0
Line 249: Line 257:
   end
   end
end
end


function p.getWeaponAttackType(frame)
function p.getWeaponAttackType(frame)