Module:Skills

From Melvor Idle
Revision as of 14:28, 15 October 2020 by Falterfire (talk | contribs) (Added getMasteryCheckpointTable and getMasteryUnlockTable)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Data pulled from Module:GameData

Some skills have their own modules:

Also be aware of:


local p = {}

local SkillData = mw.loadData('Module:Skills/data')
local Constants = mw.loadData('Module:Constants/data')

local Shared = require('Module:Shared')
local Items = require('Module:Items')
local Icons = require('Module:Icons')

local MasteryCheckpoints = {'10%', '25%', '50%', '95%'}

function p.getSkillID(skillName)
  for skName, ID in Shared.skpairs(Constants.skill) do
    if skName == skillName then
      return ID
    end
  end
  return nil
end

function p.getMasteryUnlockTable(frame)
  local skillName = frame.args ~= nil and frame.args[1] or frame
  local skillID = p.getSkillID(skillName)
  if skillID == nil then
    return "ERROR: Failed to find a skill ID for "..skillName
  end

  local unlockTable = SkillData.MasteryUnlocks[skillID]
  if unlockTable == nil then
    return 'ERROR: Failed to find Mastery Unlock data for '..skillName
  end

  local result = '{|class="wikitable"\r\n!Level!!Unlock'
  for i, unlock in pairs(unlockTable) do
    result = result..'\r\n|-'
    result = result..'\r\n|'..unlock.level..'||'..unlock.unlock
  end
  result = result..'\r\n|}'
  return result
end

function p.getMasteryCheckpointTable(frame)
  local skillName = frame.args ~= nil and frame.args[1] or frame
  local skillID = p.getSkillID(skillName)
  if skillID == nil then
    return "ERROR: Failed to find a skill ID for "..skillName
  end

  if SkillData.MasteryCheckpoints[skillID] == nil then
    return 'ERROR: Failed to find Mastery Unlock data for '..skillName
  end

  local bonuses = SkillData.MasteryCheckpoints[skillID].bonuses

  local result = '{|class="wikitable"\r\n!Pool %!!Bonus'
  for i, bonus in Shared.skpairs(bonuses) do
    result = result..'\r\n|-'
    result = result..'\r\n|'..MasteryCheckpoints[i]..'||'..bonus
  end
  result = result..'\r\n|}'
  return result
end

return p