Module:Skills/Gathering/Sandbox: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 506: Line 506:
end
end


local rareTxt = '{|class="wikitable sortable"'
local html = mw.html.create('table')
rareTxt = rareTxt..'\r\n!Item!!Qty'
html:addClass('wikitable sortable')
rareTxt = rareTxt..'!!Price!!colspan="2"|Chance'
 
-- Add header row
local headerRow = html:tag('tr')
headerRow:tag('th'):wikitext('Item')
headerRow:tag('th'):wikitext('[[DLC]]')
headerRow:tag('th'):wikitext('Qty')
headerRow:tag('th'):wikitext('Price')
headerRow:tag('th'):attr('colspan', '2'):wikitext('Chance')
 
-- Add rows for each rare item
for i, drop in ipairs(SkillData.Thieving.generalRareItems) do
for i, drop in ipairs(SkillData.Thieving.generalRareItems) do
-- If an npcID has been passed and the item is NPC specific, only display
-- If an npcID has been passed and the item is NPC specific, only display the item if it may be obtained while pickpocketing that NPC
-- the item if it may be obtained while pickpocketing that NPC
local npcMatch = (npc == nil or drop.npcs == nil or Shared.contains(drop.npcs, npc.id))
local npcMatch = (
local realmMatch = (npcRealm == nil or drop.realms == nil or Shared.contains(drop.realms, npcRealm))
npc == nil
 
or drop.npcs == nil
or Shared.contains(drop.npcs, npc.id)
)
local realmMatch = (
npcRealm == nil
or drop.realms == nil
or Shared.contains(drop.realms, npcRealm)
)
if npcMatch and realmMatch then
if npcMatch and realmMatch then
local thisItem = Items.getItemByID(drop.itemID)
local thisItem = Items.getItemByID(drop.itemID)
local odds = drop.chance
local odds = drop.chance
 
rareTxt = rareTxt..'\r\n|-\r\n|data-sort-value="'..thisItem.name..'"|'..Icons.getDLCColumnIcon(thisItem.id)..Icons.Icon({thisItem.name, type='item'})
local row = html:tag('tr')
rareTxt = rareTxt..'||1||data-sort-value="'..thisItem.sellsFor..'"|'..Items.getValueText(thisItem)
row:tag('td')
rareTxt = rareTxt..'||style="text-align:right" data-sort-value="'..odds..'"|'..Shared.fraction(1, Shared.round2(1/(odds/100), 0))
:attr('data-sort-value', thisItem.name)
rareTxt = rareTxt..'||style="text-align:right" data-sort-value="'..odds..'"|'..Shared.round(odds, 4, 4)..'%'
:wikitext(Icons.Icon({thisItem.name, type='item'}))
row:tag('td')
:wikitext('1')
row:tag('td')
:wikitext(Icons.getDLCColumnIcon(thisItem.id))
:attr('data-sort-value', Icons.getExpansionID(thisItem.id))
:css('text-align', 'center')
row:tag('td')
:attr('data-sort-value', thisItem.sellsFor)
:wikitext(Items.getValueText(thisItem))
row:tag('td')
:css('text-align', 'right')
:attr('data-sort-value', odds)
:wikitext(Shared.fraction(1, Shared.round2(1/(odds/100), 0)))
row:tag('td')
:css('text-align', 'right')
:attr('data-sort-value', odds)
:wikitext(Shared.round(odds, 4, 4) .. '%')
end
end
end
end
rareTxt = rareTxt..'\r\n|}'
 
return rareTxt
return tostring(html)
end
end


function p._getThievingNPCCurrencyText(npc)
function p._getThievingNPCCurrencyText(npc)
2,875

edits