Module:Skills/Summoning

From Melvor Idle
< Module:Skills
Revision as of 13:32, 11 June 2021 by Falterfire (talk | contribs) (Added links to names)

Documentation for this module may be created at Module:Skills/Summoning/doc

local p = {}

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

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

function p.getFamiliars()
  return Items.getItems(function(item) return item.type == "Familiar" end)
end

function p.getMarkTable(frame)
  local result = ''
  result = result..'{| class="wikitable sortable stickyHeader"'
  result = result..'\r\n|- class="headerRow-0"'
  result = result..'\r\n!colspan="2"|Mark!!'..Icons.Icon({'Summoning', type='skill', notext=true})..' Level'
  result = result..'!!Discovered in'

  local Familiars = p.getFamiliars()
  table.sort(Familiars, function(a, b) return a.summoningLevel < b.summoningLevel end)

  local rowArray = {}

  for i, Fam in Shared.skpairs(Familiars) do
    local rowText = '|-'
    rowText = rowText..'\r\n|data-sort-value="'..Fam.name..'"|'..Icons.Icon({Fam.name, type='mark', notext=true, size='50'})
    rowText = rowText..'||[['..Fam.name..'|Mark of the '..Fam.name..']]'
    rowText = rowText..'||'..Fam.summoningLevel
    local discoveredArray = {}
    for j, SkillID in Shared.skpairs(Fam.summoningSkills) do
      table.insert(discoveredArray, Icons.Icon({Constants.getSkillName(SkillID), type='skill'}))
    end
    rowText = rowText..'||'..table.concat(discoveredArray, '<br/>')
    table.insert(rowArray, rowText)
  end

  result = result..'\r\n'..table.concat(rowArray, '\r\n')

  result = result..'\r\n|}'
  return result
end

return p