Module:Pets: Difference between revisions

From Melvor Idle
m (Add links)
(Use tabs instead of spaces for indentation)
Line 12: Line 12:


function p.getPetByID(ID)
function p.getPetByID(ID)
  local result = Shared.clone(PetData.Pets[ID + 1])
local result = Shared.clone(PetData.Pets[ID + 1])
  if result ~= nil then
if result ~= nil then
    result.id = ID
result.id = ID
  end
end
  return result
return result
end
end


function p.getPet(name)
function p.getPet(name)
  local result = nil
local result = nil
  name = string.gsub(name, "%%27", "'")
name = string.gsub(name, "%%27", "'")
  name = string.gsub(name, "'", "'")
name = string.gsub(name, "'", "'")
  name = string.gsub(name, "'", "'")
name = string.gsub(name, "'", "'")
  for i, pet in pairs(PetData.Pets) do
for i, pet in pairs(PetData.Pets) do
    local PetName = string.gsub(pet.name, '#', '')
local PetName = string.gsub(pet.name, '#', '')
    if(name == PetName) then
if name == PetName then
      result = Shared.clone(pet)
result = Shared.clone(pet)
      --Make sure every pet has an id, and account for Lua being 1-index
--Make sure every pet has an id, and account for Lua being 1-index
      result.id = i - 1
result.id = i - 1
      result.skill = p._getPetSkill(result)
result.skill = p._getPetSkill(result)
      break
break
    end
end
  end
end
  return result
return result
end
end


function p.getPets(checkFunc)
function p.getPets(checkFunc)
  local result = {}
local result = {}
  for i, pet in Shared.skpairs(PetData.Pets) do
for i, pet in Shared.skpairs(PetData.Pets) do
    if checkFunc(pet) then
if checkFunc(pet) then
      local newPet = Shared.clone(pet)
local newPet = Shared.clone(pet)
      newPet.id = i - 1
newPet.id = i - 1
      newPet.skill = p._getPetSkill(newPet)
newPet.skill = p._getPetSkill(newPet)
      table.insert(result, newPet)
table.insert(result, newPet)
    end
end
  end
end
  return result
return result
end
end


function p._getPetSource(pet)
function p._getPetSource(pet)
  local sourceOverrides = {
local sourceOverrides = {
    -- Format: ['PetName'] = {'Source', UseIcon}
-- Format: ['PetName'] = {'Source', UseIcon}
    -- UseIcon = true if Source has an associated icon, false otherwise
-- UseIcon = true if Source has an associated icon, false otherwise
    ['Asura'] = {'Slayer', true},
['Asura'] = {'Slayer', true},
    ['Ripper the Reindeer'] = {'[[Events#Christmas_Event_2020|Christmas Event 2020]]', false},
['Ripper the Reindeer'] = {'[[Events#Christmas_Event_2020|Christmas Event 2020]]', false},
    ['Festive Chio'] = {'[[Holiday Event 2021]]'},
['Festive Chio'] = {'[[Holiday Event 2021]]'},
    ['Festive Cool Rock'] = {'[[Holiday Event 2021]]'},
['Festive Cool Rock'] = {'[[Holiday Event 2021]]'},
    ['Jerry the Giraffe'] = {'[[Golbin Raid|Golbin Raid Shop]]', false},
['Jerry the Giraffe'] = {'[[Golbin Raid|Golbin Raid Shop]]', false},
    ['Preston the Platypus'] = {'[[Golbin Raid|Golbin Raid Shop]]', false},
['Preston the Platypus'] = {'[[Golbin Raid|Golbin Raid Shop]]', false},
    ['Mark'] = {'Summoning', true},
['Mark'] = {'Summoning', true},
    ['Bone'] = {'Impending Darkness Event', true}
['Bone'] = {'Impending Darkness Event', true}
  }
}
  local petSource = ''
local petSource = ''
  local useIcon = true
local useIcon = true
  local override = sourceOverrides[pet.name]
local override = sourceOverrides[pet.name]
  if override ~= nil then
if override ~= nil then
    petSource = override[1] ~= nil and override[1] or pet.acquiredBy
petSource = override[1] ~= nil and override[1] or pet.acquiredBy
    useIcon = override[2]
useIcon = override[2]
  elseif pet.acquiredBy ~= nil then
elseif pet.acquiredBy ~= nil then
    petSource = pet.acquiredBy
petSource = pet.acquiredBy
  end
end


  -- Determine icon type (if any)
-- Determine icon type (if any)
  local iconType = nil
local iconType = nil
  if Constants.getSkillID(petSource) ~= nil then
if Constants.getSkillID(petSource) ~= nil then
    iconType = 'skill'
iconType = 'skill'
  else
else
    local combatArea = CombatAreas.getArea(petSource)
local combatArea = CombatAreas.getArea(petSource)
    if combatArea ~= nil then
if combatArea ~= nil then
      iconType = combatArea.type
iconType = combatArea.type
    end
end
  end
end


  if useIcon then
if useIcon then
    petSource = Icons.Icon({petSource, type=iconType})
petSource = Icons.Icon({petSource, type=iconType})
  end
end
  return petSource
return petSource
end
end


function p._getPetEffect(pet)
function p._getPetEffect(pet)
  local effectOverrides = {
local effectOverrides = {
    ['Ripper the Reindeer'] = 'None',
['Ripper the Reindeer'] = 'None',
  }
}
  if effectOverrides[pet.name] ~= nil then
if effectOverrides[pet.name] ~= nil then
    return effectOverrides[pet.name]
return effectOverrides[pet.name]
  else
else
  local modKeys = {'modifiers', 'enemyModifiers'}
local modKeys = {'modifiers', 'enemyModifiers'}
  local effects = {}
local effects = {}
  for i, key in ipairs(modKeys) do
for i, key in ipairs(modKeys) do
    if pet[key] ~= nil and Shared.tableCount(pet[key]) > 0 then
if pet[key] ~= nil and Shared.tableCount(pet[key]) > 0 then
    for effectName, effectValue in pairs(pet[key]) do
for effectName, effectValue in pairs(pet[key]) do
      local preText = (key == 'enemyModifiers' and 'All enemies have: ' or '')
local preText = (key == 'enemyModifiers' and 'All enemies have: ' or '')
      table.insert(effects, preText .. Constants._getModifierText(effectName, effectValue, false))
table.insert(effects, preText .. Constants._getModifierText(effectName, effectValue, false))
    end
end
    end
end
  end
end
  if Shared.tableCount(effects) > 0 then
if Shared.tableCount(effects) > 0 then
    return table.concat(effects, '<br/>')
return table.concat(effects, '<br/>')
  elseif pet.skill ~= nil and pet.skill >= 0 then
elseif pet.skill ~= nil and pet.skill >= 0 then
    -- Attempt to remove skill prefix from description
-- Attempt to remove skill prefix from description
    local newDesc, subIdx = string.gsub(pet.description, '^' .. Constants.getSkillName(pet.skill) .. '<br>', '')
local newDesc, subIdx = string.gsub(pet.description, '^' .. Constants.getSkillName(pet.skill) .. '<br>', '')
    return newDesc
return newDesc
  else
else
    return pet.description
return pet.description
  end
end
  end
end
end
end


function p._getPetChance(pet)
function p._getPetChance(pet)
    if pet.obtained ~= nil and pet.obtained.dungeonCompletion ~= nil then
if pet.obtained ~= nil and pet.obtained.dungeonCompletion ~= nil then
        local odds = pet.obtained.dungeonCompletion[1][2]
local odds = pet.obtained.dungeonCompletion[1][2]
        if pet.name == 'Pablo' then
if pet.name == 'Pablo' then
            -- Special handling for Into the Mist/Pablo
-- Special handling for Into the Mist/Pablo
            return 'Guaranteed after ' .. odds .. ' clears'
return 'Guaranteed after ' .. odds .. ' clears'
        else
else
            -- Dungeon pet
-- Dungeon pet
            return '1 in ' .. odds .. ' (' .. Shared.round(100 / odds, 2, 2) .. '%)'
return '1 in ' .. odds .. ' (' .. Shared.round(100 / odds, 2, 2) .. '%)'
        end
end
    elseif pet.name == 'Bone' then
elseif pet.name == 'Bone' then
        -- Special handling for Impending Darkness/Bone
-- Special handling for Impending Darkness/Bone
return 'Guaranteed after 1 clear'
return 'Guaranteed after 1 clear'
    elseif pet.name == 'Peri' or pet.name == 'Otto' then
elseif pet.name == 'Peri' or pet.name == 'Otto' then
-- Slayer area pets
-- Slayer area pets
local odds = 7500
local odds = 7500
return '1 in ' .. odds .. ' (' .. Shared.round(100 / odds, 2, 2) .. '%)'
return '1 in ' .. odds .. ' (' .. Shared.round(100 / odds, 2, 2) .. '%)'
    else
else
        -- Skill pet or other
-- Skill pet or other
        return 'See: [[Pets#Acquiring Pets|Acquiring Pets]]'
return 'See: [[Pets#Acquiring Pets|Acquiring Pets]]'
    end
end
end
end


function p._getPetSkill(pet)
function p._getPetSkill(pet)
  local skillOverrides = {
local skillOverrides = {
    ['Ty'] = -1,
['Ty'] = -1,
    ['Mark'] = 21
['Mark'] = 21
  }
}


  local skillID = pet.skill
local skillID = pet.skill
  if skillOverrides[pet.name] ~= nil then
if skillOverrides[pet.name] ~= nil then
    skillID = skillOverrides[pet.name]
skillID = skillOverrides[pet.name]
  end
end
  if skillID < 0 then
if skillID < 0 then
    return nil
return nil
  else
else
    return skillID
return skillID
  end
end
end
end


function p._getPetTable(pets)
function p._getPetTable(pets)
  if pets == nil or Shared.tableCount(pets) == 0 then return nil end
if pets == nil or Shared.tableCount(pets) == 0 then return nil end


  local resultPart = {}
local resultPart = {}
  table.insert(resultPart, '{| class="wikitable"\r\n!Pet!!Name!!Effect')
table.insert(resultPart, '{| class="wikitable"\r\n!Pet!!Name!!Effect')


  for i, pet in pairs(pets) do
for i, pet in pairs(pets) do
    table.insert(resultPart, '|-')
table.insert(resultPart, '|-')
    table.insert(resultPart, '|style="text-align: center;"|' .. Icons.Icon({pet.name, type='pet', size=60, notext=true}))
table.insert(resultPart, '|style="text-align: center;"|' .. Icons.Icon({pet.name, type='pet', size=60, notext=true}))
    table.insert(resultPart, '|' .. Icons.Icon({pet.name, type='pet', noicon=true}))
table.insert(resultPart, '|' .. Icons.Icon({pet.name, type='pet', noicon=true}))
    table.insert(resultPart, '| ' .. p._getPetEffect(pet))
table.insert(resultPart, '| ' .. p._getPetEffect(pet))
  end
end
  table.insert(resultPart, '|}')
table.insert(resultPart, '|}')


  return table.concat(resultPart, '\r\n')
return table.concat(resultPart, '\r\n')
end
end


function p.getPetTableBySkill(frame)
function p.getPetTableBySkill(frame)
  local skillName = frame.args ~= nil and frame.args[1] or frame
local skillName = frame.args ~= nil and frame.args[1] or frame
  local skillID = Constants.getSkillID(skillName)
local skillID = Constants.getSkillID(skillName)


  if skillID == nil then
if skillID == nil then
    return ''
return ''
  else
else
    local pets = p.getPets(function(pet) return p._getPetSkill(pet) == skillID end)
local pets = p.getPets(function(pet) return p._getPetSkill(pet) == skillID end)
    if pets == nil then
if pets == nil then
      return ''
return ''
    else
else
      return p._getPetTable(pets)
return p._getPetTable(pets)
    end
end
  end
end
end
end


function p.getPetSidebar(frame)
function p.getPetSidebar(frame)
  local args = frame.args ~= nil and frame.args or frame
local args = frame.args ~= nil and frame.args or frame
  local result = nil
local result = nil
  local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
  local pet = p.getPet(name)
local pet = p.getPet(name)
  local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or p._getPetEffect(pet)
local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or p._getPetEffect(pet)
  local completionReq = (pet.ignoreCompletion ~= nil and pet.ignoreCompletion) and 'No' or 'Yes'
local completionReq = (pet.ignoreCompletion ~= nil and pet.ignoreCompletion) and 'No' or 'Yes'
  local dropChance = p._getPetChance(pet)
local dropChance = p._getPetChance(pet)


  result = '{| class="wikitable" style="float:right; clear:right;"\r\n|-\r\n'
result = '{| class="wikitable" style="float:right; clear:right;"\r\n|-\r\n'
  result = result..'! '..name..'\r\n|-\r\n| '
result = result..'! '..name..'\r\n|-\r\n| '
  result = result..'style="text-align: center;"|' .. Icons.Icon({name, type='pet', size='250', notext=true})
result = result..'style="text-align: center;"|' .. Icons.Icon({name, type='pet', size='250', notext=true})
  result = result.."\r\n|-\r\n|'''Pet ID:''' "..pet.id
result = result.."\r\n|-\r\n|'''Pet ID:''' "..pet.id
  result = result.."\r\n|-\r\n|'''Source:''' "..p._getPetSource(pet)
result = result.."\r\n|-\r\n|'''Source:''' "..p._getPetSource(pet)
  if dropChance ~= nil then
if dropChance ~= nil then
    result = result.."\r\n|-\r\n|'''Drop Chance:''' "..dropChance
result = result.."\r\n|-\r\n|'''Drop Chance:''' "..dropChance
  end
end
  result = result.."\r\n|-\r\n| style =\"width: 250px;\"|'''Effect:''' "..effect
result = result.."\r\n|-\r\n| style =\"width: 250px;\"|'''Effect:''' "..effect
  result = result .. "\r\n|-\r\n|'''Part of 100% Completion:''' " .. completionReq .. "\r\n|}"
result = result .. "\r\n|-\r\n|'''Part of 100% Completion:''' " .. completionReq .. "\r\n|}"


  return result
return result
end
end


function p.getPetPageTable()
function p.getPetPageTable()
  local result = ''
local result = ''
  local petList = Shared.clone(PetData.Pets)
local petList = Shared.clone(PetData.Pets)


  result = '{|class="wikitable sortable lighttable stickyHeader"'
result = '{|class="wikitable sortable lighttable stickyHeader"'
  result = result..'\r\n|- class="headerRow-0"\r\n! Name !! Image !! Acquired From !! Effect'
result = result..'\r\n|- class="headerRow-0"\r\n! Name !! Image !! Acquired From !! Effect'


  table.sort(petList, function(a, b)
table.sort(petList, function(a, b)
                        return p.getPet(a.name).id < p.getPet(b.name).id
return p.getPet(a.name).id < p.getPet(b.name).id
                      end)
end)


  for i, thisPet in pairs(petList) do
for i, thisPet in pairs(petList) do
    result = result..'\r\n|-\r\n|'..Icons.Icon({thisPet.name, type='pet', noicon=true})
result = result..'\r\n|-\r\n|'..Icons.Icon({thisPet.name, type='pet', noicon=true})
    result = result..'||style="text-align: center;"|'..Icons.Icon({thisPet.name, size='60', type='pet', notext=true})
result = result..'||style="text-align: center;"|'..Icons.Icon({thisPet.name, size='60', type='pet', notext=true})
    result = result..'||'..p._getPetSource(thisPet)
result = result..'||'..p._getPetSource(thisPet)
    result = result..'||'..p._getPetEffect(thisPet)
result = result..'||'..p._getPetEffect(thisPet)
  end
end
  result = result..'\r\n|}'
result = result..'\r\n|}'


  return result
return result
end
end


function p.getDungeonBoxPetText(frame)
function p.getDungeonBoxPetText(frame)
  local dungeonName = frame.args ~= nil and frame.args[1] or frame
local dungeonName = frame.args ~= nil and frame.args[1] or frame
  local dung = CombatAreas.getArea(dungeonName)
local dung = CombatAreas.getArea(dungeonName)
  if dung == nil then
if dung == nil then
    return 'ERROR: Invalid dungeon name '..dungeonName..'[[Category:Pages with script errors]]'
return 'ERROR: Invalid dungeon name '..dungeonName..'[[Category:Pages with script errors]]'
  end
end


  local result = ''
local result = ''
  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|'''[[Pets#Boss Pets|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'})
    result = result.."\r\n|-\r\n|'''Pet Drop Chance:'''<br/>"..p._getPetChance(pet)
result = result.."\r\n|-\r\n|'''Pet Drop Chance:'''<br/>"..p._getPetChance(pet)
  end
end


  return result
return result
end
end


function p.getPetNavbox()
function p.getPetNavbox()
  --•
--•
  local result = '{| class="wikitable" style="margin:auto; text-align:center; clear:both; width: 100%"'
local result = '{| class="wikitable" style="margin:auto; text-align:center; clear:both; width: 100%"'
  result = result..'\r\n|-\r\n!colspan="2"|[[Pets]]'
result = result..'\r\n|-\r\n!colspan="2"|[[Pets]]'


  local skillPetList = {}
local skillPetList = {}
  local bossPetList = {}
local bossPetList = {}
  local otherPetList = {}
local otherPetList = {}
  for i, petData in Shared.skpairs(PetData.Pets) do
for i, petData in Shared.skpairs(PetData.Pets) do
    if p._getPetSkill(petData) ~= nil then
if p._getPetSkill(petData) ~= nil then
      table.insert(skillPetList, Icons.Icon({petData.name, type='pet'}))
table.insert(skillPetList, Icons.Icon({petData.name, type='pet'}))
    elseif petData.obtained ~= nil and petData.obtained.dungeonCompletion ~= nil then
elseif petData.obtained ~= nil and petData.obtained.dungeonCompletion ~= nil then
      table.insert(bossPetList, Icons.Icon({petData.name, type='pet'}))
table.insert(bossPetList, Icons.Icon({petData.name, type='pet'}))
    else
else
      table.insert(otherPetList, Icons.Icon({petData.name, type='pet'}))
table.insert(otherPetList, Icons.Icon({petData.name, type='pet'}))
    end
end
  end
end
  table.sort(skillPetList, function(a, b) return a < b end)
table.sort(skillPetList, function(a, b) return a < b end)
  table.sort(bossPetList, function(a, b) return a < b end)
table.sort(bossPetList, function(a, b) return a < b end)
  table.sort(otherPetList, function(a, b) return a < b end)
table.sort(otherPetList, function(a, b) return a < b end)
  result = result..'\r\n|-\r\n!Skill Pets\r\n|'..table.concat(skillPetList, ' • ')
result = result..'\r\n|-\r\n!Skill Pets\r\n|'..table.concat(skillPetList, ' • ')
  result = result..'\r\n|-\r\n!Boss Pets\r\n|'..table.concat(bossPetList, ' • ')
result = result..'\r\n|-\r\n!Boss Pets\r\n|'..table.concat(bossPetList, ' • ')
  result = result..'\r\n|-\r\n!Other Pets\r\n|'..table.concat(otherPetList, ' • ')
result = result..'\r\n|-\r\n!Other Pets\r\n|'..table.concat(otherPetList, ' • ')
  result = result..'\r\n|}'
result = result..'\r\n|}'
  return result
return result
end
end


return p
return p

Revision as of 23:20, 7 January 2022

Data for this page is stored in Module:GameData/data


--This module contains all sorts of functions for getting data on pets

local p = {}

local PetData = mw.loadData('Module:Pets/data')

local Shared = require( "Module:Shared" )
local Constants = require('Module:Constants')
local Icons = require('Module:Icons')
local CombatAreas = require('Module:CombatAreas')


function p.getPetByID(ID)
	local result = Shared.clone(PetData.Pets[ID + 1])
	if result ~= nil then
		result.id = ID
	end
	return result
end

function p.getPet(name)
	local result = nil
	name = string.gsub(name, "%%27", "&apos;")
	name = string.gsub(name, "'", "&apos;")
	name = string.gsub(name, "&#39;", "&apos;")
	for i, pet in pairs(PetData.Pets) do
		local PetName = string.gsub(pet.name, '#', '')
		if name == PetName then
			result = Shared.clone(pet)
			--Make sure every pet has an id, and account for Lua being 1-index
			result.id = i - 1
			result.skill = p._getPetSkill(result)
			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
			newPet.skill = p._getPetSkill(newPet)
			table.insert(result, newPet)
		end
	end
	return result
end

function p._getPetSource(pet)
	local sourceOverrides = {
		-- Format: ['PetName'] = {'Source', UseIcon}
		-- UseIcon = true if Source has an associated icon, false otherwise
		['Asura'] = {'Slayer', true},
		['Ripper the Reindeer'] = {'[[Events#Christmas_Event_2020|Christmas Event 2020]]', false},
		['Festive Chio'] = {'[[Holiday Event 2021]]'},
		['Festive Cool Rock'] = {'[[Holiday Event 2021]]'},
		['Jerry the Giraffe'] = {'[[Golbin Raid|Golbin Raid Shop]]', false},
		['Preston the Platypus'] = {'[[Golbin Raid|Golbin Raid Shop]]', false},
		['Mark'] = {'Summoning', true},
		['Bone'] = {'Impending Darkness Event', true}
	}
	local petSource = ''
	local useIcon = true
	local override = sourceOverrides[pet.name]
	if override ~= nil then
		petSource = override[1] ~= nil and override[1] or pet.acquiredBy
		useIcon = override[2]
	elseif pet.acquiredBy ~= nil then
		petSource = pet.acquiredBy
	end

	-- Determine icon type (if any)
	local iconType = nil
	if Constants.getSkillID(petSource) ~= nil then
		iconType = 'skill'
	else
		local combatArea = CombatAreas.getArea(petSource)
		if combatArea ~= nil then
			iconType = combatArea.type
		end
	end

	if useIcon then
		petSource = Icons.Icon({petSource, type=iconType})
	end
	return petSource
end

function p._getPetEffect(pet)
	local effectOverrides = {
		['Ripper the Reindeer'] = 'None',
	}
	if effectOverrides[pet.name] ~= nil then
		return effectOverrides[pet.name]
	else
		local modKeys = {'modifiers', 'enemyModifiers'}
		local effects = {}
		for i, key in ipairs(modKeys) do
			if pet[key] ~= nil and Shared.tableCount(pet[key]) > 0 then
				for effectName, effectValue in pairs(pet[key]) do
					local preText = (key == 'enemyModifiers' and 'All enemies have: ' or '')
					table.insert(effects, preText .. Constants._getModifierText(effectName, effectValue, false))
				end
			end
		end
		if Shared.tableCount(effects) > 0 then
			return table.concat(effects, '<br/>')
		elseif pet.skill ~= nil and pet.skill >= 0 then
			-- Attempt to remove skill prefix from description
			local newDesc, subIdx = string.gsub(pet.description, '^' .. Constants.getSkillName(pet.skill) .. '<br>', '')
			return newDesc
		else
			return pet.description
		end
	end
end

function p._getPetChance(pet)
	if pet.obtained ~= nil and pet.obtained.dungeonCompletion ~= nil then
		local odds = pet.obtained.dungeonCompletion[1][2]
		if pet.name == 'Pablo' then
			-- Special handling for Into the Mist/Pablo
			return 'Guaranteed after ' .. odds .. ' clears'
		else
			-- Dungeon pet
			return '1 in ' .. odds .. ' (' .. Shared.round(100 / odds, 2, 2) .. '%)'
		end
	elseif pet.name == 'Bone' then
		-- Special handling for Impending Darkness/Bone
		return 'Guaranteed after 1 clear'
	elseif pet.name == 'Peri' or pet.name == 'Otto' then
		-- Slayer area pets
		local odds = 7500
		return '1 in ' .. odds .. ' (' .. Shared.round(100 / odds, 2, 2) .. '%)'
	else
		-- Skill pet or other
		return 'See: [[Pets#Acquiring Pets|Acquiring Pets]]'
	end
end

function p._getPetSkill(pet)
	local skillOverrides = {
		['Ty'] = -1,
		['Mark'] = 21
	}

	local skillID = pet.skill
	if skillOverrides[pet.name] ~= nil then
		skillID = skillOverrides[pet.name]
	end
	if skillID < 0 then
		return nil
	else
		return skillID
	end
end

function p._getPetTable(pets)
	if pets == nil or Shared.tableCount(pets) == 0 then return nil end

	local resultPart = {}
	table.insert(resultPart, '{| class="wikitable"\r\n!Pet!!Name!!Effect')

	for i, pet in pairs(pets) do
		table.insert(resultPart, '|-')
		table.insert(resultPart, '|style="text-align: center;"|' .. Icons.Icon({pet.name, type='pet', size=60, notext=true}))
		table.insert(resultPart, '|' .. Icons.Icon({pet.name, type='pet', noicon=true}))
		table.insert(resultPart, '| ' .. p._getPetEffect(pet))
	end
	table.insert(resultPart, '|}')

	return table.concat(resultPart, '\r\n')
end

function p.getPetTableBySkill(frame)
	local skillName = frame.args ~= nil and frame.args[1] or frame
	local skillID = Constants.getSkillID(skillName)

	if skillID == nil then
		return ''
	else
		local pets = p.getPets(function(pet) return p._getPetSkill(pet) == skillID end)
		if pets == nil then
			return ''
		else
			return p._getPetTable(pets)
		end
	end
end

function p.getPetSidebar(frame)
	local args = frame.args ~= nil and frame.args or frame
	local result = nil
	local name = (args.name ~= nil and args.name ~= '') and args.name or args[1]
	local pet = p.getPet(name)
	local effect = (args.effect ~= nil and args.effect ~= '') and args.effect or p._getPetEffect(pet)
	local completionReq = (pet.ignoreCompletion ~= nil and pet.ignoreCompletion) and 'No' or 'Yes'
	local dropChance = p._getPetChance(pet)

	result = '{| class="wikitable" style="float:right; clear:right;"\r\n|-\r\n'
	result = result..'! '..name..'\r\n|-\r\n| '
	result = result..'style="text-align: center;"|' .. Icons.Icon({name, type='pet', size='250', notext=true})
	result = result.."\r\n|-\r\n|'''Pet ID:''' "..pet.id
	result = result.."\r\n|-\r\n|'''Source:''' "..p._getPetSource(pet)
	if dropChance ~= nil then
		result = result.."\r\n|-\r\n|'''Drop Chance:''' "..dropChance
	end
	result = result.."\r\n|-\r\n| style =\"width: 250px;\"|'''Effect:''' "..effect
	result = result .. "\r\n|-\r\n|'''Part of 100% Completion:''' " .. completionReq .. "\r\n|}"

	return result
end

function p.getPetPageTable()
	local result = ''
	local petList = Shared.clone(PetData.Pets)

	result = '{|class="wikitable sortable lighttable stickyHeader"'
	result = result..'\r\n|- class="headerRow-0"\r\n! Name !! Image !! Acquired From !! Effect'

	table.sort(petList, function(a, b)
		return p.getPet(a.name).id < p.getPet(b.name).id
	end)

	for i, thisPet in pairs(petList) do
		result = result..'\r\n|-\r\n|'..Icons.Icon({thisPet.name, type='pet', noicon=true})
		result = result..'||style="text-align: center;"|'..Icons.Icon({thisPet.name, size='60', type='pet', notext=true})
		result = result..'||'..p._getPetSource(thisPet)
		result = result..'||'..p._getPetEffect(thisPet)
	end
	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'})
		result = result.."\r\n|-\r\n|'''Pet Drop Chance:'''<br/>"..p._getPetChance(pet)
	end

	return result
end

function p.getPetNavbox()
	--•
	local result = '{| class="wikitable" style="margin:auto; text-align:center; clear:both; width: 100%"'
	result = result..'\r\n|-\r\n!colspan="2"|[[Pets]]'

	local skillPetList = {}
	local bossPetList = {}
	local otherPetList = {}
	for i, petData in Shared.skpairs(PetData.Pets) do
		if p._getPetSkill(petData) ~= nil then
			table.insert(skillPetList, Icons.Icon({petData.name, type='pet'}))
		elseif petData.obtained ~= nil and petData.obtained.dungeonCompletion ~= nil then
			table.insert(bossPetList, Icons.Icon({petData.name, type='pet'}))
		else
			table.insert(otherPetList, Icons.Icon({petData.name, type='pet'}))
		end
	end
	table.sort(skillPetList, function(a, b) return a < b end)
	table.sort(bossPetList, function(a, b) return a < b end)
	table.sort(otherPetList, function(a, b) return a < b end)
	result = result..'\r\n|-\r\n!Skill Pets\r\n|'..table.concat(skillPetList, ' • ')
	result = result..'\r\n|-\r\n!Boss Pets\r\n|'..table.concat(bossPetList, ' • ')
	result = result..'\r\n|-\r\n!Other Pets\r\n|'..table.concat(otherPetList, ' • ')
	result = result..'\r\n|}'
	return result
end

return p