17,101
edits
No edit summary |
(getFarmingFoodTable: Better support for realms) |
||
Line 1,015: | Line 1,015: | ||
function p.getFarmingFoodTable(frame) | function p.getFarmingFoodTable(frame) | ||
local args = frame.args ~= nil and frame.args or frame | |||
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 = 'Farming' | |||
local root = mw.html.create('table') | local root = mw.html.create('table') | ||
:addClass('wikitable sortable stickyHeader') | :addClass('wikitable sortable stickyHeader') | ||
Line 1,027: | Line 1,035: | ||
headerRow:tag('th'):wikitext('Value') | headerRow:tag('th'):wikitext('Value') | ||
local recipes = GameData.getEntities(SkillData | local recipes = GameData.getEntities(SkillData[skillID].recipes, | ||
function(recipe) | function(recipe) | ||
if Skills.getRecipeRealm(recipe) ~= realm.id then | |||
return false | |||
end | |||
local product = Items.getItemByID(recipe.productId) | local product = Items.getItemByID(recipe.productId) | ||
return product ~= nil and product.healsFor ~= nil and product.healsFor > 0 | return product ~= nil and product.healsFor ~= nil and product.healsFor > 0 | ||
end | end | ||
) | ) | ||
table.sort(recipes, function(a, b) return a | table.sort(recipes, function (a, b) return Skills.standardRecipeSort(skillID, a, b) end) | ||
for i, recipe in ipairs(recipes) do | for i, recipe in ipairs(recipes) do | ||
Line 1,042: | Line 1,053: | ||
row:tag('td'):wikitext('[[' .. product.name .. ']]') | row:tag('td'):wikitext('[[' .. product.name .. ']]') | ||
row:tag('td'):css('text-align', 'center') | row:tag('td'):css('text-align', 'center') | ||
:wikitext(recipe | :wikitext(Skills.getRecipeLevel(skillID, recipe)) | ||
row:tag('td'):css('text-align', 'center') | row:tag('td'):css('text-align', 'center') | ||
:attr('data-sort-value', Icons.getExpansionID(product.id)) | :attr('data-sort-value', Icons.getExpansionID(product.id)) |