2,873
edits
(_getHerblorePotionTable: Fix overall potion icons) |
No edit summary |
||
Line 218: | Line 218: | ||
end | end | ||
function p. | -- Returns the icon of the past potion found in potion.PotiodIDs | ||
-- This is usually the IV potion. | |||
function p._getHerblorePotionIcon(potion) | |||
local lastPot = nil | |||
for k, v in ipairs(potion.potionIDs) do | |||
lastPot = v | |||
end | |||
local pot = Items.getItemByID(lastPot) | |||
return Icons.Icon({pot.name, type='item', notext=true, size='25'}) | |||
end | end | ||
function p._getHerblorePotionSlimTable(realmID) | function p._getHerblorePotionSlimTable(realmID) | ||
--'melvorD:Melvor' | |||
--'melvorItA:Abyssal' | |||
local skillID = 'Herblore' | |||
local realmIcon = Icons._SkillRealmIcon('Herblore', realmID) | |||
local potions = GameData.getEntities(SkillData.Herblore.recipes, | local potions = GameData.getEntities(SkillData.Herblore.recipes, | ||
function( | function(x) | ||
return Skills.getRecipeRealm( | return Skills.getRecipeRealm(x) == realmID | ||
end | end | ||
) | ) | ||
table.sort(potions, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end) | table.sort(potions, function(a, b) return Skills.standardRecipeSort(skillID, a, b) end) | ||
function getIngredients(potion) | |||
local herbs = {} | |||
local secondaries = {} | |||
-- Grab secondaries and split herb. | |||
if type(potion.itemCosts) == 'table' then | |||
for k, v in pairs(potion.itemCosts) do | |||
local ingredientID = v.id | |||
local item = GameData.getEntityByID('items', v.id) | |||
local icon = Icons.Icon({item.name, type='item', qty=v.quantity}) | |||
if ingredientID ~= nil and string.sub(ingredientID, -5) == "_Herb" then | |||
table.insert(herbs, icon) | |||
else | |||
table.insert(secondaries, icon) | |||
end | |||
end | |||
end | |||
-- Format currencies as normal | |||
if type(potion.currencies) == 'table' then | |||
for k, v in pairs(potion.currencies) do | |||
local currID = v.id or v.currencyID | |||
table.insert(secondaries, Icons._Currency(currID, v.quantity)) | |||
end | |||
end | |||
return { | |||
herbs = table.concat(herbs, '<br>'), | |||
secondaries = table.concat(secondaries, '<br>') | |||
} | |||
end | |||
local tbl = mw.html.create("table") | local tbl = mw.html.create("table") | ||
:addClass("wikitable sortable stickyHeader mw-collapsible mw-collapsed") | :addClass("wikitable sortable stickyHeader mw-collapsible mw-collapsed") | ||
Line 246: | Line 282: | ||
:attr('colspan', 2) | :attr('colspan', 2) | ||
:tag('th'):wikitext('[[DLC]]') | :tag('th'):wikitext('[[DLC]]') | ||
:tag('th'):wikitext('<br>Level') | :tag('th'):wikitext(realmIcon .. '<br>Level') | ||
:tag('th'):wikitext('<br>XP') | :tag('th'):wikitext(realmIcon .. '<br>XP') | ||
:tag('th'):wikitext('Herb') | :tag('th'):wikitext('Herb') | ||
:tag('th'):wikitext('Secondary') | :tag('th'):wikitext('Secondary') | ||
--:tag('th'):wikitext('Effect') | --:tag('th'):wikitext('Effect') | ||
:done() | :done() | ||
for i, potion in ipairs(potions) do | |||
local level = Skills.getRecipeLevel(skillID, potion) | |||
local xp = potion.baseAbyssalExperience or potion.baseExperience | |||
local ingreds = getIngredients(potion) | |||
local row = tbl:tag('tr') | |||
row:tag('td'):wikitext(p._getHerblorePotionIcon(potion)) | |||
:css('text-align', 'center') | |||
row:tag('td'):wikitext('[['..potion.name..']]') | |||
row:tag('td'):wikitext(Icons.getDLCColumnIcon(potion.potionIDs[1])) | |||
:css('text-align', 'center') | |||
:attr('data-sort-value', Icons.getExpansionID(potion.potionIDs[1])) | |||
row:tag('td'):wikitext(level) | |||
:css('text-align', 'center') | |||
row:tag('td'):wikitext(xp) | |||
:css('text-align', 'right') | |||
row:tag('td'):wikitext(ingreds.herbs) | |||
row:tag('td'):wikitext(ingreds.secondaries) | |||
end | |||
return tostring(tbl) | |||
end | end | ||
edits