Module:Skills/Summoning: Difference between revisions

Partial fix following 1.0.3 data structure changes
(Substitute links with Icons.Icon() where possible to benefit from ambiguous link handling)
(Partial fix following 1.0.3 data structure changes)
Line 20: Line 20:
   result = result..'!!Discovered in'
   result = result..'!!Discovered in'


   local Familiars = p.getFamiliars()
   local Familiars = {}
   table.sort(Familiars, function(a, b)  
  for i, recipe in ipairs(SkillData.Summoning.Marks) do
                           if a.summoningLevel == b.summoningLevel then
  table.insert(Familiars, recipe)
                             return a.summoningID < b.summoningID
  end
   table.sort(Familiars, function(a, b)
                           if a.level == b.level then
                             return a.masteryID < b.masteryID
                           else
                           else
                             return a.summoningLevel < b.summoningLevel
                             return a.level < b.level
                           end
                           end
                         end)
                         end)


   local rowArray = {}
   local rowArray = {}
 
   for i, Fam in ipairs(Familiars) do
   for i, Fam in Shared.skpairs(Familiars) do
local item = Items.getItemByID(Fam.itemID)
    local rowText = '|-'
if item ~= nil then
    rowText = rowText..'\r\n|data-sort-value="'..Fam.name..'"|'..Icons.Icon({Fam.name, type='mark', notext=true, size='50'})
    local rowText = '|-'
    rowText = rowText..'||'..Icons.Icon({Fam.name, 'Mark of the ' .. Fam.name, type='mark', noicon=true})
    rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='mark', notext=true, size='50'})
    rowText = rowText..'||style="text-align:right"|'..Fam.summoningLevel
    rowText = rowText..'||'..Icons.Icon({item.name, 'Mark of the ' .. item.name, type='mark', noicon=true})
    local discoveredArray = {}
    rowText = rowText..'||style="text-align:right"|'..Fam.level
    for j, SkillID in Shared.skpairs(Fam.summoningSkills) do
    local discoveredArray = {}
      table.insert(discoveredArray, Icons.Icon({Constants.getSkillName(SkillID), type='skill'}))
    for j, SkillID in Shared.skpairs(Fam.skills) do
    end
      table.insert(discoveredArray, Icons.Icon({Constants.getSkillName(SkillID), type='skill'}))
    rowText = rowText..'||'..table.concat(discoveredArray, '<br/>')
    end
    table.insert(rowArray, rowText)
    rowText = rowText..'||'..table.concat(discoveredArray, '<br/>')
    table.insert(rowArray, rowText)
end
   end
   end


Line 57: Line 62:
   result = result..'!!Tier!!Effect!!' .. Icons.Icon({'Melee', notext=true, nolink=true}) .. ' Max Hit!!Description!!Shard Cost!!Secondary!!Creation XP'
   result = result..'!!Tier!!Effect!!' .. Icons.Icon({'Melee', notext=true, nolink=true}) .. ' Max Hit!!Description!!Shard Cost!!Secondary!!Creation XP'


   local Familiars = p.getFamiliars()
   local Familiars = {}
   table.sort(Familiars, function(a, b)  
  for i, recipe in ipairs(SkillData.Summoning.Marks) do
                           if a.summoningLevel == b.summoningLevel then
  table.insert(Familiars, recipe)
                             return a.summoningID < b.summoningID
  end
   table.sort(Familiars, function(a, b)
                           if a.level == b.level then
                             return a.masteryID < b.masteryID
                           else
                           else
                             return a.summoningLevel < b.summoningLevel
                             return a.level < b.level
                           end
                           end
                         end)
                         end)


   local rowArray = {}
   local rowArray = {}
  for i, Fam in ipairs(Familiars) do
local item = Items.getItemByID(Fam.itemID)
if item ~= nil then
    local maxHit, maxHitText = Items._getItemStat(item, 'summoningMaxhit'), ''
    if maxHit ~= nil then
      maxHit = maxHit * 10
      maxHitText = 'style="text-align:right"; data-sort-value="' .. maxHit .. '"|' .. Shared.formatnum(maxHit)
    end
    local rowText = '|-'
    rowText = rowText..'\r\n|data-sort-value="'..item.name..'"|'..Icons.Icon({item.name, type='item', notext=true, size='50'})
    rowText = rowText..'||'..Icons.Icon({item.name, type='item', noicon=true})
    rowText = rowText..'||style="text-align:right"|'..Fam.level
    rowText = rowText..'||style="text-align:right"|'..Fam.tier
    rowText = rowText..'||'..item.description..'||'..maxHitText..'||'..Fam.description


  for i, Fam in Shared.skpairs(Familiars) do
-- Create item requirements text
    local maxHit, maxHitText = Items._getItemStat(Fam, 'summoningMaxhit'), ''
local ShardCostArray, OtherCostArray = {}, {}
    if maxHit ~= nil then
-- Shards
      maxHit = maxHit * 10
for j, cost in ipairs(Fam.itemCosts) do
      maxHitText = 'style="text-align:right"; data-sort-value="' .. maxHit .. '"|' .. Shared.formatnum(maxHit)
local shard = Items.getItemByID(cost.id)
    end
if shard ~= nil then
    local rowText = '|-'
table.insert(ShardCostArray, Icons.Icon({shard.name, type='item', notext=true, qty=cost.qty}))
    rowText = rowText..'\r\n|data-sort-value="'..Fam.name..'"|'..Icons.Icon({Fam.name, type='item', notext=true, size='50'})
end
    rowText = rowText..'||'..Icons.Icon({Fam.name, type='item', noicon=true})
end
    rowText = rowText..'||style="text-align:right"|'..Fam.summoningLevel
rowText = rowText..'||style="text-align:right"|'..table.concat(ShardCostArray, ', ')..'&nbsp;'
    rowText = rowText..'||style="text-align:right"|'..Fam.summoningTier
    rowText = rowText..'||'..Fam.description..'||'..maxHitText..'||'..Fam.summoningDescription


    --Currently assuming the shard cost is the same for all recipe variants
-- Other costs
    local ShardCostArray = {}
local recipeGPCost = SkillData.Summoning.RecipeGPCost
    for j, cost in Shared.skpairs(Fam.summoningReq[1]) do
if Fam.gpCost > 0 then
      if cost.id >= 0 then
table.insert(OtherCostArray, Icons.GP(Fam.gpCost))
        local item = Items.getItemByID(cost.id)
end
        if item.type == 'Shard' then
if Fam.scCost > 0 then
          table.insert(ShardCostArray, Icons.Icon({item.name, type='item', notext=true, qty=cost.qty}))
table.insert(OtherCostArray, Icons.SC(Fam.scCost))
        end
end
      end
for j, nonShardID in ipairs(Fam.nonShardItemCosts) do
    end
local nonShard = Items.getItemByID(nonShardID)
    rowText = rowText..'||style="text-align:right"|'..table.concat(ShardCostArray, ', ')..'&nbsp;'
if nonShard ~= nil then
local itemValue = math.max(item.sellsFor, 20)
local nonShardQty = math.max(1, math.floor(recipeGPCost / itemValue))
table.insert(OtherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty}))
end
end
rowText = rowText..'||style="text-align:right"|'..table.concat(OtherCostArray, "<br/>'''OR''' ")


    --Now to get all the other cost options
rowText = rowText..'||style="text-align:right"|'..Fam.baseXP
    local OtherCostArray = {}
    local recipeGPCost = SkillData.Summoning.Settings.recipeGPCost
    for j, altCost in Shared.skpairs(Fam.summoningReq) do
      local nonShardArray = {}
      for k, cost in Shared.skpairs(altCost) do
        if cost.id >= 0 then
          local item = Items.getItemByID(cost.id)
          if item.type ~= 'Shard' then
            local sellPrice = item.sellsFor
            if sellPrice < 20 then sellPrice = 20 end
            table.insert(nonShardArray, Icons.Icon({item.name, type='item', notext=true, qty=math.max(1, math.floor(recipeGPCost / sellPrice))}))
          end
        else
          if cost.id == -4 then
            table.insert(nonShardArray, Icons.GP(recipeGPCost))
          elseif cost.id == -5 then
            table.insert(nonShardArray, Icons.SC(recipeGPCost))
          end
        end
      end
      table.insert(OtherCostArray, table.concat(nonShardArray, ', '))
    end
    rowText = rowText..'||style="text-align:right"|'..table.concat(OtherCostArray, "<br/>'''OR''' ")
 
    rowText = rowText..'||style="text-align:right"|'..(5 + 2 * math.floor(Fam.summoningLevel / 5))


    table.insert(rowArray, rowText)
    table.insert(rowArray, rowText)
end
   end
   end


Line 129: 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 161: Line 176:


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


         rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')
         rowText = rowText..'||data-sort-value="'..reqLvl..'"|'..table.concat(reqArray, '<br/>')
 
         table.insert(rowArray, rowText)
         table.insert(rowArray, rowText)
       end
       end
Line 291: Line 306:
   return p._getSkillSummoningBonusTable(skillName)
   return p._getSkillSummoningBonusTable(skillName)
end
end
--]==]


return p
return p