Anonymous

Module:CombatAreas: Difference between revisions

From Melvor Idle
Fixed an issue with getting difficulty not working when multiple difficulties were present
(Added p.getDungeonRequirements)
(Fixed an issue with getting difficulty not working when multiple difficulties were present)
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
--NOTE: Some tables are in Module:CombatAreas/AreaTables to prevent loop from referencing Monsters
local p = {}
local p = {}


local Constants = mw.loadData('Module:Constants/data')
local AreaData = mw.loadData('Module:CombatAreas/data')
local AreaData = mw.loadData('Module:CombatAreas/data')


local Constants = require('Module:Constants')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
Line 81: Line 82:
     if area.requiresCompletion ~= nil and area.requiresCompletion >= 0 then
     if area.requiresCompletion ~= nil and area.requiresCompletion >= 0 then
       local dung = p.getAreaByID('dungeon', area.requiresCompletion)
       local dung = p.getAreaByID('dungeon', area.requiresCompletion)
       return 'Completing '..Icons.Icon({dung.name, type='dungeon'})
       local compCount = area.requiresCompletionCount ~= nil and area.requiresCompletionCount or 1
      if compCount > 1 then
        return compCount..'x '..Icons.Icon({dung.name, type='dungeon'})..' Completions'
      else
        return Icons.Icon({dung.name, type='dungeon'})..' Completed'
      end
     else
     else
       return ''
       return ''
     end
     end
  elseif statName == 'areaEffectDesc' then
    if area.areaEffect ~= nil and area.areaEffect then
      return area.areaEffectDescription
    else
      return 'None'
    end
  elseif statName == 'difficulty' then
    local result = Constants.getDifficultyString(area.difficulty[1])
    if area.difficulty[2] ~= nil then
      result = result..' - '..Constants.getDifficultyString(area.difficulty[2])
    end
    return result
   end
   end


Line 116: Line 134:
   end
   end


   for i, area in pairs(AreaData.dungeons) do
   --Hill Giants specifically ignore dungeons to prevent the issue with Into the Mist incorrectly being listed.
    if Shared.contains(area.monsters, monsterID) then
  if monsterID ~= 1 then
      table.insert(areaArray, processArea(area, i, 'dungeon'))
    for i, area in pairs(AreaData.dungeons) do
      if Shared.contains(area.monsters, monsterID) then
        table.insert(areaArray, processArea(area, i, 'dungeon'))
      end
     end
     end
   end
   end
Line 133: Line 154:
   local result = p._getAreaStat(area, 'dungeonReq')
   local result = p._getAreaStat(area, 'dungeonReq')
   if result ~= '' then
   if result ~= '' then
     result = '\r\n|-\r\n|Requirements:<br/>'..result
     result = "\r\n|-\r\n|'''Requirements:'''<br/>"..result
   end
   end
   return result
   return result