Module:Monsters: Difference between revisions

getMonsterDrops: Amend display of very small chances
(getMonsterPassives: Improve passive ability detection further)
(getMonsterDrops: Amend display of very small chances)
Line 737: Line 737:
--Getting the drop chance
--Getting the drop chance
local dropChance = (row[2] / totalWt * lootChance)
local dropChance = (row[2] / totalWt * lootChance)
if dropChance ~= 100 then
if dropChance < 100 then
--Show fraction as long as it isn't going to be 1/1
--Show fraction as long as it isn't going to be 1/1
result = result..'||style="text-align:right" data-sort-value="'..row[2]..'"'
result = result..'||style="text-align:right" data-sort-value="'..row[2]..'"'
Line 745: Line 745:
result = result..'||colspan="2" data-sort-value="'..row[2]..'"'
result = result..'||colspan="2" data-sort-value="'..row[2]..'"'
end
end
result = result..'style="text-align:right"|'..Shared.round(dropChance, 2, 2)..'%'
-- If chance is less than 0.10% then show 2 significant figures, otherwise 2 decimal places
local fmt = (dropChance < 0.10 and '%.2g') or '%.2f'
result = result..'style="text-align:right"|'..string.format(fmt, dropChance)..'%'


--Adding to the average loot value based on price & dropchance
--Adding to the average loot value based on price & dropchance