Anonymous

Module:Skills/Summoning: Difference between revisions

From Melvor Idle
Further 1.0.3 fixes, reverts temporary 'fix'
(Partial fix following 1.0.3 data structure changes)
(Further 1.0.3 fixes, reverts temporary 'fix')
Line 131: Line 131:
end
end


function p.getSynergyTable(frame)
return ''
end
function p.getFamiliarSynergyTable(frame)
return ''
end
function p.getSkillSummoningBonusTable(frame)
return ''
end
--[==[
function p.getSynergyTable(frame)
function p.getSynergyTable(frame)
   local result = ''
   local result = ''
Line 150: Line 137:
   result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect!!Requirements'
   result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect!!Requirements'


   local Familiars = p.getFamiliars()
   local synergyList = {}
   local FamArrayByID = {}
  for i, syn in ipairs(SkillData.Summoning.Synergies) do
   for i, Fam in Shared.skpairs(Familiars) do
  table.insert(synergyList, syn)
    FamArrayByID[Fam.summoningID + 1] = Fam
  end
  table.sort(synergyList, function (a, b) return (a.summons[1] == b.summons[1] and a.summons[2] < b.summons[2]) or a.summons[1] < b.summons[1] end)
 
   local marksByID, famNames = {}, {}
   for i, recipe in ipairs(SkillData.Summoning.Marks) do
  marksByID[recipe.masteryID] = recipe
  local item = Items.getItemByID(recipe.itemID)
  if item ~= nil then
  famNames[recipe.masteryID] = item.name
  end
   end
   end


   local rowArray = {}
   local rowArray = {}
 
   for i, syn in ipairs(synergyList) do
   for i, SynCat in Shared.skpairs(SkillData.Summoning.Synergies) do
local Fam1 = marksByID[syn.summons[1]]
    local Fam1 = FamArrayByID[i]
local Fam2 = marksByID[syn.summons[2]]
    for j, Syn in Shared.skpairs(SynCat) do
if Fam1 ~= nil and Fam2 ~= nil then
       local Fam2 = FamArrayByID[j]
       local FamName1 = famNames[Fam1.masteryID] or 'Unknown'
  local FamName2 = famNames[Fam2.masteryID] or 'Unknown'
       local rowText = '|-'
       local rowText = '|-'
       rowText = rowText..'\r\n|data-sort-value="'..Fam1.name..'"|'..Icons.Icon({Fam1.name, type='item', notext=true, size='30'})
       rowText = rowText..'\r\n|data-sort-value="'..FamName1..'"|'..Icons.Icon({FamName1, type='item', notext=true, size='30'})
       rowText = rowText..'||'..Icons.Icon({Fam1.name, type='item', noicon=true})
       rowText = rowText..'||'..Icons.Icon({FamName1, type='item', noicon=true})
       rowText = rowText..'||data-sort-value="'..Fam2.name..'"|'..Icons.Icon({Fam2.name, type='item', notext=true, size='30'})
       rowText = rowText..'||data-sort-value="'..FamName2..'"|'..Icons.Icon({FamName2, type='item', notext=true, size='30'})
       rowText = rowText..'||'..Icons.Icon({Fam2.name, type='item', noicon=true})
       rowText = rowText..'||'..Icons.Icon({FamName2, type='item', noicon=true})
       rowText = rowText..'||'..Syn.description
       rowText = rowText..'||'..syn.description


       local reqArray = {}
       local reqArray = {}
       local reqLvl = math.max(Fam1.summoningLevel, Fam2.summoningLevel)
       local reqLvl = math.max(Fam1.level, Fam2.level)
       table.insert(reqArray, Icons._SkillReq('Summoning', reqLvl))
       table.insert(reqArray, Icons._SkillReq('Summoning', reqLvl))
       table.insert(reqArray, Fam1.name..' Mark Level '..(Fam2.summoningTier + 1))
       table.insert(reqArray, FamName1..' Mark Level '..(Fam2.tier + 1))
       table.insert(reqArray, Fam2.name..' Mark Level '..(Fam1.summoningTier + 1))
       table.insert(reqArray, FamName2..' Mark Level '..(Fam1.tier + 1))


       rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')
       rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')
Line 187: Line 184:
end
end


function p._getFamiliarSynergyTable(familiar)
function p._getFamiliarSynergyTable(familiarID)
  local result = ''
local result = ''
  result = result..'{| class="wikitable sortable stickyHeader"'
result = result..'{| class="wikitable sortable stickyHeader"'
  result = result..'\r\n|- class="headerRow-0"'
result = result..'\r\n|- class="headerRow-0"'
  result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect!!Requirements'
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 = {}
local synergyList = {}
for i, syn in ipairs(SkillData.Summoning.Synergies) do
if Shared.contains(syn.summons, familiarID) then
table.insert(synergyList, syn)
end
end
    table.sort(synergyList, function (a, b) return (a.summons[1] == b.summons[1] and a.summons[2] < b.summons[2]) or a.summons[1] < b.summons[1] end)


  for i, SynCat in Shared.skpairs(SkillData.Summoning.Synergies) do
local marksByID, famNames = {}, {}
    local Fam1 = FamArrayByID[i]
for i, recipe in ipairs(SkillData.Summoning.Marks) do
    for j, Syn in Shared.skpairs(SynCat) do
marksByID[recipe.masteryID] = recipe
      local Fam2 = FamArrayByID[j]
local item = Items.getItemByID(recipe.itemID)
      if i - 1 == familiar.summoningID or j - 1 == familiar.summoningID then
if item ~= nil then
        local rowText = '|-'
  famNames[recipe.masteryID] = item.name
        rowText = rowText..'\r\n|data-sort-value="'..Fam1.name..'"|'..Icons.Icon({Fam1.name, type='item', notext=true, size='30'})
end
        rowText = rowText..'||'..Icons.Icon({Fam1.name, type='item', noicon=true})
end
        rowText = rowText..'||data-sort-value="'..Fam2.name..'"|'..Icons.Icon({Fam2.name, type='item', notext=true, size='30'})
        rowText = rowText..'||'..Icons.Icon({Fam2.name, type='item', noicon=true})
        rowText = rowText..'||'..Syn.description


        local reqArray = {}
local rowArray = {}
        local reqLvl = math.max(Fam1.summoningLevel, Fam2.summoningLevel)
for i, syn in ipairs(synergyList) do
        table.insert(reqArray, Icons._SkillReq('Summoning', reqLvl))
local Fam1 = marksByID[syn.summons[1]]
        table.insert(reqArray, Fam1.name..' Mark Level '..(Fam2.summoningTier + 1))
local Fam2 = marksByID[syn.summons[2]]
        table.insert(reqArray, Fam2.name..' Mark Level '..(Fam1.summoningTier + 1))
if Fam1 ~= nil and Fam2 ~= nil then
local FamName1 = famNames[Fam1.masteryID] or 'Unknown'
local FamName2 = famNames[Fam2.masteryID] or 'Unknown'
local rowText = '|-'
rowText = rowText..'\r\n|data-sort-value="'..FamName1..'"|'..Icons.Icon({FamName1, type='item', notext=true, size='30'})
rowText = rowText..'||'..Icons.Icon({FamName1, type='item', noicon=true})
rowText = rowText..'||data-sort-value="'..FamName2..'"|'..Icons.Icon({FamName2, type='item', notext=true, size='30'})
rowText = rowText..'||'..Icons.Icon({FamName2, type='item', noicon=true})
rowText = rowText..'||'..syn.description


        rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')
local reqArray = {}
 
local reqLvl = math.max(Fam1.level, Fam2.level)
        table.insert(rowArray, rowText)
table.insert(reqArray, Icons._SkillReq('Summoning', reqLvl))
      end
table.insert(reqArray, FamName1..' Mark Level '..(Fam2.tier + 1))
    end
table.insert(reqArray, FamName2..' Mark Level '..(Fam1.tier + 1))
  end
rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')


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


  result = result..'\r\n|}'
result = result..'\r\n'..table.concat(rowArray, '\r\n')
  return result
result = result..'\r\n|}'
return result
end
end


function p.getFamiliarSynergyTable(frame)
function p.getFamiliarSynergyTable(frame)
  local famName = frame.args ~= nil and frame.args[1] or frame
local famName = frame.args ~= nil and frame.args[1] or frame
  local familiar = Items.getItem(famName)
local familiarID = nil
  if familiar == nil or familiar.type ~= 'Familiar' then
local familiarItem = Items.getItem(famName)
    return 'ERROR: Not a valid familiar[[Category:Pages with script errors]]'
if familiarItem == nil then
  end
return 'ERROR: Not a valid familiar[[Category:Pages with script errors]]'
  return p._getFamiliarSynergyTable(familiar)
else
for i, recipe in ipairs(SkillData.Summoning.Marks) do
if recipe.itemID == familiarItem.id then
familiarID = recipe.masteryID
break
end
end
if familiarID == nil then
return 'ERROR: Not a valid familiar[[Category:Pages with script errors]]'
else
return p._getFamiliarSynergyTable(familiarID)
end
end
end
end


function p._getSkillSummoningBonusTable(skill)
function p._getSkillSummoningBonusTable(skill)
  local rowArray = {}
local rowArray = {}
local famNames = {}


  local Familiars = p.getFamiliars()
-- Familiars
  local FamArrayByID = {}
for i, recipe in ipairs(SkillData.Summoning.Marks) do
  for i, Fam in Shared.skpairs(Familiars) do
local item = Items.getItemByID(recipe.itemID)
    FamArrayByID[Fam.summoningID + 1] = Fam
if item ~= nil then
    local famSkills = Constants.getModifierSkills(Fam.modifiers)
famNames[recipe.masteryID] = item.name
    for k, skillName in Shared.skpairs(famSkills) do
if item.modifiers ~= nil then
      if skillName == skill then
local famSkills = Constants.getModifierSkills(item.modifiers)
        table.insert(rowArray, {Fam1 = Fam.name, Fam2 = nil, Descrip = Constants.getModifiersText(Fam.modifiers, false)})
if Shared.contains(famSkills, skill) then
      end
table.insert(rowArray, {Fam1 = item.name, Fam2 = nil, Descrip = Constants.getModifiersText(item.modifiers, false)})
    end
end
  end
end
end
end


  for i, SynCat in Shared.skpairs(SkillData.Summoning.Synergies) do
-- Synergies
    local Fam1 = FamArrayByID[i]
for i, syn in ipairs(SkillData.Summoning.Synergies) do
 
local synSkills = Constants.getModifierSkills(syn.modifiers)
    for j, Syn in Shared.skpairs(SynCat) do
if Shared.contains(synSkills, skill) then
      local Fam2 = FamArrayByID[j]
local FamName1 = famNames[syn.summons[1]] or 'Unknown'
      local skills = Constants.getModifierSkills(Syn.modifiers)
local FamName2 = famNames[syn.summons[2]] or 'Unknown'
      for k, skillName in Shared.skpairs(skills) do
table.insert(rowArray, {Fam1 = FamName1, Fam2 = FamName2, Descrip = syn.description})
        if skillName == skill then
end
          table.insert(rowArray, {Fam1 = Fam1.name, Fam2 = Fam2.name, Descrip = Syn.description})
end
        end
      end
    end
  end


if Shared.tableCount(rowArray) == 0 then
return ''
end


  local result = ''
local resultPart = {}
  result = result..'{| class="wikitable sortable stickyHeader"'
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
  result = result..'\r\n|- class="headerRow-0"'
  table.insert(resultPart, '\r\n|- class="headerRow-0"')
  result = result..'\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect'
table.insert(resultPart, '\r\n!colspan="2"|Familiar 1!!colspan="2"|Familiar 2!!Effect')


  for i, rowItem in Shared.skpairs(rowArray) do
for i, rowItem in Shared.skpairs(rowArray) do
    result = result..'\r\n|-'
table.insert(resultPart, '\r\n|-')
    result = result..'\r\n|data-sort-value="'..rowItem.Fam1..'"|'..Icons.Icon({rowItem.Fam1, type='item', notext=true, size='30'})
    table.insert(resultPart, '\r\n|data-sort-value="'..rowItem.Fam1..'"|'..Icons.Icon({rowItem.Fam1, type='item', notext=true, size='30'}))
    result = result..'||'..Icons.Icon({rowItem.Fam1, type='item', noicon=true})
table.insert(resultPart, '||'..Icons.Icon({rowItem.Fam1, type='item', noicon=true}))
    if rowItem.Fam2 ~= nil then
if rowItem.Fam2 ~= nil then
      result = result..'||data-sort-value="'..rowItem.Fam2..'"|'..Icons.Icon({rowItem.Fam2, type='item', notext=true, size='30'})
table.insert(resultPart, '||data-sort-value="'..rowItem.Fam2..'"|'..Icons.Icon({rowItem.Fam2, type='item', notext=true, size='30'}))
      result = result..'||'..Icons.Icon({rowItem.Fam2, type='item', noicon=true})
table.insert(resultPart, '||'..Icons.Icon({rowItem.Fam2, type='item', noicon=true}))
    else
else
      result = result..'|| || '
table.insert(resultPart, '|| || ')
    end
end
    if rowItem.Descrip == nil then
table.insert(resultPart, '||'..(rowItem.Descrip or ' '))
      if rowItem.Fam2 == nil then
end
        mw.log(rowItem.Fam1)
      else
        mw.log(rowItem.Fam1..' + '..rowItem.Fam2)
      end
    else
      result = result..'||'..rowItem.Descrip
    end
  end


  result = result..'\r\n|}'
table.insert(resultPart, '\r\n|}')
  return result
return table.concat(resultPart)
end
end


function p.getSkillSummoningBonusTable(frame)
function p.getSkillSummoningBonusTable(frame)
  local skillName = frame.args ~= nil and frame.args[1] or frame
local skillName = frame.args ~= nil and frame.args[1] or frame
 
return p._getSkillSummoningBonusTable(skillName)
  return p._getSkillSummoningBonusTable(skillName)
end
end
--]==]


return p
return p