17,081
edits
(p.getCookingUtilityTable -> Fix increasedChanceToDoubleItemsSkill modifier which was always showing 0%. We still need to add increasedChanceToDoubleItemsSkill to Cooking Fire, decreasedPassiveCookInterval/decreasedSkillIntervalPercent to all 3 types and increasedChanceAdditionalSkillResource to non-Cooking Fire) |
(getToolTable: Move from Module:Skills/Gathering; getCookingUtilityTable: Use getToolTable & implement additional modifier columns) |
||
Line 823: | Line 823: | ||
end | end | ||
function p. | function p.getToolTable(toolName, searchString, modifiers, skillID) | ||
local | local skillName = nil | ||
if | if type(skillID) == 'string' then | ||
local | skillName = Constants.getSkillName(skillID) | ||
if | end | ||
return ' | local toolArray = p.getPurchases( | ||
function(purch) | |||
return purch.category == 'melvorD:SkillUpgrades' and string.find(purch.id, searchString) ~= nil | |||
end) | |||
if Shared.tableIsEmpty(toolArray) then | |||
return '' | |||
end | |||
if modifiers == nil then | |||
modifiers = {} | |||
end | end | ||
local | local modTotal = {} | ||
for i, modDef in ipairs(modifiers) do | |||
modTotal[modDef.name] = 0 | |||
end | end | ||
local headerRowSpan = (Shared.tableIsEmpty(toolArray) and 1) or 2 | |||
local | |||
local resultPart = {} | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable"') | |||
table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '" colspan="2"| Name') | |||
table.insert(resultPart, '{| class="wikitable | table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '"| ' .. (skillName == nil and 'Requirements' or Icons.Icon({skillName, type='skill', notext=true}) .. ' Level')) | ||
table.insert(resultPart, '| | table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '"| Cost') | ||
table.insert(resultPart, '! | for i, modDef in ipairs(modifiers) do | ||
modTotal[modDef.name] = 0 | |||
table.insert(resultPart, '\n!colspan="2"| ' .. modDef.header) | |||
end | |||
if headerRowSpan > 1 then | |||
table.insert(resultPart, '\n|-' .. string.rep('\n!This ' .. toolName .. '\n!Total', Shared.tableCount(modifiers))) | |||
end | |||
for i, tool in ipairs(toolArray) do | |||
local toolName = p._getPurchaseName(tool) | |||
local toolCost = p.getCostString(tool.cost, false) | |||
local toolCostSort = p._getPurchaseSortValue(tool) or 0 | |||
table.insert(resultPart, '\n|-') | |||
table.insert(resultPart, '\n|style="min-width:25px" data-sort-value="' .. toolName .. '"| ' .. Icons.Icon({toolName, type='upgrade', size='50', notext=true})) | |||
table.insert(resultPart, '\n| data-sort-value="' .. toolName.. '"|' .. Icons.getExpansionIcon(tool.id) .. toolName) | |||
local level, levelStyle = nil, nil | |||
if skillID == nil then | |||
level = 'None' | |||
levelStyle = '|class="table-na"' | |||
else | |||
level = 1 | |||
levelStyle = '|style="text-align:right"' | |||
end | |||
if tool.purchaseRequirements ~= nil and not Shared.tableIsEmpty(tool.purchaseRequirements) then | |||
if skillID == nil then | |||
-- Return all requirements | |||
level = p.getRequirementString(tool.purchaseRequirements) | |||
if level ~= 'None' then | |||
levelStyle = '' | |||
end | |||
else | |||
-- Return level requirement for just the specified skill | |||
for i, purchReq in ipairs(tool.purchaseRequirements) do | |||
if purchReq.type == 'SkillLevel' and purchReq.skillID == skillID then | |||
level = purchReq.level | |||
break | |||
end | |||
end | |||
end | |||
end | |||
table.insert(resultPart, '\n' .. levelStyle .. '| '..level) | |||
table.insert(resultPart, '\n|style="text-align:right" data-sort-value="' .. toolCostSort .. '"| ' .. toolCost) | |||
local cellStart = '\n|style="text-align:right"' | |||
if tool.contains ~= nil and tool.contains.modifiers ~= nil then | |||
for j, modDef in ipairs(modifiers) do | |||
local modName = modDef.name | |||
local modVal = tool.contains.modifiers[modName] | |||
if modVal ~= nil then | |||
if type(modVal) == 'table' and type(modVal[1]) == 'table' and modVal[1].skillID ~= nil and (modDef.skillID == nil or modDef.skillID == modVal[1].skillID) then | |||
modVal = modVal[1].value | |||
end | end | ||
modTotal[modName] = modTotal[modName] + modVal | |||
else | |||
modVal = 0 | |||
end | end | ||
local cellStartVal = cellStart .. ((modVal == 0 and ' class="table-na"') or '') | |||
local cellStartTot = cellStart .. ((modTotal[modName] == 0 and ' class="table-na"') or '') | |||
table.insert(resultPart, cellStartVal .. '| ' .. (modVal == 0 and '' or modDef.sign) .. modVal .. modDef.suffix) | |||
table.insert(resultPart, cellStartTot .. '| ' .. (modTotal[modName] == 0 and '' or modDef.sign) .. modTotal[modName] .. modDef.suffix) | |||
end | end | ||
end | end | ||
end | |||
table.insert(resultPart, '\n|}') | |||
return table.concat(resultPart) | |||
end | |||
function p.getAxeTable(frame) | |||
local modifiers = { | |||
{ name = 'decreasedSkillIntervalPercent', header = 'Cut Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'increasedChanceToDoubleItemsSkill', header = 'Double Items Chance', sign = '+', suffix = '%' }, | |||
{ name = 'increasedBirdNestDropRate', header = Icons.Icon({'Bird Nest', 'Drop Chance', type='item', nolink=true}), sign = '+', suffix = '%' }, | |||
{ name = 'increasedChanceForAshInWoodcutting', header = Icons.Icon({'Ash', 'Drop Chance', type='item', nolink=true}), sign = '+', suffix = '%' } | |||
} | |||
return p.getToolTable('Axe', '_Axe$', modifiers, 'melvorD:Woodcutting') | |||
end | |||
function p.getPickaxeTable(frame) | |||
local modifiers = { | |||
{ name = 'decreasedSkillIntervalPercent', header = 'Mining Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'increasedChanceToDoubleOres', header = '2x Ore Chance', sign = '+', suffix = '%' }, | |||
{ name = 'increasedChanceForOneExtraOre', header = '+1 Ore Chance', sign = '+', suffix = '%' }, | |||
{ name = 'increasedChanceForQualitySuperiorGem', header = 'Superior Gem Chance', sign = '+', suffix = '%' }, | |||
{ name = 'increasedMeteoriteOre', header = 'Increased ' .. Icons.Icon({'Meteorite Ore', type='item', notext=true}), sign = '+', suffix = '' } | |||
} | |||
return p.getToolTable('Pickaxe', '_Pickaxe$', modifiers, 'melvorD:Mining') | |||
end | |||
function p.getRodTable(frame) | |||
local modifiers = { | |||
{ name = 'decreasedSkillIntervalPercent', header = 'Catch Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'increasedChanceForOneExtraFish', header = '+1 Fish Chance', sign = '+', suffix = '%' }, | |||
{ name = 'increasedChanceToFindLostChest', header = Icons.Icon({'Lost Chest', type='item', notext=true}) .. ' Chance', sign = '+', suffix = '%' }, | |||
{ name = 'increasedFishingCookedChance', header = 'Cooked Fish Chance', sign = '+', suffix = '%' } | |||
} | |||
return p.getToolTable('Rod', '_Rod$', modifiers, 'melvorD:Fishing') | |||
end | |||
function p.getCookingUtilityTable(frame) | |||
local category = nil | |||
if frame ~= nil then category = frame.args ~= nil and frame.args[1] or frame end | |||
local validCategories = {'Cooking Fire', 'Furnace', 'Pot'} | |||
if category == nil or not Shared.contains({'Cooking Fire', 'Furnace', 'Pot'}, category) then | |||
return 'ERROR: Invalid category specified. Must be one of the following: ' .. mw.text.listToText(validCategories, ', ', ' or ') | |||
end | end | ||
return | local categoryShort = string.match(category, '[^%s]+$') | ||
local modifiers = { | |||
['Cooking Fire'] = { | |||
{ name = 'increasedSkillXP', skillID = 'melvorD:Cooking', header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP', sign = '+', suffix = '%' }, | |||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'increasedChancePerfectCookFire', header = 'Fire Perfect Cook Chance', sign ='+', suffix = '%' }, | |||
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' }, | |||
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '-', suffix = '%' } | |||
}, | |||
['Furnace'] = { | |||
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' }, | |||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' } | |||
}, | |||
['Pot'] = { | |||
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' }, | |||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '-', suffix = '%' }, | |||
{ name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' } | |||
} | |||
} | |||
return p.getToolTable(categoryShort, categoryShort .. '$', modifiers[category], nil) | |||
end | end | ||
return p | return p |