4,951
edits
(Create _getPetSource() & apply source/effect overrides consistently, resolves exception with getPetSidebar() for Golbin Raid pets) |
Falterfire (talk | contribs) (Added new getPets function for use in the new ModifierTables module that's in progress) |
||
(7 intermediate revisions by 2 users 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 | local CombatAreas = require('Module:CombatAreas') | ||
Line 41: | Line 41: | ||
local skillID = Skills.getSkillID(skillName) | local skillID = Skills.getSkillID(skillName) | ||
for i, pet in pairs(PetData.Pets) do | for i, pet in pairs(PetData.Pets) do | ||
if(skillID == pet.skill) then | --Deliberately excluding Ty. He knows what he did. | ||
if(skillID == pet.skill and pet.name ~= 'Ty') 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 | ||
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 75: | Line 88: | ||
iconType = 'skill' | iconType = 'skill' | ||
else | else | ||
local combatArea = | local combatArea = CombatAreas.getArea(petSource) | ||
if combatArea ~= nil then | if combatArea ~= nil then | ||
iconType = combatArea.type | iconType = combatArea.type | ||
Line 96: | 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. | table.insert(effects, Constants._getModifierText(effectName, effectValue, false)) | ||
end | end | ||
return table.concat(effects, '<br/>') | return table.concat(effects, '<br/>') | ||
Line 128: | Line 141: | ||
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 dropChance = nil | local dropChance = nil | ||
Line 138: | Line 152: | ||
result = result..'! '..name..'\r\n|-\r\n| ' | result = result..'! '..name..'\r\n|-\r\n| ' | ||
result = result..Icons.Icon({name, type='pet', size='250', notext=true}) | result = result..Icons.Icon({name, type='pet', size='250', notext=true}) | ||
result = result.. | result = result.."\r\n|-\r\n|'''Pet ID:''' "..pet.id | ||
result = result.."\r\n|-\r\n|'''Source:''' "..p._getPetSource(pet) | |||
result = result.. | |||
if dropChance ~= nil then | if dropChance ~= nil then | ||
result = result.. | result = result.."\r\n|-\r\n|'''Drop Chance:''' "..dropChance | ||
end | end | ||
result = result.."\r\n|-\r\n| style =\"width: 250px;\"|'''Effect:''' "..effect | |||
result = result.. | result = result .. "\r\n|-\r\n|'''Part of 100% Completion:''' " .. completionReq .. "\r\n|}" | ||
return result | return result | ||
Line 168: | 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 |