17,370
edits
No edit summary |
(Update for v1.3) |
||
Line 5: | Line 5: | ||
local GameData = require('Module:GameData') | local GameData = require('Module:GameData') | ||
local Common = require('Module:Common') | local Common = require('Module:Common') | ||
local Modifiers = require('Module:Modifiers') | |||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
Line 119: | Line 120: | ||
local item = nil | local item = nil | ||
if purch.contains.modifiers ~= nil then | if purch.contains.modifiers ~= nil then | ||
return | return Modifiers.getModifiersText(purch.contains.modifiers, false) | ||
elseif purch.contains.petID ~= nil then | elseif purch.contains.petID ~= nil then | ||
local pet = Pets.getPetByID(purch.contains.petID) | local pet = Pets.getPetByID(purch.contains.petID) | ||
Line 132: | Line 133: | ||
return item.customDescription | return item.customDescription | ||
elseif item.modifiers ~= nil then | elseif item.modifiers ~= nil then | ||
return | return Modifiers.getModifiersText(item.modifiers, false) | ||
end | end | ||
end | end | ||
Line 142: | Line 143: | ||
local displayInline = (inline ~= nil and inline or false) | local displayInline = (inline ~= nil and inline or false) | ||
local costArray = {} | local costArray = {} | ||
if cost.currencies ~= nil then | |||
for i, costAmt in ipairs(cost.currencies) do | |||
local costStr = p.getCurrencyCostString(costAmt) | |||
local costStr = p.getCurrencyCostString( | |||
if costStr ~= nil then | if costStr ~= nil then | ||
table.insert(costArray, costStr) | table.insert(costArray, costStr) | ||
Line 172: | Line 172: | ||
return mw.text.listToText(costArray, sep, lastSep) | return mw.text.listToText(costArray, sep, lastSep) | ||
end | end | ||
return '' | |||
end | end | ||
Line 186: | Line 187: | ||
end | end | ||
function p.getCurrencyCostString(cost | function p.getCurrencyCostString(cost) | ||
if cost.type == 'BankSlot' then | if cost.type == 'BankSlot' then | ||
-- Unusual bit of code that basically evaluates wikitext '<math>C_b</math>*' | -- Unusual bit of code that basically evaluates wikitext '<math>C_b</math>*' | ||
return mw.getCurrentFrame():callParserFunction('#tag:math', {'C_b'}) .. '*' | return mw.getCurrentFrame():callParserFunction('#tag:math', {'C_b'}) .. '*' | ||
elseif cost.type == 'Linear' and (cost.initial > 0 or cost.scaling > 0) then | elseif cost.type == 'Linear' and (cost.initial > 0 or cost.scaling > 0) then | ||
return | return Icons._Currency(cost.currency, cost.initial) .. '<br/>+' .. Icons._Currency(cost.currency, cost.scaling) .. ' for each purchase' | ||
elseif cost.type == 'Glove' or cost.type == 'Fixed' and cost.cost > 0 then | elseif cost.type == 'Glove' or cost.type == 'Fixed' and cost.cost > 0 then | ||
-- Type Glove exists in game so the Merchant's Permit cost reduction can be applied, | -- Type Glove exists in game so the Merchant's Permit cost reduction can be applied, | ||
-- it makes no difference here | -- it makes no difference here | ||
return | return Icons._Currency(cost.currency, cost.cost) | ||
end | end | ||
end | end | ||
Line 339: | Line 327: | ||
function p._getPurchaseSortValue(purchase) | function p._getPurchaseSortValue(purchase) | ||
if purchase.cost ~= nil and purchase.cost.currencies ~= nil then | |||
for _, costAmt in ipairs(purchase.cost.currencies) do | |||
-- Find cost for the current currency, if it exists | |||
if costAmt.type == 'BankSlot' then | |||
return -1 | |||
elseif costAmt.type == 'Linear' then | |||
return costAmt.initial | |||
elseif costAmt.type == 'Glove' or costAmt.type == 'Fixed' and costAmt.cost > 0 then | |||
return costAmt.cost | |||
end | |||
end | end | ||
end | end | ||
Line 828: | Line 817: | ||
-- Keep track of modifiers which are present on tools but not exposed within the table, so | -- 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 | -- 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 867: | Line 855: | ||
local cellStart = '\n|style="text-align:right"' | local cellStart = '\n|style="text-align:right"' | ||
if tool.contains ~= nil and tool.contains.modifiers ~= nil then | if tool.contains ~= nil and tool.contains.modifiers ~= nil then | ||
local toolMods = tool.contains.modifiers | |||
for j, modDef in ipairs(modifiers) do | for j, modDef in ipairs(modifiers) do | ||
local modName = modDef.name | local modName = modDef.name | ||
local | local matchRules = { { ["alias"] = modName } } | ||
local matchedMods = Modifiers.getMatchingModifiers(tool.contains.modifiers, matchRules) | |||
local modVal = Modifiers.getModifierValue(matchedMods.matched) or 0 | |||
modTotal[modName] = modTotal[modName] + 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[modName] == 0 and ' class="table-na"') or '') | ||
Line 894: | Line 870: | ||
end | end | ||
table.insert(resultPart, '\n|}') | table.insert(resultPart, '\n|}') | ||
return | return table.concat(resultPart) | ||
end | end | ||
function p.getAxeTable(frame) | function p.getAxeTable(frame) | ||
local modifiers = { | local modifiers = { | ||
{ name = 'decreasedSkillIntervalPercent', header = 'Cut Time Decrease', sign = ' | { name = 'decreasedSkillIntervalPercent', header = 'Cut Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'increasedChanceToDoubleItemsSkill', header = 'Double Items Chance', 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 = 'increasedBirdNestDropRate', header = Icons.Icon({'Bird Nest', 'Drop Chance', type='item', nolink=true}), sign = '+', suffix = '%' }, | ||
Line 915: | Line 887: | ||
function p.getPickaxeTable(frame) | function p.getPickaxeTable(frame) | ||
local modifiers = { | local modifiers = { | ||
{ name = 'decreasedSkillIntervalPercent', header = 'Mining Time Decrease', sign = ' | { name = 'decreasedSkillIntervalPercent', header = 'Mining Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'increasedChanceToDoubleOres', header = '2x Ore Chance', sign = '+', suffix = '%' }, | { name = 'increasedChanceToDoubleOres', header = '2x Ore Chance', sign = '+', suffix = '%' }, | ||
{ name = 'increasedChanceForOneExtraOre', header = '+1 Ore Chance', sign = '+', suffix = '%' }, | { name = 'increasedChanceForOneExtraOre', header = '+1 Ore Chance', sign = '+', suffix = '%' }, | ||
Line 927: | Line 899: | ||
function p.getRodTable(frame) | function p.getRodTable(frame) | ||
local modifiers = { | local modifiers = { | ||
{ name = 'decreasedSkillIntervalPercent', header = 'Catch Time Decrease', sign = ' | { name = 'decreasedSkillIntervalPercent', header = 'Catch Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'increasedChanceForOneExtraFish', header = '+1 Fish Chance', 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 = 'increasedChanceToFindLostChest', header = Icons.Icon({'Lost Chest', type='item', notext=true}) .. ' Chance', sign = '+', suffix = '%' }, | ||
Line 949: | Line 921: | ||
{ name = 'increasedSkillXP', skillID = 'melvorD:Cooking', header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP', sign = '+', suffix = '%' }, | { 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 = '%' }, | { name = 'increasedChancePerfectCookFire', header = Icons.Icon({'Normal Cooking Fire', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance', sign ='+', suffix = '%' }, | ||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = ' | { name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items 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 = ' | { name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '', suffix = '%' } | ||
}, | }, | ||
['Furnace'] = { | ['Furnace'] = { | ||
{ name = 'increasedChancePerfectCookFurnace', header = Icons.Icon({'Basic Furnace', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance', sign = '+', suffix = '%' }, | { 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 = '%' }, | { name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' }, | ||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = ' | { name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = ' | { name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' } | { name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' } | ||
}, | }, | ||
Line 963: | Line 935: | ||
{ name = 'increasedChancePerfectCookPot', header = Icons.Icon({'Basic Pot', type='upgrade', notext=true, nolink=true}) .. ' Perfect Cook Chance', sign = '+', suffix = '%' }, | { 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 = '%' }, | { name = 'increasedChanceToDoubleItemsSkill', skillID = 'melvorD:Cooking', header = '2x Items Chance', sign = '+', suffix = '%' }, | ||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = ' | { name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = ' | { name = 'decreasedSkillIntervalPercent', skillID = 'melvorD:Cooking', header = 'Active Cook Time Decrease', sign = '', suffix = '%' }, | ||
{ name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' }, | { name = 'increasedChanceAdditionalSkillResource', skillID = 'melvorD:Cooking', header = '+1 Item Chance', sign = '+', suffix = '%' }, | ||
{ name = 'increasedMasteryXP', skillID = 'melvorD:Cooking', header = 'Increased Cooking ' .. Icons.Icon({'Mastery', nolink=true}) .. ' XP', sign = '+', suffix = '%'} | { name = 'increasedMasteryXP', skillID = 'melvorD:Cooking', header = 'Increased Cooking ' .. Icons.Icon({'Mastery', nolink=true}) .. ' XP', sign = '+', suffix = '%'} | ||
Line 976: | Line 948: | ||
function p.getShipTable(frame) | function p.getShipTable(frame) | ||
local modifiers = { | local modifiers = { | ||
{ name = 'decreasedSkillIntervalPercent', header = 'Cartography Interval', sign = ' | { name = 'decreasedSkillIntervalPercent', header = 'Cartography Interval', sign = '', suffix = '%' }, | ||
{ name = 'increasedSightRange', header = 'Increased Sight Range', sign = '+', suffix = '' }, | { name = 'increasedSightRange', header = 'Increased Sight Range', sign = '+', suffix = '' }, | ||
{ name = 'increasedSurveyRange', header = 'Increased Survey Range', sign = '+', suffix = ''}, | { name = 'increasedSurveyRange', header = 'Increased Survey Range', sign = '+', suffix = ''}, |