-- rarity cell contents
local rare_class, rare_sort
if rarity_value ~== nilundefined then ▼
rare_class, rare_sort = unpack(rarities[rarity:lower()] or rarities._default)
if raritynotes and #raritynotes > 0 then
ifelseif type(rarity_value ) == 'number'false then ▼
-- If raritynotes is provided, only show the notes, skip rarity value
rare_class, rare_sort = unpack(rarities._default)
rarity_cell:wikitext(raritynotes)
else
-- If rarity_value is provided, calculate rare_sort and= fetch rare_class1/rarity_value
rare_class = get_rarity_class(rarity_value) ▼
▲ if rarity_value ~= nil then
rare_sort = 1 / rarity_value
local tilderollstext = '' ▼
▲ rare_class = get_rarity_class(rarity_value)
elseif rolls then
rollstext = rolls .. ' × '
-- If rarity_value is not provided, fallback to rarity string
rare_class, rare_sort = unpack(rarities[rarity:lower()]rare_sort or/ rarities._default)rolls
rare_class = get_rarity_class(math.min(1/rare_sort,0.99)) ▼
end
local rollstexttilde = ''
if rollsapprox and type(rarity_value) == 'number' then
rollstexttilde = rolls .. ' × ~'
rare_sort = rare_sort / rolls
▲ rare_class = get_rarity_class(math.min(1/rare_sort,0.99))
if approx and type(rarity_value) == 'number' then
tilde = '~'
end
-- Add rarity and any other additional rarity-related info
local rarity_span = rarity_cell:tag('span')
rarity_span:wikitext(rollstext .. tilde .. rarity)
rarity_cell:attr('data-sort-value', rare_sort)
:addClass(rare_class)
▲ if type(rarity_value) == 'number' then
rarity_cell:attr('title', rollstext .. tilde .. string.format('%.3g%%', 100 * rarity_value))
rarity_span:attr({
['data-drop-fraction'] = rollstext .. tilde .. rarity,
['data-drop-oneover'] = rollstext .. tilde .. '1/' .. commas(sigfig(1/rarity_value, 4)),
['data-drop-percent'] = rollstext .. tilde .. sigfig(100 * rarity_value, 3),
['data-drop-permil'] = rollstext .. tilde .. sigfig(1000 * rarity_value, 3),
['data-drop-permyriad'] = rollstext .. tilde .. sigfig(10000 * rarity_value, 3),
})
end
-- Handle alt_rarity if provided
if alt_rarity ~= '' then
if alt_rarity_endash ~= '' then
rarity_cell:tag('span'):wikitext('–')
else
rarity_cell:tag('span'):wikitext('; ')
end
local alt_rarity_span = rarity_cell:tag('span')
alt_rarity_span:wikitext(alt_rarity)
if type(alt_rarity_value) == 'number' then
alt_rarity_span:attr({
['data-drop-fraction'] = alt_rarity,
['data-drop-oneover'] = '1/' .. commas(sigfig(1/alt_rarity_value, 3)),
['data-drop-percent'] = sigfig(100 * alt_rarity_value, 3),
['data-drop-permil'] = sigfig(1000 * alt_rarity_value, 3),
['data-drop-permyriad'] = sigfig(10000 * alt_rarity_value, 3),
})
end
end
end
local _r = rarity
|