Anonymous

Module:CombatAreas/AreaTables: Difference between revisions

From Melvor Idle
getSlayerAreaTable: Fix area effect descriptions; Use in-game display order for all zone tables
(_getDungeonRewards: Safely handle cases where boss monsters have no loot table)
(getSlayerAreaTable: Fix area effect descriptions; Use in-game display order for all zone tables)
Line 30: Line 30:
   result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Lowest Monster Level!!Highest Monster Level'
   result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Lowest Monster Level!!Highest Monster Level'


  local combatAreas = Shared.clone(AreaData.combatAreas)
   for i, area in ipairs(AreaData.combatAreas) do
  table.sort(combatAreas, function(a, b)
              if a.difficulty[1] ~= b.difficulty[1] then
                return a.difficulty[1] < b.difficulty[1]
              elseif a.difficulty[2] == nil then
                return true
              elseif b.difficulty[2] == nil then
                return false
              elseif a.difficulty[2] ~= b.difficulty[2] then
                return a.difficulty[2] < b.difficulty[2]
              else
                return a.name < b.name
              end
            end)
 
   for i, area in Shared.skpairs(combatAreas) do
     result = result..'\r\n|-'
     result = result..'\r\n|-'
     result = result..'\r\n|'..Icons.Icon({area.name, type='combat', size='50', notext=true})
     result = result..'\r\n|'..Icons.Icon({area.name, type='combat', size='50', notext=true})
Line 67: Line 52:
   result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Highest Monster Level!!Requirements!!Area Effect'
   result = result..'\r\n!colspan="2"|Zone!!Difficulty!!Highest Monster Level!!Requirements!!Area Effect'


  local slayerAreas = Shared.clone(AreaData.slayerAreas)
   for i, area in ipairs(AreaData.slayerAreas) do
  table.sort(slayerAreas, function(a, b)
              if a.difficulty[1] ~= b.difficulty[1] then
                return a.difficulty[1] < b.difficulty[1]
              elseif a.difficulty[2] == nil then
                return true
              elseif b.difficulty[2] == nil then
                return false
              elseif a.difficulty[2] ~= b.difficulty[2] then
                return a.difficulty[2] < b.difficulty[2]
              else
                return a.name < b.name
              end
            end)
 
   for i, area in Shared.skpairs(slayerAreas) do
     result = result..'\r\n|-'
     result = result..'\r\n|-'
     result = result..'\r\n|'..Icons.Icon({area.name, type='slayer', size='50', notext=true})
     result = result..'\r\n|'..Icons.Icon({area.name, type='slayer', size='50', notext=true})
Line 96: Line 66:
     result = result..'||'
     result = result..'||'
     if area.areaEffectDescription ~= nil then
     if area.areaEffectDescription ~= nil then
       result = result..area.areaEffectDescription
       result = result .. string.gsub(area.areaEffectDescription, '${effectValue}', area.areaEffectValue or 0)
     end
     end
   end
   end
Line 159: Line 129:


function p.getDungeonTable(frame)
function p.getDungeonTable(frame)
  local dungeons = CombatAreas.getAreas(function(area) return area.type == 'dungeon' end)
   local result = '{| class="wikitable sortable stickyHeader"'
   local 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"|Dungeon!!Difficulty!!Monsters!!Boss Level!!Reward(s)!!Boss Pet'
   result = result..'\r\n!colspan="2"|Dungeon!!Difficulty!!Monsters!!Boss Level!!Reward(s)!!Boss Pet'
    
    
  table.sort(dungeons, function(a, b)
   for i, dung in ipairs(AreaData.dungeons) do
                      if a.difficulty[1] ~= b.difficulty[1] then
                        return a.difficulty[1] < b.difficulty[1]
                      else
                        return a.id < b.id
                      end end)
   for i, dung in Shared.skpairs(dungeons) do
     result = result..'\r\n|-'
     result = result..'\r\n|-'
     result = result..'\r\n|data-sort-value="'..dung.name..'"|'..Icons.Icon({dung.name, type='dungeon', size='50', notext=true})
     result = result..'\r\n|data-sort-value="'..dung.name..'"|'..Icons.Icon({dung.name, type='dungeon', size='50', notext=true})