Anonymous

Module:Shop: Difference between revisions

From Melvor Idle
Add new coating & harvester upgrade tables, and amend getToolTable to use modifier IDs rather than aliases
(Remove getAutoEatTable in favour of manual table)
(Add new coating & harvester upgrade tables, and amend getToolTable to use modifier IDs rather than aliases)
Line 577: Line 577:
-- Exclude tools, handled by p.getToolTable()
-- Exclude tools, handled by p.getToolTable()
and string.find(purch.id, '_Axe$') == nil
and string.find(purch.id, '_Axe$') == nil
and string.find(purch.id, '_Axe_Coating$') == nil
and string.find(purch.id, '_Pickaxe$') == nil
and string.find(purch.id, '_Pickaxe$') == nil
and string.find(purch.id, '_Pickaxe_Coating$') == nil
and string.find(purch.id, '_Rod$') == nil
and string.find(purch.id, '_Rod$') == nil
and string.find(purch.id, '_Pickaxe$') == nil
and string.find(purch.id, '_Rod_Coating$') == nil
and string.find(purch.id, '_Harvester$') == nil
and string.find(purch.id, 'Fire$') == nil
and string.find(purch.id, 'Fire$') == nil
and string.find(purch.id, 'Furnace$') == nil
and string.find(purch.id, 'Furnace$') == nil
Line 794: Line 797:
end
end


local modTotal = {}
-- Determine match criteria for modifier matches later & initialize
-- accumulators for modifier magnitudes
local modTotal, modMatchCriteria = {}, {}
for i, modDef in ipairs(modifiers) do
for i, modDef in ipairs(modifiers) do
modTotal[modDef.name] = 0
modTotal[i] = 0
modMatchCriteria[i] = Modifiers.getMatchCriteriaFromIDs({ modDef.matchRule })
end
end


Line 807: Line 813:
table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '"| Cost')
table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '"| Cost')
for i, modDef in ipairs(modifiers) do
for i, modDef in ipairs(modifiers) do
modTotal[modDef.name] = 0
table.insert(resultPart, '\n!colspan="2"| ' .. modDef.header)
table.insert(resultPart, '\n!colspan="2"| ' .. modDef.header)
end
end
Line 814: Line 819:
end
end


-- Keep track of modifiers which are present on tools but not exposed within the table, so
-- that an error may be printed if any are omitted
for i, tool in ipairs(toolArray) do
for i, tool in ipairs(toolArray) do
local toolName = Common.getPurchaseName(tool)
local toolName = Common.getPurchaseName(tool)
Line 856: Line 859:
local toolMods = tool.contains.modifiers
local toolMods = tool.contains.modifiers
for j, modDef in ipairs(modifiers) do
for j, modDef in ipairs(modifiers) do
local modName = modDef.name
local matchedMods = Modifiers.getMatchingModifiers(tool.contains.modifiers, modMatchCriteria[j])
local matchRules = { { ["alias"] = modName } }
local matchedMods = Modifiers.getMatchingModifiers(tool.contains.modifiers, matchRules)
local modVal = Modifiers.getModifierValue(matchedMods.matched) or 0
local modVal = Modifiers.getModifierValue(matchedMods.matched) or 0
modTotal[modName] = modTotal[modName] + modVal
modTotal[j] = modTotal[j] + modVal
local cellStartVal = cellStart .. ((modVal == 0 and ' class="table-na"') or '')
local cellStartVal = cellStart .. ((modVal == 0 and ' class="table-na"') or '')
local cellStartTot = cellStart .. ((modTotal[modName] == 0 and ' class="table-na"') or '')
local cellStartTot = cellStart .. ((modTotal[j] == 0 and ' class="table-na"') or '')
table.insert(resultPart, cellStartVal .. '| ' .. (modVal == 0 and '' or modDef.sign) .. modVal .. modDef.suffix)
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)
table.insert(resultPart, cellStartTot .. '| ' .. (modTotal[j] == 0 and '' or modDef.sign) .. modTotal[j] .. modDef.suffix)
end
end
end
end
Line 875: Line 876:
function p.getAxeTable(frame)
function p.getAxeTable(frame)
local modifiers = {
local modifiers = {
{ name = 'decreasedSkillIntervalPercent', header = 'Cut Time Decrease', sign = '', suffix = '%' },
{  
{ name = 'increasedChanceToDoubleItemsSkill', header = 'Double Items Chance', sign = '+', suffix = '%' },
header = 'Cut Time Decrease',
{ name = 'increasedBirdNestDropRate', header = Icons.Icon({'Bird Nest', 'Drop Chance', type='item', nolink=true}), sign = '+', suffix = '%' },
sign = '',
{ name = 'increasedChanceForAshInWoodcutting', header = Icons.Icon({'Ash', 'Drop Chance', type='item', nolink=true}), sign = '+', suffix = '%' }
suffix = '%',
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting' }
}
}, {
header = 'Double Items Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'skillItemDoublingChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting' }
}
}, {
header = Icons.Icon({'Bird Nest', 'Drop Chance', type='item', nolink=true}),
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'randomProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting', ["itemID"] = 'melvorD:Bird_Nest' }
}
}, {
header = Icons.Icon({'Ash', 'Drop Chance', type='item', nolink=true}),
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalRandomSkillItemChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting', ["itemID"] = 'melvorF:Ash' }
}
}
}
}
return p.getToolTable('Axe', '_Axe$', modifiers, 'melvorD:Woodcutting')
return p.getToolTable('Axe', '_Axe$', modifiers, 'melvorD:Woodcutting')
end
function p.getAxeCoatingTable(frame)
local modifiers = {
{
header = 'AXP Increase',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'abyssalSkillXP',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting' }
}
}, {
header = 'Log Quantity Increase',
sign = '+',
suffix = '',
matchRule = {
["id"] = 'flatAdditionalPrimaryProductQuantity',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting' }
}
}, {
header = Icons.Icon({'Shadow Raven Nest', 'Drop Chance', type='item', nolink=true}),
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'randomProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting', ["itemID"] = 'melvorItA:Shadow_Raven_Nest' }
}
}, {
header = Icons.Icon({'Shadow Drake Nest', 'Drop Chance', type='item', nolink=true}),
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'randomProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Woodcutting', ["itemID"] = 'melvorItA:Shadow_Drake_Nest' }
}
}
}
return p.getToolTable('Coating', '_Axe_Coating$', modifiers, 'melvorD:Woodcutting')
end
end


function p.getPickaxeTable(frame)
function p.getPickaxeTable(frame)
local modifiers = {
local modifiers = {
{ name = 'decreasedSkillIntervalPercent', header = 'Mining Time Decrease', sign = '', suffix = '%' },
{  
{ name = 'increasedChanceToDoubleOres', header = '2x Ore Chance', sign = '+', suffix = '%' },
header = 'Mining Time Decrease',
{ name = 'increasedChanceForOneExtraOre', header = '+1 Ore Chance', sign = '+', suffix = '%' },
sign = '',
{ name = 'increasedChanceForQualitySuperiorGem', header = 'Superior Gem Chance', sign = '+', suffix = '%' },
suffix = '%',
{ name = 'increasedMeteoriteOre', header = 'Increased ' .. Icons.Icon({'Meteorite Ore', type='item', notext=true}), sign = '+', suffix = '' }
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Mining' }
}
}, {
header = '2x Ore Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'skillItemDoublingChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Mining' }
}
}, {
header = '+1 Ore Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalPrimaryProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Mining', ["categoryID"] = 'melvorD:Ore' }
}
}, {
header = 'Superior Gem Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'qualitySuperiorGemChance',
["type"] = 'id'
}
}, {
header = 'Increased ' .. Icons.Icon({'Meteorite Ore', type='item', notext=true}),
sign = '+',
suffix = '',
matchRule = {
["id"] = 'flatBasePrimaryProductQuantity',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Mining', ["actionID"] = 'melvorTotH:Meteorite_Ore' }
}
}
}
}


return p.getToolTable('Pickaxe', '_Pickaxe$', modifiers, 'melvorD:Mining')
return p.getToolTable('Pickaxe', '_Pickaxe$', modifiers, 'melvorD:Mining')
end
function p.getPickaxeCoatingTable(frame)
local modifiers = {
{
header = 'AXP Increase',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'abyssalSkillXP',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Mining' }
}
}, {
header = 'Rock Quantity Increase',
sign = '+',
suffix = '',
matchRule = {
["id"] = 'flatAdditionalPrimaryProductQuantity',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Mining' }
}
}, {
header = 'Abyssal Gem Vein Location Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'abyssalGemVeinChanceIncrease',
["type"] = 'id'
}
}, {
header = '+1 Abyssal Gem Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalAbyssalGemChance',
["type"] = 'id'
}
}
}
return p.getToolTable('Coating', '_Pickaxe_Coating$', modifiers, 'melvorD:Mining')
end
end


function p.getRodTable(frame)
function p.getRodTable(frame)
local modifiers = {
local modifiers = {
{ name = 'decreasedSkillIntervalPercent', header = 'Catch Time Decrease', sign = '', suffix = '%' },
{  
{ name = 'increasedChanceForOneExtraFish', header = '+1 Fish Chance', sign = '+', suffix = '%' },
header = 'Catch Time Decrease',
{ name = 'increasedChanceToFindLostChest', header = Icons.Icon({'Lost Chest', type='item', notext=true}) .. ' Chance', sign = '+', suffix = '%' },
sign = '',
{ name = 'increasedFishingCookedChance', header = 'Cooked Fish Chance', sign = '+', suffix = '%' }
suffix = '%',
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Fishing' }
}
}, {
header = '+1 Fish Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalPrimaryProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Fishing' }
}
}, {
header = Icons.Icon({'Lost Chest', type='item', notext=true}) .. ' Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalRandomSkillItemChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Fishing', ["itemID"] = 'melvorTotH:Lost_Chest' }
}
}, {
header = 'Cooked Fish Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'fishingCookedChance',
["type"] = 'id'
}
}
}
}


return p.getToolTable('Rod', '_Rod$', modifiers, 'melvorD:Fishing')
return p.getToolTable('Rod', '_Rod$', modifiers, 'melvorD:Fishing')
end
function p.getRodCoatingTable(frame)
local modifiers = {
{
header = 'AXP Increase',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'abyssalSkillXP',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Fishing' }
}
}, {
header = 'Fish Quantity Increase',
sign = '+',
suffix = '',
matchRule = {
["id"] = 'flatAdditionalPrimaryProductQuantity',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Fishing' }
}
}, {
header = 'Cooked Fish Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'fishingCookedChance',
["type"] = 'id'
}
}
}
return p.getToolTable('Coating', '_Rod_Coating$', modifiers, 'melvorD:Fishing')
end
function p.getHarvesterTable(frame)
local modifiers = {
{
header = 'Minimum Harvesting Intensity',
sign = '+',
suffix = '',
matchRule = {
["id"] = 'minimumHarvestingIntensity',
["type"] = 'id'
}
}, {
header = '2x Intensity Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'doubleHarvestingIntensityChance',
["type"] = 'id'
}
}, {
header = '2x Item Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'flatAdditionalPrimaryProductQuantity',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorItA:Harvesting' }
}
}
}
return p.getToolTable('Harvester', '_Harvester$', modifiers, 'melvorItA:Harvesting')
end
end


Line 918: Line 1,177:
local modifiers = {
local modifiers = {
['Cooking Fire'] = {
['Cooking Fire'] = {
{ name = 'increasedSkillXP', skillID = 'melvorD:Cooking', header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP', sign = '+', suffix = '%' },
{  
{ name = 'increasedChancePerfectCookFire', header = Icons.Icon({'Normal Cooking Fire', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance', sign ='+', suffix = '%' },
header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP',
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '', suffix = '%' },
sign = '+',
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' },
suffix = '%',
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '', suffix = '%' }
matchRule = {
["id"] = 'skillXP',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = Icons.Icon({'Normal Cooking Fire', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'perfectCookChance',
["type"] = 'id',
["props"] = { ["categoryID"] = 'melvorD:Fire' }
}
}, {
header = 'Passive Cook Time Decrease',
sign = '',
suffix = '%',
matchRule = {
["id"] = 'passiveCookingInterval',
["type"] = 'id'
}
}, {
header = '2x Items Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'skillItemDoublingChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = 'Active Cook Time Decrease',
sign = '',
suffix = '%',
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}
},
},
['Furnace'] = {
['Furnace'] = {
{ name = 'increasedChancePerfectCookFurnace', header = Icons.Icon({'Basic Furnace', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance', sign = '+', suffix = '%' },
{
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' },
header = Icons.Icon({'Basic Furnace', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance',
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '', suffix = '%' },
sign = '+',
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '', suffix = '%' },
suffix = '%',
{ name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' }
matchRule = {
["id"] = 'perfectCookChance',
["type"] = 'id',
["props"] = { ["categoryID"] = 'melvorD:Furnace' }
}
}, {
header = '2x Items Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'skillItemDoublingChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = 'Passive Cook Time Decrease',
sign = '',
suffix = '%',
matchRule = {
["id"] = 'passiveCookingInterval',
["type"] = 'id'
}
}, {
header = 'Active Cook Time Decrease',
sign = '',
suffix = '%',
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = '+1 Item Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalPrimaryProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}
},
},
['Pot'] = {
['Pot'] = {
{ name = 'increasedChancePerfectCookPot', header = Icons.Icon({'Basic Pot', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance', sign = '+', suffix = '%' },
{
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' },
header = Icons.Icon({'Basic Pot', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance',
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '', suffix = '%' },
sign = '+',
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '', suffix = '%' },
suffix = '%',
{ name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' },
matchRule = {
{ name = 'increasedMasteryXP', skillID = 'melvorD:Cooking', header = 'Increased Cooking ' .. Icons.Icon({'Mastery', nolink=true}) .. ' XP', sign = '+', suffix = '%'}
["id"] = 'perfectCookChance',
["type"] = 'id',
["props"] = { ["categoryID"] = 'melvorD:Pot' }
}
}, {
header = '2x Items Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'skillItemDoublingChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = 'Passive Cook Time Decrease',
sign = '',
suffix = '%',
matchRule = {
["id"] = 'passiveCookingInterval',
["type"] = 'id'
}
}, {
header = 'Active Cook Time Decrease',
sign = '',
suffix = '%',
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = '+1 Item Chance',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'additionalPrimaryProductChance',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}, {
header = 'Increased Cooking ' .. Icons.Icon({'Mastery', nolink=true}) .. ' XP',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'masteryXP',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorD:Cooking' }
}
}
}
}
}
}
Line 947: Line 1,334:
function p.getShipTable(frame)
function p.getShipTable(frame)
local modifiers = {
local modifiers = {
{ name = 'decreasedSkillIntervalPercent', header = 'Cartography Interval', sign = '', suffix = '%' },
{
{ name = 'increasedSightRange', header = 'Increased Sight Range', sign = '+', suffix = '' },
header = 'Cartography Interval',
{ name = 'increasedSurveyRange', header = 'Increased Survey Range', sign = '+', suffix = ''},
sign = '',
suffix = '%',
matchRule = {
["id"] = 'skillInterval',
["type"] = 'id',
["props"] = { ["skillID"] = 'melvorAoD:Cartography' }
}
}, {
header = 'Increased Sight Range',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'cartographySightRange',
["type"] = 'id'
}
}, {
header = 'Increased Survey Range',
sign = '+',
suffix = '%',
matchRule = {
["id"] = 'cartographySurveyRange',
["type"] = 'id'
}
}
}
}


return p.getToolTable('Ship', 'Ship', modifiers, 'melvorAoD:Cartography')
return p.getToolTable('Ship', 'Ship', modifiers, 'melvorAoD:Cartography')
end
end


function p.getArchToolTable(frame)local category = nil
function p.getArchToolTable(frame)
local category = nil
if frame ~= nil then category = frame.args ~= nil and frame.args[1] or frame end
if frame ~= nil then category = frame.args ~= nil and frame.args[1] or frame end
local validCategories = {'Sieve', 'Trowel', 'Brush', 'Shovel'}
local validCategories = {'Sieve', 'Trowel', 'Brush', 'Shovel'}
Line 963: Line 1,374:


local modifiers = {
local modifiers = {
{name = 'increased'..category..'ToolLevel', header = 'Increased '..category..' Tool level', sign = '+', suffix = ''}
{
header = 'Increased ' .. category .. 'Tool Level',
sign = '+',
suffix = '',
matchRule = {
["id"] = string.lower(category) .. 'ToolLevel',
["type"] = 'id'
}
}
}
}
return p.getToolTable(category, category .. '$', modifiers, 'melvorAoD:Archaeology')
return p.getToolTable(category, category .. '$', modifiers, 'melvorAoD:Archaeology')
end
end