17,428
edits
m (Amend odd indentation) |
(Ensure consistent pet drop chance logic by creating _getPetChance()) |
||
Line 81: | Line 81: | ||
end | end | ||
end | end | ||
if useIcon then | if useIcon then | ||
petSource = Icons.Icon({petSource, type=iconType}) | petSource = Icons.Icon({petSource, type=iconType}) | ||
Line 115: | Line 115: | ||
end | end | ||
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' | |||
else | |||
-- Skill pet or other | |||
return 'See: [[Pets#Acquiring Pets|Acquiring Pets]]' | |||
end | |||
end | end | ||
Line 174: | Line 193: | ||
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) | |||
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| ' | ||
Line 234: | Line 243: | ||
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/>".. | |||
end | end | ||