17,101
edits
(getFiremakingTable: Add XP with bonfire stats & refactor to avoid repetitive string concatenation) |
(Implement getMasteryTokenTable()) |
||
Line 501: | Line 501: | ||
table.insert(resultPart, '\r\n|}') | table.insert(resultPart, '\r\n|}') | ||
return table.concat(resultPart) | |||
end | |||
function p.getMasteryTokenTable() | |||
local baseTokenChance = 18500 | |||
local masterySkills = {} | |||
-- Find all mastery tokens | |||
local masteryTokens = Items.getItems(function(item) return item.isToken ~= nil and item.skill ~= nil and item.isToken end) | |||
for i, item in pairs(masteryTokens) do | |||
local milestones = SkillData.Milestones[item.skill + 1] | |||
if milestones ~= nil then | |||
table.insert(masterySkills, {tokenRef = i, skillID = item.skill, milestoneCount = milestones}) | |||
end | |||
end | |||
table.sort(masterySkills, function(a, b) | |||
if a['milestoneCount'] == b['milestoneCount'] then | |||
return a['skillID'] < b['skillID'] | |||
else | |||
return a['milestoneCount'] > b['milestoneCount'] | |||
end | |||
end) | |||
-- Generate output table | |||
local resultPart = {} | |||
local CCI = Items.getItem('Clue Chasers Insignia') | |||
local CCIIcon = Icons.Icon({'Clue Chasers Insignia', type='item', notext=true}) | |||
if CCI == nil then return '' end | |||
table.insert(resultPart, '{| class="wikitable sortable"') | |||
table.insert(resultPart, '\r\n!rowspan="2"|Token!!rowspan="2"|Skill!!colspan="2"|Approximate Mastery Token Chance') | |||
table.insert(resultPart, '\r\n|-\r\n!Without ' .. CCIIcon .. '!!With ' .. CCIIcon) | |||
for i, m in pairs(masterySkills) do | |||
local token = masteryTokens[m.tokenRef] | |||
local denom = math.floor(baseTokenChance / m['milestoneCount']) | |||
local denomCCI = math.floor(baseTokenChance / m['milestoneCount'] / (1 + CCI.increasedItemChance / 100)) | |||
table.insert(resultPart, '\r\n|-') | |||
table.insert(resultPart, '\r\n|' .. Icons.Icon({token.name, type='item', size=50, notext=true})) | |||
table.insert(resultPart, '\r\n|' .. Icons.Icon({p.getSkillName(m['skillID']), type='skill'})) | |||
table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="' .. denom .. '"|1/' .. Shared.formatnum(denom)) | |||
table.insert(resultPart, '\r\n|style="text-align:right" data-sort-value="' .. denomCCI .. '"|1/' .. Shared.formatnum(denomCCI)) | |||
end | |||
table.insert(resultPart, '\r\n|}') | |||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end | ||
return p | return p |