12,726
edits
(_getLootTableValue: Added for average loot table sale value; _formatLootTable: Support output in table form; _getThievingNPCStat: Add lootValue, pickpocketValue, lootList stats) |
(_formatLootTable: Re-order columns for table output & include total row) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 163: | Line 163: | ||
end | end | ||
else | else | ||
table.insert(returnPart, '{|class="wikitable sortable"\r\n!Item!!colspan="2"|Chance | table.insert(returnPart, '{|class="wikitable sortable"\r\n!Item!!Price!!colspan="2"|Chance') | ||
end | end | ||
-- Generate row for each item | -- Generate row for each item | ||
Line 175: | Line 175: | ||
else | else | ||
table.insert(returnPart, '|-\r\n|' .. itemText) | table.insert(returnPart, '|-\r\n|' .. itemText) | ||
table.insert(returnPart, '|style="text-align:right;" data-sort-value="' .. sellsFor .. '"|' .. Icons.GP(sellsFor)) | |||
table.insert(returnPart, '|style="text-align:right;" data-sort-value="' .. dropChance .. '"|' .. Shared.fraction(drop[2] * chanceMult, totalWeight * 100)) | table.insert(returnPart, '|style="text-align:right;" data-sort-value="' .. dropChance .. '"|' .. Shared.fraction(drop[2] * chanceMult, totalWeight * 100)) | ||
table.insert(returnPart, '|style="text-align:right;"|' .. dropChance .. '%') | table.insert(returnPart, '|style="text-align:right;"|' .. dropChance .. '%') | ||
end | end | ||
end | end | ||
if not asList then | if not asList then | ||
table.insert(returnPart, '|}') | table.insert(returnPart, '|-class="sortbottom" \r\n!colspan="2"|Total:') | ||
local textTotChance = '' | |||
if chanceMult < 100 then | |||
textTotChance = '|style="text-align:right"|' .. Shared.fraction(chanceMult, 100) .. '\r\n|' | |||
else | |||
textTotChance = '|colspan="2" ' | |||
end | |||
textTotChance = textTotChance .. 'style="text-align:right;"|' .. Shared.round(chanceMult, 2, 2) .. '%' .. '\r\n|}' | |||
table.insert(returnPart, textTotChance) | |||
end | end | ||
Line 192: | Line 200: | ||
-- Create table header | -- Create table header | ||
table.insert(returnPart, '{| class="wikitable sortable stickyHeader"') | table.insert(returnPart, '{| class="wikitable sortable stickyHeader"') | ||
table.insert(returnPart, '|- class="headerRow-0"\r\n!Target!!Name!!' .. Icons.Icon({'Thieving', type='skill', notext=true}).. ' Level!!Experience!!Max Hit!!Max Coins') | table.insert(returnPart, '|- class="headerRow-0"\r\n!Target!!Name!!' .. Icons.Icon({'Thieving', type='skill', notext=true}).. ' Level!!Experience!!Max Hit!!Max Coins!!<abbr title="Assumes all loot is sold, and no GP boosts apply (such as those from Mastery & Gloves of Silence)">GP/Theft</abbr>') | ||
-- Create row for each NPC | -- Create row for each NPC | ||
for i, npc in Shared.skpairs(SkillData.Thieving) do | for i, npc in Shared.skpairs(SkillData.Thieving) do | ||
local linkText = (npc.name ~= p._getThievingNPCStat(npc, 'pageName') and p._getThievingNPCStat(npc, 'pageName') .. '|' .. npc.name) or npc.name | |||
table.insert(returnPart, '|-\r\n|style="text-align: left;" |' .. Icons.Icon({npc.name, type='thieving', size=50, notext=true})) | table.insert(returnPart, '|-\r\n|style="text-align: left;" |' .. Icons.Icon({npc.name, type='thieving', size=50, notext=true})) | ||
table.insert(returnPart, '|style="text-align: left;" |[[' .. | table.insert(returnPart, '|style="text-align: left;" |[[' .. linkText .. ']]') | ||
table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'level')) | table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'level')) | ||
table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'xp')) | table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'xp')) | ||
table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'maxHit')) | table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'maxHit')) | ||
table.insert(returnPart, '|style="text-align: right;" |' .. p._getThievingNPCStat(npc, 'maxCoins')) | table.insert(returnPart, '|style="text-align: right;" data-sort-value="' .. p._getThievingNPCStat(npc, 'maxCoins') .. '" |' .. Icons.GP(p._getThievingNPCStat(npc, 'maxCoins'))) | ||
table.insert(returnPart, '|style="text-align: right;" data-sort-value="' .. p._getThievingNPCStat(npc, 'pickpocketValue') .. '" |' .. Icons.GP(p._getThievingNPCStat(npc, 'pickpocketValue'))) | |||
end | end | ||
table.insert(returnPart, '|}') | table.insert(returnPart, '|}') | ||
Line 219: | Line 229: | ||
-- Create row for each NPC | -- Create row for each NPC | ||
for i, npc in Shared.skpairs(SkillData.Thieving) do | for i, npc in Shared.skpairs(SkillData.Thieving) do | ||
table.insert(npcList, Icons.Icon({npc.name, type='thieving', notext=true}) .. ' [[' .. | local linkText = (npc.name ~= p._getThievingNPCStat(npc, 'pageName') and p._getThievingNPCStat(npc, 'pageName') .. '|' .. npc.name) or npc.name | ||
table.insert(npcList, Icons.Icon({npc.name, type='thieving', notext=true}) .. ' [[' .. linkText .. ']]') | |||
end | end | ||
table.insert(returnPart, table.concat(npcList, ' • ')) | table.insert(returnPart, table.concat(npcList, ' • ')) |