2,875
edits
No edit summary |
No edit summary |
||
Line 795: | Line 795: | ||
function p.getThievingAreaTable(frame) | function p.getThievingAreaTable(frame) | ||
local args = frame.args or frame:getParent().args | |||
local realmName = args.realm | |||
local realm = Skills.getRealmFromName(realmName) | |||
if realm == nil then | |||
return Shared.printError('Failed to find a realm with name ' .. (realmName or 'nil')) | |||
end | |||
local skillID = 'Thieving' | |||
local root = mw.html.create('table') | |||
:addClass('wikitable sortable stickyHeader') | |||
-- Header row | |||
local headerRow = root:tag('tr') | |||
:addClass('headerRow-0') | |||
headerRow:tag('th'):wikitext('Area') | |||
headerRow:tag('th'):wikitext(Icons.Icon({'Thieving', type='skill', notext=true}) .. '<br>Level') | |||
headerRow:tag('th'):wikitext('NPCs') | |||
headerRow:tag('th'):wikitext('Unique Drops') | |||
local areas = GameData.getEntities(SkillData.Thieving.areas, | |||
function(obj) | |||
return Skills.getRecipeRealm(obj) == realm.id | |||
end | |||
) | |||
for i, area in ipairs(areas) do | |||
local minLevel, npcList, areaItemList = nil, {}, {} | |||
-- Build NPC list & determine minimum Thieving level | |||
if area.npcIDs and not Shared.tableIsEmpty(area.npcIDs) then | |||
for j, npcID in ipairs(area.npcIDs) do | |||
local npc = Skills.getThievingNPCByID(npcID) | |||
local level = Skills.getRecipeLevel(skillID, npc) | |||
if not minLevel or level < minLevel then | |||
minLevel = level | |||
end | |||
table.insert(npcList, Icons.Icon({npc.name, type='thieving'})) | |||
end | |||
else | |||
table.insert(npcList, '') | |||
end | |||
-- Build area unique item list | |||
if area.uniqueDrops and Shared.tableCount(area.uniqueDrops) > 0 then | |||
for k, drop in ipairs(area.uniqueDrops) do | |||
local areaItem = Items.getItemByID(drop.id) | |||
if areaItem then | |||
local iconDef = {areaItem.name, type='item'} | |||
if drop.quantity > 1 then | |||
iconDef.qty = drop.quantity | |||
end | |||
table.insert(areaItemList, Icons.Icon(iconDef)) | |||
else | |||
table.insert(areaItemList, 'Unknown[[Category:Pages with script errors]]') | |||
end | |||
end | |||
else | |||
table.insert(areaItemList, '') | |||
end | |||
-- Generate table row | |||
local row = root:tag('tr') | |||
row:tag('td'):wikitext(area.name) | |||
row:tag('td'):wikitext(minLevel) | |||
:css('text-align', 'center') | |||
row:tag('td'):wikitext(table.concat(npcList, '<br/>')) | |||
row:tag('td'):wikitext(table.concat(areaItemList, '<br/>')) | |||
end | |||
return tostring(root) | |||
end | |||
function p._getFarmingTable(realmID, category) | function p._getFarmingTable(realmID, category) |
edits