Anonymous

Module:Magic: Difference between revisions

From Melvor Idle
2,866 bytes added ,  23 January 2021
Added p.getCurseTable, p.getAuroraTable, and p.getAncientTable
(Tweaking links for magic types again)
(Added p.getCurseTable, p.getAuroraTable, and p.getAncientTable)
Line 249: Line 249:
   end
   end
   return ''
   return ''
end
function p._getSpellRow(spell, includeTypeColumn)
  local rowTxt = '\r\n|-\r\n|data-sort-value="'..spell.name..'"|'
  if spell.type == 'Auroras' then
    rowTxt = rowTxt..Icons.Icon({spell.name, type='aurora', notext=true, size=50})
  elseif spell.type == 'Curses' then
    rowTxt = rowTxt..Icons.Icon({spell.name, type='curse', notext=true, size=50})
  else
    rowTxt = rowTxt..Icons.Icon({spell.name, type='spell', notext=true, size=50})
  end
  rowTxt = rowTxt..'||[['..spell.name..']]'
  rowTxt = rowTxt..'||data-sort-value="'..spell.magicLevelRequired..'"|'..Icons._SkillReq('Magic', spell.magicLevelRequired)
  --Handle required items/dungeon clears
  if spell.requiredItem ~= nil and spell.requiredItem >= 0 then
    local reqItem = Items.getItemByID(spell.requiredItem)
    rowTxt = rowTxt..'<br/>'..Icons.Icon({reqItem.name, type='item', notext=true})..' equipped'
  end
  if spell.requiredDungeonCompletion ~= nil then
    local dung = Areas.getAreaByID('dungeon', spell.requiredDungeonCompletion[1])
    rowTxt = rowTxt..'<br/>'..Icons.Icon({dung.name, type='dungeon', notext=true, qty=spell.requiredDungeonCompletion[2]})..' Clears'
  end
  if includeTypeColumn then
    rowTxt = rowTxt..'||data-sort-value="'..p.getSpellTypeIndex(spell.type)..'"|'
    rowTxt = rowTxt..p.getSpellTypeLink(spell.type)
  end
  if spell.type == 'Spells' then
    rowTxt = rowTxt..'||Combat spell with a max hit of '..(spell.maxHit * 10)
  else
    rowTxt = rowTxt..'||'..spell.description
  end
  rowTxt = rowTxt..'||style="text-align:center"|'
  rowTxt = rowTxt..p._getSpellRunes(spell)
  return rowTxt
end
function p.getCurseTable(frame)
  local result = '{|class="wikitable sortable"\r\n!colspan="2"|Spell'
  result = result..'!!Requirements'
  result = result..'!!style="width:275px"|Description'
  result = result..'!!Runes'
  for i, spell in pairs(MagicData.Curses) do
    local rowTxt = p._getSpellRow(processSpell('Curses', i), false)
    result = result..rowTxt
  end
  result = result..'\r\n|}'
  return result
end
function p.getAuroraTable(frame)
  local result = '{|class="wikitable sortable"\r\n!colspan="2"|Spell'
  result = result..'!!Requirements'
  result = result..'!!style="width:275px"|Description'
  result = result..'!!Runes'
  for i, spell in pairs(MagicData.Auroras) do
    local rowTxt = p._getSpellRow(processSpell('Auroras', i), false)
    result = result..rowTxt
  end
  result = result..'\r\n|}'
  return result
end
function p.getAncientTable(frame)
  local result = '{|class="wikitable sortable"\r\n!colspan="2"|Spell'
  result = result..'!!Requirements'
  result = result..'!!style="width:275px"|Description'
  result = result..'!!Runes'
  for i, spell in pairs(MagicData.Ancient) do
    local rowTxt = p._getSpellRow(processSpell('Ancient', i), false)
    result = result..rowTxt
  end
  result = result..'\r\n|}'
  return result
end
end


return p
return p