17,370
edits
(getCostString: Fix regression for cost display within tables) |
(Use tabs instead of spaces for indentation) |
||
Line 669: | Line 669: | ||
end | end | ||
local modsPerfectChance = {'increasedChancePerfectCookFire', 'increasedChancePerfectCookFurnace', | local modsPerfectChance = {'increasedChancePerfectCookFire', 'increasedChancePerfectCookFurnace', | ||
'increasedChancePerfectCookPot', 'increasedChancePerfectCookGlobal'} | |||
local totalBonusVal, totalPerfectChance = 0, 0 | local totalBonusVal, totalPerfectChance = 0, 0 | ||
local utilityList = p.getPurchases(function(cat, purch) return cat == 'SkillUpgrades' and string.find(purch.name, category .. '$') ~= nil end) | local utilityList = p.getPurchases(function(cat, purch) return cat == 'SkillUpgrades' and string.find(purch.name, category .. '$') ~= nil end) | ||
local resultPart = {} | local resultPart = {} | ||
-- Table header | |||
table.insert(resultPart, '{| class="wikitable stickyHeader"') | |||
table.insert(resultPart, '|- class="headerRow-0"') | |||
table.insert(resultPart, '!colspan="4"| !!colspan="2"|' .. bonusColName .. '!!colspan="2"|Bonus Perfect Chance') | |||
table.insert(resultPart, '|- class="headerRow-1"') | |||
table.insert(resultPart, '!colspan="2"|Name!!Level!!Cost' .. string.rep('!!This ' .. categoryShort .. '!!Total', 2)) | |||
-- Row for each upgrade | |||
for i, utility in ipairs(utilityList) do | |||
-- First determine bonus XP/doubling chance and perfect chance | |||
local bonusVal, perfectChance = 0, 0 | |||
if type(utility.contains) == 'table' then | |||
if type(utility.contains.modifiers) == 'table' then | |||
for modName, modVal in pairs(utility.contains.modifiers) do | |||
if modName == bonusColMod and type(modVal) == 'table' then | |||
-- Bonus XP/doubling | |||
for skID, skVal in pairs(modVal) do | |||
if skVal[1] == bonusSkillID then bonusVal = bonusVal + skVal[2] end | |||
end | |||
elseif Shared.contains(modsPerfectChance, modName) then | |||
-- Perfect chance | |||
perfectChance = perfectChance + modVal | |||
end | |||
end | |||
end | |||
end | |||
totalBonusVal = totalBonusVal + bonusVal | |||
totalPerfectChance = totalPerfectChance + perfectChance | |||
-- Mangle unlockRequirements so that it only includes skillLevels | |||
local unlockReqs = {} | |||
if type(utility.unlockRequirements) == 'table' then | |||
unlockReqs['skillLevel'] = utility.unlockRequirements.skillLevel | |||
end | |||
table.insert(resultPart, '|-') | |||
table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({utility.name, type='upgrade', size='50', notext=true})) | |||
table.insert(resultPart, '|' .. utility.name) | |||
table.insert(resultPart, '|style="text-align:right"|' .. p.getRequirementString(unlockReqs)) | |||
table.insert(resultPart, '|style="text-align:right"|' .. p.getCostString(utility.cost, false)) | |||
table.insert(resultPart, '|style="text-align:right"|' .. '+' .. bonusVal .. '%') | |||
table.insert(resultPart, '|style="text-align:right"|' .. '+' .. totalBonusVal .. '%') | |||
table.insert(resultPart, '|style="text-align:right"|' .. '+' .. perfectChance .. '%') | |||
table.insert(resultPart, '|style="text-align:right"|' .. '+' .. totalPerfectChance .. '%') | |||
end | |||
table.insert(resultPart, '|}') | |||
return table.concat(resultPart, '\r\n') | return table.concat(resultPart, '\r\n') | ||
end | end | ||
return p | return p |