Anonymous

Module:Pets: Difference between revisions

From Melvor Idle
Added new getPets function for use in the new ModifierTables module that's in progress
(Added p.getDungeonBoxPetText)
(Added new getPets function for use in the new ModifierTables module that's in progress)
(3 intermediate revisions by the same user not shown)
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 183: Line 195:
   local pet = p.getPetByID(dung.petID)
   local pet = p.getPetByID(dung.petID)
   if pet ~= nil then
   if pet ~= nil then
     result = "\r\n|-\r\n|'''Pet:'''<br/>"
     result = "\r\n|-\r\n|'''[[Pets#Boss Pets|Pet]]:'''<br/>"
     result = result..Icons.Icon({pet.name, type='pet'})
     result = result..Icons.Icon({pet.name, type='pet'})


     local odds = pet.obtained.dungeonCompletion[1][2]
     local dropChance = ''
    local dropChance = '1 in '..odds..' ('..Shared.round(100 / odds, 2, 2)..'%)'
    if dung.name == 'Into the Mist' then
     result = result.."<br/>Drop Chance: "..dropChance
      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
   end