Anonymous

Module:Pets: Difference between revisions

From Melvor Idle
1,114 bytes added ,  22 April 2021
Added new getPets function for use in the new ModifierTables module that's in progress
(Fixing Ty showing up as the woodcutting pet)
(Added new getPets function for use in the new ModifierTables module that's in progress)
(5 intermediate revisions by the same user not shown)
Line 9: Line 9:
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local Zones = require('Module:CombatAreas')
local CombatAreas = require('Module:CombatAreas')




Line 47: Line 47:
       result.id = i - 1
       result.id = i - 1
       break
       break
    end
  end
  return result
end
function p.getPets(checkFunc)
  local result = {}
  for i, pet in Shared.skpairs(PetData.Pets) do
    if checkFunc(pet) then
      local newPet = Shared.clone(pet)
      newPet.id = i - 1
      table.insert(result, newPet)
     end
     end
   end
   end
Line 76: Line 88:
     iconType = 'skill'
     iconType = 'skill'
   else
   else
     local combatArea = Zones.getArea(petSource)
     local combatArea = CombatAreas.getArea(petSource)
     if combatArea ~= nil then
     if combatArea ~= nil then
       iconType = combatArea.type
       iconType = combatArea.type
Line 97: Line 109:
     local effects = {}
     local effects = {}
     for effectName, effectValue in pairs(pet.modifiers) do
     for effectName, effectValue in pairs(pet.modifiers) do
       table.insert(effects, Constants.getModifierText(effectName, effectValue, false))
       table.insert(effects, Constants._getModifierText(effectName, effectValue, false))
     end
     end
     return table.concat(effects, '<br/>')
     return table.concat(effects, '<br/>')
Line 169: Line 181:
   end
   end
   result = result..'\r\n|}'
   result = result..'\r\n|}'
  return result
end
function p.getDungeonBoxPetText(frame)
  local dungeonName = frame.args ~= nil and frame.args[1] or frame
  local dung = CombatAreas.getArea(dungeonName)
  if dung == nil then
    return 'ERROR: Invalid dungeon name '..dungeonName..'[[Category:Pages with script errors]]'
  end
  local result = ''
  local pet = p.getPetByID(dung.petID)
  if pet ~= nil then
    result = "\r\n|-\r\n|'''[[Pets#Boss Pets|Pet]]:'''<br/>"
    result = result..Icons.Icon({pet.name, type='pet'})
    local dropChance = ''
    if dung.name == 'Into the Mist' then
      dropChance = 'Guaranteed after 5 clears'
    else
      local odds = pet.obtained.dungeonCompletion[1][2]
      dropChance = '1 in '..odds..' ('..Shared.round(100 / odds, 2, 2)..'%)'
    end
    result = result.."\r\n|-\r\n|'''Pet Drop Chance:'''<br/>"..dropChance
  end


   return result
   return result