Module:Skills/Gathering/Sandbox: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 719: Line 719:


function p.getThievingNPCTable(frame)
function p.getThievingNPCTable(frame)
local args = frame.args ~= nil and frame.args or frame
    local args = frame.args or frame:getParent().args
local realmName = args.realm
    local realmName = args.realm
local realm = Skills.getRealmFromName(realmName)
    local realm = Skills.getRealmFromName(realmName)
if realm == nil then
   
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
    if realm == nil then
end
        return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil'))
local skillID = 'Thieving'
    end
 
   
local result = '{| class="wikitable sortable stickyHeader"'
    local skillID = 'Thieving'
result = result..'\r\n|- class="headerRow-0"'
    local root = mw.html.create('table')
result = result..'\r\n!colspan="2"|Name!!Area!!'..Icons.Icon({'Thieving', type='skill', notext=true})..' Level!!Experience!!Max Hit!!Perception!!Currency!!Unique Drop'
        :addClass('wikitable sortable stickyHeader')
local npcArray = GameData.getEntities(SkillData.Thieving.npcs,
   
function(obj)
    -- Header row
return Skills.getRecipeRealm(obj) == realm.id
    local headerRow = root:tag('tr')
end
        :addClass('headerRow-0')
)
        :tag('th'):attr('colspan', '2'):wikitext('Name')
table.sort(npcArray, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
        :tag('th'):wikitext('Area')
for i, npc in ipairs(npcArray) do
        :tag('th'):wikitext(Icons.Icon({'Thieving', type='skill', notext=true}) .. '<br>Level')
local level = Skills.getRecipeLevel(skillID, npc)
        :tag('th'):wikitext('[[DLC]]')
local baseXP = npc.baseAbyssalExperience or npc.baseExperience
        :tag('th'):wikitext('Experience')
local reqText = Skills.getRecipeRequirementText(SkillData.Thieving.name, npc)
        :tag('th'):wikitext('Max Hit')
local area = Skills.getThievingNPCArea(npc)
        :tag('th'):wikitext('Perception')
local currSortAmt = npc.currencyDrops[1].quantity
        :tag('th'):wikitext('Currency')
 
        :tag('th'):wikitext('Unique Drop')
result = result..'\r\n|-'
   
result = result..'\r\n|'..Icons.Icon({npc.name, type='thieving', notext=true})
    local npcArray = GameData.getEntities(SkillData.Thieving.npcs,
result = result..'||data-sort-value="'..npc.name..'"|'..Icons.getDLCColumnIcon(npc.id)..Icons.Icon({npc.name, type='thieving', noicon=true})
        function(obj)
 
            return Skills.getRecipeRealm(obj) == realm.id
result = result..'||'..area.name
        end
result = result..'||data-sort-value="' .. level .. '"| ' .. reqText
    )
result = result..'||style="text-align:right"|' .. Shared.formatnum(baseXP)
    table.sort(npcArray, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end)
result = result..'||style="text-align:right"|' .. Shared.formatnum(npc.maxHit * 10)
   
result = result..'||style="text-align:right" data-sort-value="' .. npc.perception .. '| '..Shared.formatnum(npc.perception)
    for i, npc in ipairs(npcArray) do
result = result..'||data-sort-value="' .. currSortAmt .. '"|' .. p._getThievingNPCCurrencyText(npc)
        local level = Skills.getRecipeLevel(skillID, npc)
if npc.uniqueDrop ~= nil then
        local baseXP = npc.baseAbyssalExperience or npc.baseExperience
local uniqueDrop = Items.getItemByID(npc.uniqueDrop.id)
        local area = Skills.getThievingNPCArea(npc)
if npc.uniqueDrop.quantity > 1 then
        local currSortAmt = npc.currencyDrops[1].quantity
result = result..'||data-sort-value="'..uniqueDrop.name..'"|'..Icons.Icon({uniqueDrop.name, type='item', qty = npc.uniqueDrop.quantity})
       
else
        local row = root:tag('tr')
result = result..'||data-sort-value="'..uniqueDrop.name..'"|'..Icons.Icon({uniqueDrop.name, type='item'})
        row:tag('td'):wikitext(Icons.Icon({npc.name, type='thieving', notext=true}))
end
        row:tag('td'):attr('data-sort-value', npc.name)
else
            :wikitext('[[' .. npc.name .. ']]')
result = result..'|| '
        row:tag('td'):wikitext(area.name)
end
        row:tag('td'):wikitext(level)
end
        row:tag('td'):wikitext(Icons.getDLCColumnIcon(npc.id))
result = result..'\r\n|}'
        :css('text-align', 'center')
 
        :attr('data-sort-value', Icons.getExpansionID(npc.id))
return result
        row:tag('td'):css('text-align', 'right')
            :wikitext(Shared.formatnum(baseXP))
        row:tag('td'):css('text-align', 'right')
            :wikitext(Shared.formatnum(npc.maxHit * 10))
        row:tag('td'):css('text-align', 'right')
            :attr('data-sort-value', npc.perception)
            :wikitext(Shared.formatnum(npc.perception))
        row:tag('td'):attr('data-sort-value', currSortAmt)
            :wikitext(p._getThievingNPCCurrencyText(npc))
       
        if npc.uniqueDrop ~= nil then
            local uniqueDrop = Items.getItemByID(npc.uniqueDrop.id)
            if npc.uniqueDrop.quantity > 1 then
                row:tag('td'):attr('data-sort-value', uniqueDrop.name)
                    :wikitext(Icons.Icon({uniqueDrop.name, type='item', qty=npc.uniqueDrop.quantity}))
            else
                row:tag('td'):attr('data-sort-value', uniqueDrop.name)
                    :wikitext(Icons.Icon({uniqueDrop.name, type='item'}))
            end
        else
            row:tag('td'):wikitext(' ')
        end
    end
   
    return tostring(root)
end
end


2,875

edits