17,105
edits
(Hide POI Discovery table if empty) |
(getHexMasteryBonusTable: Added to generate table of hex mastery bonuses) |
||
Line 137: | Line 137: | ||
end | end | ||
end) | end) | ||
end | |||
function p.getHexMasteryBonusTable(frame) | |||
-- Build table header | |||
local resultTable = mw.html.create('table') | |||
resultTable:addClass('wikitable stickyHeaders') | |||
resultTable:tag('tr'):addClass('headerRow-0') | |||
:tag('th'):wikitext('Hexes Mastered') | |||
:tag('th'):wikitext('Passive Bonuses') | |||
:tag('th'):wikitext('Rewards') | |||
local masteryBonuses = Shared.shallowClone(SkillData.Cartography.worldMaps[1].masteryBonuses) | |||
table.sort(masteryBonuses, function(a, b) return a.masteredHexes < b.masteredHexes end) | |||
for i, bonus in ipairs(masteryBonuses) do | |||
-- Populate passive bonuses & rewards cell text | |||
local modText, rewardTextPart = nil, {} | |||
if bonus.modifiers ~= nil and not Shared.tableIsEmpty(bonus.modifiers) then | |||
modText = Constants.getModifiersText(bonus.modifiers, true, false) | |||
end | |||
if bonus.items ~= nil then | |||
for k, itemDef in ipairs(bonus.items) do | |||
local item = Items.getItemByID(itemDef.id) | |||
if item ~= nil then | |||
local expIcon = Icons.getExpansionIcon(itemDef.id) | |||
table.insert(rewardTextPart, expIcon .. Icons.Icon({item.name, type='item', qty = itemDef.quantity})) | |||
end | |||
end | |||
end | |||
if bonus.pets ~= nil then | |||
for k, petID in ipairs(bonus.pets) do | |||
local pet = GameData.getEntityByID('pets', petID) | |||
if pet ~= nil then | |||
local expIcon = Icons.getExpansionIcon(petID) | |||
table.insert(rewardTextPart, expIcon .. Icons.Icon({pet.name, type='pet'})) | |||
end | |||
end | |||
end | |||
local row = mw.html.create('tr') | |||
row:tag('td'):wikitext(Shared.formatnum(bonus.masteredHexes)) | |||
if modText == nil then | |||
row:tag('td') | |||
:addClass('table-na') | |||
:wikitext('None') | |||
else | |||
row:tag('td'):wikitext(modText) | |||
end | |||
if Shared.tableIsEmpty(rewardTextPart) then | |||
row:tag('td') | |||
:addClass('table-na') | |||
:wikitext('None') | |||
else | |||
row:tag('td'):wikitext(table.concat(rewardTextPart, '\n')) | |||
end | |||
resultTable:node(row) | |||
end | |||
return tostring(resultTable) | |||
end | end | ||
Line 208: | Line 265: | ||
function p._getDiscoveryRewardsTable(item) | function p._getDiscoveryRewardsTable(item) | ||
local POIs = {} | local POIs = {} | ||
for i, POI in | for i, POI in ipairs(SkillData.Cartography.worldMaps[1].pointsOfInterest) do | ||
if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then | if POI.discoveryRewards ~= nil and POI.discoveryRewards.items ~= nil then | ||
for i, reward in | for i, reward in ipairs(POI.discoveryRewards.items) do | ||
if reward.id == item.id then | if reward.id == item.id then | ||
table.insert(POIs, POI) | table.insert(POIs, POI) |