Anonymous

Module:Skills/Summoning: Difference between revisions

From Melvor Idle
Added a getFamiliarSynergyTable function
(Added XP for creation to summoning tablet table)
(Added a getFamiliarSynergyTable function)
Line 151: Line 151:
   result = result..'\r\n|}'
   result = result..'\r\n|}'
   return result
   return result
end
function p._getFamiliarSynergyTable(familiar)
  local result = ''
  result = result..'{| class="wikitable sortable stickyHeader"'
  result = result..'\r\n|- class="headerRow-0"'
  result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect!!Requirements'
  local Familiars = p.getFamiliars()
  local FamArrayByID = {}
  for i, Fam in Shared.skpairs(Familiars) do
    FamArrayByID[Fam.summoningID + 1] = Fam
  end
  local rowArray = {}
  for i, SynCat in Shared.skpairs(SkillData.Summoning.Synergies) do
    local Fam1 = FamArrayByID[i]
    for j, Syn in Shared.skpairs(SynCat) do
      local Fam2 = FamArrayByID[j]
      if i - 1 == familiar.summoningID or j - 1 == familiar.summoningID then
        local rowText = '|-'
        rowText = rowText..'\r\n|data-sort-value="'..Fam1.name..'"|'..Icons.Icon({Fam1.name, type='item', notext=true, size='30'})..'||[['..Fam1.name..']]'
        rowText = rowText..'||data-sort-value="'..Fam2.name..'"|'..Icons.Icon({Fam2.name, type='item', notext=true, size='30'})..'||[['..Fam2.name..']]'
        rowText = rowText..'||'..Syn.description
        local reqArray = {}
        local reqLvl = math.max(Fam1.summoningLevel, Fam2.summoningLevel)
        table.insert(reqArray, Icons._SkillReq('Summoning', reqLvl))
        table.insert(reqArray, Fam1.name..' Mark Level '..(Fam2.summoningTier + 1))
        table.insert(reqArray, Fam2.name..' Mark Level '..(Fam1.summoningTier + 1))
        rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')
        table.insert(rowArray, rowText)
      end
    end
  end
  result = result..'\r\n'..table.concat(rowArray, '\r\n')
  result = result..'\r\n|}'
  return result
end
function p.getFamiliarSynergyTable(frame)
  local famName = frame.args ~= nil and frame.args[1] or frame
  local familiar = Items.getItem(famName)
  if familiar == nil or familiar.type ~= 'Familiar' then
    return 'ERROR: Not a valid familiar[[Category:Pages with script errors]]'
  end
  return p._getFamiliarSynergyTable(familiar)
end
end


return p
return p