17,101
edits
(_getPetSource: Add override for Mark) |
(Implement _getPetSkill(); Amend getPetTable()/getPetTableBySkill() to handle multiple pets) |
||
Line 31: | Line 31: | ||
--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) | |||
break | break | ||
end | end | ||
Line 58: | Line 59: | ||
local newPet = Shared.clone(pet) | local newPet = Shared.clone(pet) | ||
newPet.id = i - 1 | newPet.id = i - 1 | ||
newPet.skill = p._getPetSkill(newPet) | |||
table.insert(result, newPet) | table.insert(result, newPet) | ||
end | end | ||
Line 118: | Line 120: | ||
end | end | ||
function p. | function p._getPetSkill(pet) | ||
local | local skillOverrides = { | ||
['Ty'] = -1, | |||
local | ['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, '|[[' .. pet.name .. ']]') | |||
table.insert(resultPart, '| ' .. p._getPetEffect(pet)) | |||
end | |||
table.insert(resultPart, '|}') | |||
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 = Skills.getSkillID(skillName) | |||
return p. | 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 | end | ||
Line 212: | Line 247: | ||
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%"' | ||
Line 221: | Line 256: | ||
local otherPetList = {} | local otherPetList = {} | ||
for i, petData in Shared.skpairs(PetData.Pets) do | for i, petData in Shared.skpairs(PetData.Pets) do | ||
if petData | 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 |