12,883
edits
(Use tabs instead of spaces for indentation) |
(Use printError function) |
||
(44 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Constants = require('Module:Constants') | |||
local GameData = require('Module:GameData') | |||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local | local Pets = require('Module:Pets') | ||
-- Overrides for various items, mostly relating to icon overrides | -- Overrides for various items, mostly relating to icon overrides | ||
local purchOverrides = { | local purchOverrides = { | ||
["Extra Bank Slot"] = { icon = {'Bank Slot', 'upgrade'}, link = 'Bank Slot | ["Extra Bank Slot"] = { icon = {'Bank Slot', 'upgrade'}, link = 'Bank Slot' }, | ||
-- Golbin Raid items | -- Golbin Raid items | ||
["Reduce Wave Skip Cost"] = { icon = {'Melvor Logo', nil}, link = nil }, | ["Reduce Wave Skip Cost"] = { icon = {'Melvor Logo', nil}, link = nil }, | ||
Line 23: | Line 20: | ||
["Prayer"] = { icon = {'Prayer', 'skill'}, link = nil }, | ["Prayer"] = { icon = {'Prayer', 'skill'}, link = nil }, | ||
["Increase Prayer Level"] = { icon = {'Prayer', 'skill'}, link = nil }, | ["Increase Prayer Level"] = { icon = {'Prayer', 'skill'}, link = nil }, | ||
["Increase Prayer Points gained per Wave Completion"] = { icon = {'Prayer', 'skill'}, link = nil } | ["Increase Prayer Points gained per Wave Completion"] = { icon = {'Prayer', 'skill'}, link = nil }, | ||
["Faster Golbin Spawns"] = { icon = {'Timer', nil}, link = nil }, | |||
["Golbin Crate"] = { icon = {'Golbin Crate', 'upgrade'}, link = nil } | |||
} | } | ||
function p.getPurchase(purchaseName) | function p.getPurchase(purchaseName) | ||
local purchList = p.getPurchases(function(purch) return p._getPurchaseName(purch) == purchaseName end) | |||
if purchList ~= nil and not Shared.tableIsEmpty(purchList) then | |||
return purchList[1] | |||
end | |||
end | |||
function p.getPurchaseByID(id) | |||
return GameData.getEntityByID('shopPurchases', id) | |||
end | end | ||
function p. | function p.getPurchases(checkFunc) | ||
return GameData.getEntities('shopPurchases', checkFunc) | |||
end | end | ||
Line 48: | Line 45: | ||
return p.getCostString(purchase.cost, displayInline) | return p.getCostString(purchase.cost, displayInline) | ||
elseif stat == 'requirements' then | elseif stat == 'requirements' then | ||
return p.getRequirementString(purchase. | return p.getRequirementString(purchase.purchaseRequirements) | ||
elseif stat == 'contents' then | elseif stat == 'contents' then | ||
return p._getPurchaseContents(purchase, true) | return p._getPurchaseContents(purchase, true) | ||
elseif stat == 'type' then | elseif stat == 'type' then | ||
return p._getPurchaseType(purchase) | return p._getPurchaseType(purchase) | ||
elseif stat == 'buyLimit' then | |||
return p._getPurchaseBuyLimit(purchase, not displayInline) | |||
elseif stat == 'description' then | |||
return p._getPurchaseDescription(purchase) | |||
elseif stat =='expansionicon' then | |||
return p._getPurchaseExpansionIcon(purchase) | |||
else | else | ||
return purchase[stat] | return purchase[stat] | ||
Line 60: | Line 63: | ||
function p.getPurchaseStat(frame) | function p.getPurchaseStat(frame) | ||
local args = frame.args ~= nil and frame.args or frame | local args = frame.args ~= nil and frame.args or frame | ||
local purchaseName = args[1] | local purchaseName = Shared.fixPagename(args[1]) | ||
local statName = args[2] | local statName = args[2] | ||
local displayInline = (args['inline'] ~= nil and string.lower(args['inline']) == 'true' or false) | local displayInline = (args['inline'] ~= nil and string.lower(args['inline']) == 'true' or false) | ||
Line 66: | Line 69: | ||
local purchaseList = {} | local purchaseList = {} | ||
if statName == 'cost' then | if statName == 'cost' then | ||
purchaseList = p.getPurchases(function( | purchaseList = p.getPurchases(function(purch) return p._getPurchaseName(purch) == purchaseName end) | ||
else | else | ||
purchaseList = {p.getPurchase(purchaseName)} | purchaseList = {p.getPurchase(purchaseName)} | ||
end | end | ||
if Shared. | if Shared.tableIsEmpty(purchaseList) then | ||
return " | return Shared.printError("Couldn't find purchase with name '" .. purchaseName .. "'") | ||
else | else | ||
local resultPart = {} | local resultPart = {} | ||
Line 82: | Line 85: | ||
end | end | ||
function p. | function p._getPurchaseName(purch) | ||
if purch.customName ~= nil then | |||
return purch.customName | |||
elseif purch.contains ~= nil then | |||
local item = nil | |||
if purch.contains.items ~= nil and not Shared.tableIsEmpty(purch.contains.items) then | |||
item = Items.getItemByID(purch.contains.items[1].id) | |||
elseif purch.contains.itemCharges ~= nil and not Shared.tableIsEmpty(purch.contains.itemCharges) then | |||
item = Items.getItemByID(purch.contains.itemCharges.id) | |||
end | |||
if item ~= nil then | |||
return item.name | |||
end | |||
if purch.contains.petID ~= nil then | |||
local pet = Pets.getPetByID(purch.contains.petID) | |||
if pet ~= nil then | |||
return pet.name | |||
end | |||
end | |||
end | |||
return '' | |||
end | |||
function p._getPurchaseExpansionIcon(purch) | |||
if purch.id ~= nil then | |||
return Icons.getExpansionIcon(purch.id) | |||
elseif purch.contains ~= nil then | |||
local item = nil | |||
if purch.contains.items ~= nil and not Shared.tableIsEmpty(purch.contains.items) then | |||
return Icons.getExpansionIcon(purch.contains.items[1].id) | |||
elseif purch.contains.itemCharges ~= nil and not Shared.tableIsEmpty(purch.contains.itemCharges) then | |||
return Icons.getExpansionIcon(purch.contains.itemCharges.id) | |||
end | |||
if purch.contains.petID ~= nil then | |||
return Icons.getExpansionIcon(purch.contains.petID) | |||
end | |||
end | |||
return '' | |||
end | end | ||
function p. | function p._getPurchaseDescription(purch) | ||
if | if purch.customDescription ~= nil then | ||
return | local templateData = p._getPurchaseTemplateData(purch) | ||
return Shared.applyTemplateData(purch.customDescription, templateData) | |||
elseif purch.contains ~= nil then | |||
local item = nil | |||
if purch.contains.modifiers ~= nil then | |||
return Constants.getModifiersText(purch.contains.modifiers, false) | |||
elseif purch.contains.petID ~= nil then | |||
local pet = Pets.getPetByID(purch.contains.petID) | |||
return Pets._getPetEffect(pet) | |||
elseif purch.contains.items ~= nil and Shared.tableCount(purch.contains.items) == 1 then | |||
item = Items.getItemByID(purch.contains.items[1].id) | |||
elseif purch.contains.itemCharges ~= nil then | |||
item = Items.getItemByID(purch.contains.itemCharges.id) | |||
end | end | ||
if item ~= nil then | |||
if item.customDescription ~= nil then | |||
return item.customDescription | |||
elseif item.modifiers ~= nil then | |||
return Constants.getModifiersText(item.modifiers, false) | |||
end | end | ||
end | end | ||
end | end | ||
return '' | |||
end | |||
if | function p.getCostString(cost, inline) | ||
for i, | local displayInline = (inline ~= nil and inline or false) | ||
local | local costArray = {} | ||
local currencies = {'gp', 'slayerCoins', 'raidCoins'} | |||
for i, currency in ipairs(currencies) do | |||
if cost[currency] ~= nil then | |||
local costStr = p.getCurrencyCostString(cost[currency], currency) | |||
if costStr ~= nil then | |||
table.insert(costArray, costStr) | |||
end | |||
end | |||
end | |||
if cost.items ~= nil and not Shared.tableIsEmpty(cost.items) then | |||
local itemArray = {} | |||
for i, itemCost in ipairs(cost.items) do | |||
local item = Items.getItemByID(itemCost.id) | |||
if item ~= nil then | |||
table.insert(itemArray, Icons.Icon({item.name, type="item", notext=(not displayInline and true or nil), qty=itemCost.quantity})) | |||
end | |||
end | end | ||
if not Shared.tableIsEmpty(itemArray) then | |||
table.insert(costArray, table.concat(itemArray, ', ')) | |||
end | |||
end | end | ||
if not Shared.tableIsEmpty(costArray) then | |||
local sep, lastSep = '<br/>', '<br/>' | |||
if displayInline then | |||
sep = ', ' | |||
lastSep = Shared.tableCount(costArray) > 2 and ', and ' or ' and ' | |||
end | |||
return mw.text.listToText(costArray, sep, lastSep) | |||
end | |||
end | |||
-- Generates description template data. See: shop.js, getDescriptionTemplateData() | |||
function p._getPurchaseTemplateData(purchase) | |||
-- qty is a static value of 1 for Bank slots | |||
local templateData = { qty = 1 } | |||
if purchase.contains ~= nil and purchase.contains.items ~= nil then | |||
for i, itemDef in ipairs(purchase.contains.items) do | |||
templateData['qty' .. i] = itemDef.quantity | |||
end | end | ||
end | end | ||
return templateData | |||
end | |||
function p.getCurrencyCostString(cost, currency) | |||
local decoratorList = { | |||
["gp"] = Icons.GP, | |||
["slayerCoins"] = Icons.SC, | |||
["raidCoins"] = Icons.RC | |||
} | |||
local decorator = nil | |||
if currency ~= nil then | |||
decorator = decoratorList[currency] | |||
end | |||
if decorator == nil then | |||
decorator = function(cost) return cost end | |||
end | |||
if cost.type == 'BankSlot' then | |||
-- Unusual bit of code that basically evaluates wikitext '<math>C_b</math>*' | |||
return mw.getCurrentFrame():callParserFunction('#tag:math', {'C_b'}) .. '*' | |||
elseif cost.type == 'Linear' and (cost.initial > 0 or cost.scaling > 0) then | |||
return decorator(cost.initial) .. '<br/>+' .. decorator(cost.scaling) .. ' for each purchase' | |||
elseif cost.type == 'Glove' or cost.type == 'Fixed' and cost.cost > 0 then | |||
-- Type Glove exists in game so the Merchan's Permit cost reduction can be applied, | |||
-- it makes no difference here | |||
return decorator(cost.cost) | |||
end | |||
end | |||
if reqs | function p.getRequirementString(reqs) | ||
if reqs == nil or Shared.tableIsEmpty(reqs) then | |||
return 'None' | |||
end | end | ||
if | local reqArray = {} | ||
for i, req in ipairs(reqs) do | |||
if req.type == 'SkillLevel' then | |||
local skillName = Constants.getSkillName(req.skillID) | |||
if skillName ~= nil then | |||
table.insert(reqArray, Icons._SkillReq(skillName, req.level)) | |||
end | |||
elseif req.type == 'DungeonCompletion' then | |||
local dung = GameData.getEntityByID('dungeons', req.dungeonID) | |||
if dung ~= nil then | |||
local dungStr = 'Complete ' .. Icons.Icon({dung.name, type='dungeon'}) | |||
if req.count > 1 then | |||
dungStr = dungStr .. ' ' .. Shared.formatnum(req.count) .. ' times' | |||
end | |||
table.insert(reqArray, dungStr) | |||
end | |||
elseif req.type == 'SlayerTask' then | |||
table.insert(reqArray, 'Complete ' .. Shared.formatnum(req.count) .. ' ' .. req.tier .. ' Slayer Tasks') | |||
elseif req.type == 'TownshipTask' then | |||
table.insert(reqArray, 'Complete ' .. Shared.formatnum(req.count) .. ' Township Tasks') | |||
elseif req.type == 'TownshipBuilding' then | |||
local tsData = GameData.getSkillData('melvorD:Township') | |||
if tsData ~= nil and tsData.buildings ~= nil then | |||
local building = GameData.getEntityByID(tsData.buildings, req.buildingID) | |||
if building ~= nil then | |||
table.insert(reqArray, 'Have ' .. Shared.formatnum(req.count) .. ' ' .. building.name .. ' actively built in Township') | |||
end | |||
end | |||
elseif req.type == 'ShopPurchase' then | |||
local shopPurch = p.getPurchaseByID(req.purchaseID) | |||
if shopPurch ~= nil then | |||
table.insert(reqArray, p._getPurchaseIcon({shopPurch}) .. ' Purchased') | |||
end | |||
elseif req.type == 'Completion' then | |||
local ns = GameData.getEntityByName('namespaces', req.namespace) | |||
if ns ~= nil then | |||
table.insert(reqArray, req.percent .. '% ' .. ns.displayName .. ' Completion') | |||
end | |||
elseif req.type == 'AllSkillLevels' then | |||
local reqText = 'Level ' .. req.level .. ' in all skills' | |||
if req.exceptions ~= nil and not Shared.tableIsEmpty(req.exceptions) then | |||
local exceptSkills = {} | |||
for i, skillID in ipairs(req.exceptions) do | |||
local skillName = Constants.getSkillName(skillID) | |||
if skillName ~= nil then | |||
table.insert(exceptSkills, Icons.Icon({skillName, type='skill'})) | |||
end | |||
end | |||
reqText = reqText .. ' except for ' .. table.concat(exceptSkills, ', ') | |||
end | |||
table.insert(reqArray, reqText) | |||
else | |||
table.insert(reqArray, Shared.printError('Unknown requirement: ' .. (req.type or 'nil'))) | |||
end | |||
end | |||
if Shared.tableIsEmpty(reqArray) then | |||
return 'None' | |||
else | |||
return table.concat(reqArray, '<br/>') | |||
end | |||
end | end | ||
Line 167: | Line 297: | ||
if purchase.contains == nil then | if purchase.contains == nil then | ||
return 'Unknown' | return 'Unknown' | ||
elseif purchase.contains. | elseif purchase.contains.petID ~= nil then | ||
return 'Pet' | return 'Pet' | ||
elseif purchase.contains.itemCharges ~= nil then | |||
return 'Item' | |||
elseif purchase.contains.modifiers ~= nil or purchase.contains.items == nil or Shared.tableCount(purchase.contains.items) == 0 then | elseif purchase.contains.modifiers ~= nil or purchase.contains.items == nil or Shared.tableCount(purchase.contains.items) == 0 then | ||
return 'Upgrade' | return 'Upgrade' | ||
Line 181: | Line 313: | ||
if asList == nil then asList = true end | if asList == nil then asList = true end | ||
local containArray = {} | local containArray = {} | ||
if purchase.contains.items ~= nil and Shared. | local GPTotal = 0 | ||
if purchase.contains ~= nil then | |||
if purchase.contains.items ~= nil and not Shared.tableIsEmpty(purchase.contains.items) then | |||
if not asList then | |||
table.insert(containArray, '{| class="wikitable sortable stickyHeader"') | |||
table.insert(containArray, '|- class="headerRow-0"') | |||
table.insert(containArray, '! colspan="2" | Item !! Quantity !! Price') | |||
end | |||
for i, itemLine in ipairs(purchase.contains.items) do | |||
local item = Items.getItemByID(itemLine.id) | |||
local itemQty = itemLine.quantity | |||
if asList then | |||
table.insert(containArray, Icons.Icon({item.name, type='item', qty=itemQty})) | |||
else | |||
local GPVal = item.sellsFor * itemQty | |||
GPTotal = GPTotal + GPVal | |||
table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({item.name, type='item', notext=true, size='25'})) | |||
table.insert(containArray, '|data-sort-value="'..item.name..'"|'.. Icons.getExpansionIcon(item.id) .. Icons.Icon({item.name, type='item', noicon=true}) .. '\r\n| data-sort-value="' .. itemQty .. '" style="text-align:right" | ' .. Shared.formatnum(itemQty)) | |||
table.insert(containArray, '| data-sort-value="' .. GPVal .. '"| ' .. Icons.GP(GPVal)) | |||
end | |||
end | |||
end | end | ||
if purchase.contains.itemCharges ~= nil and purchase.contains.itemCharges.quantity > 0 then | |||
local gloveItem = Items.getItemByID(purchase.contains.itemCharges.id) | |||
local chargeQty = purchase.contains.itemCharges.quantity | |||
if gloveItem ~= nil then | |||
if asList then | |||
table.insert(containArray, '+'..Shared.formatnum(chargeQty)..' '..Icons.Icon({gloveItem.name, type='item'})..' Charges') | |||
else | |||
table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({gloveItem.name, type='item', notext=true, size='25'})) | |||
table.insert(containArray, '| ' .. Icons.Icon({gloveItem.name, type='item', noicon=true}) .. ' Charges\r\n| data-sort-value="' .. chargeQty .. '" style="text-align:right" | ' .. Shared.formatnum(chargeQty)) | |||
table.insert(containArray, '| data-sort-value="0"| ' .. Icons.GP(0)) | |||
end | |||
end | |||
end | end | ||
end | end | ||
if | if not asList and not Shared.tableIsEmpty(containArray) then | ||
table.insert(containArray, '|- class="sortbottom"\r\n! colspan="3"| Total\r\n| ' .. Icons.GP(GPTotal) .. '\r\n|}') | |||
end | end | ||
local delim = (asList and '<br/>' or '\r\n') | local delim = (asList and '<br/>' or '\r\n') | ||
Line 218: | Line 364: | ||
if purchase == nil then | if purchase == nil then | ||
return " | return Shared.printError("Couldn't find purchase with name '" .. purchaseName .. "'") | ||
else | else | ||
return p._getPurchaseContents(purchase, asList) | return p._getPurchaseContents(purchase, asList) | ||
Line 226: | Line 372: | ||
function p._getPurchaseBuyLimit(purchase, asList) | function p._getPurchaseBuyLimit(purchase, asList) | ||
if asList == nil then asList = true end | if asList == nil then asList = true end | ||
local defaultLimit = (purchase.defaultBuyLimit == 0 and 'Unlimited') or Shared.formatnum(purchase.defaultBuyLimit) | |||
if purchase.buyLimitOverrides == nil or Shared.tableIsEmpty(purchase.buyLimitOverrides) then | |||
-- Same limit for all game modes | |||
return defaultLimit | |||
else | |||
-- The limit varies depending on game mode | |||
local limitTable = {} | |||
local gamemodeHasIcon = { 'melvorF:Hardcore', 'melvorF:Adventure' } | |||
for i, buyLimit in ipairs(purchase.buyLimitOverrides) do | |||
local gamemode = GameData.getEntityByID('gamemodes', buyLimit.gamemodeID) | |||
if gamemode ~= nil then | |||
local gamemodeText = nil | |||
if Shared.contains(gamemodeHasIcon, gamemode.id) then | |||
gamemodeText = Icons.Icon({gamemode.name, notext=(not asList or nil)}) | |||
else | |||
gamemodeText = '[[Game Mode#' .. gamemode.name .. '|' .. gamemode.name .. ']]' | |||
end | |||
local limitText = (buyLimit.maximum == 0 and 'Unlimited') or Shared.formatnum(buyLimit.maximum) | |||
table.insert(limitTable, limitText .. (asList and ' for ' or ' ') .. gamemodeText) | |||
end | |||
end | |||
table.insert(limitTable, defaultLimit .. (asList and ' for ' or ' ') .. 'All other game modes') | |||
return table.concat(limitTable, (asList and ' or ' or '<br/>')) | |||
end | |||
end | end | ||
Line 266: | Line 405: | ||
if purchase == nil then | if purchase == nil then | ||
return " | return Shared.printError("Couldn't find purchase with name '" .. purchaseName .. "'") | ||
else | else | ||
return p._getPurchaseBuyLimit(purchase, asList) | return p._getPurchaseBuyLimit(purchase, asList) | ||
Line 275: | Line 414: | ||
function p._getPurchaseIcon(iconArgs) | function p._getPurchaseIcon(iconArgs) | ||
local purchase = iconArgs[1] | local purchase = iconArgs[1] | ||
local override = purchOverrides[ | local purchaseName = p._getPurchaseName(purchase) | ||
local override = purchOverrides[purchaseName] | |||
local purchType = p._getPurchaseType(purchase) | local purchType = p._getPurchaseType(purchase) | ||
-- Amend iconArgs before passing to Icons.Icon() | -- Amend iconArgs before passing to Icons.Icon() | ||
iconArgs[1] = ((override ~= nil and override.icon[1]) or | iconArgs[1] = ((override ~= nil and override.icon[1]) or purchaseName) | ||
if override ~= nil then | if override ~= nil then | ||
iconArgs['type'] = override.icon[2] | iconArgs['type'] = override.icon[2] | ||
Line 293: | Line 433: | ||
function p.getPurchaseIcon(frame) | function p.getPurchaseIcon(frame) | ||
local args = frame.args ~= nil and frame.args or frame | local args = frame.args ~= nil and frame.args or frame | ||
local purchaseName = args[1] | local purchaseName = Shared.fixPagename(args[1]) | ||
local purchase = p.getPurchase(purchaseName) | local purchase = p.getPurchase(purchaseName) | ||
if purchase == nil then | if purchase == nil then | ||
return " | return Shared.printError("Couldn't find purchase with name '" .. tostring(purchaseName) .. "'") | ||
else | else | ||
args[1] = purchase | args[1] = purchase | ||
Line 308: | Line 448: | ||
for j, curr in ipairs(costCurrencies) do | for j, curr in ipairs(costCurrencies) do | ||
local costAmt = purchase.cost[curr] | local costAmt = purchase.cost[curr] | ||
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 | ||
Line 320: | Line 464: | ||
["Cost"] = 'style="min-width:100px"' | ["Cost"] = 'style="min-width:100px"' | ||
} | } | ||
local usedColumns, purchHeader, sortOrder, headerProps = {}, 'Purchase', nil, {} | local usedColumns, purchHeader, sortOrder, headerProps, stickyHeader = {}, 'Purchase', nil, {}, true | ||
-- Process options if specified | -- Process options if specified | ||
Line 343: | Line 487: | ||
if options.headerProps ~= nil and type(options.headerProps) == 'table' then | if options.headerProps ~= nil and type(options.headerProps) == 'table' then | ||
headerProps = options.headerProps | headerProps = options.headerProps | ||
end | |||
-- Sticky header class | |||
if options.stickyHeader ~= nil then | |||
if type(options.stickyHeader) == 'boolean' then | |||
stickyHeader = options.stickyHeader | |||
elseif type(options.stickyHeader) == 'string' and string.lower(options.stickyHeader) == 'false' then | |||
stickyHeader = false | |||
end | |||
end | end | ||
end | end | ||
Line 356: | Line 508: | ||
local resultPart = {} | local resultPart = {} | ||
-- Generate header | -- Generate header | ||
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"') | table.insert(resultPart, '{| class="wikitable sortable' .. (stickyHeader and ' stickyHeader' or '') .. '"') | ||
table.insert(resultPart, '|- class="headerRow-0"') | table.insert(resultPart, '|- class="headerRow-0"') | ||
for i, column in ipairs(usedColumns) do | for i, column in ipairs(usedColumns) do | ||
Line 363: | Line 515: | ||
end | end | ||
if sortOrder == nil then | if sortOrder == nil then | ||
Purchases = GameData.sortByOrderTable(Purchases, GameData.rawData.shopDisplayOrder, true) | |||
else | else | ||
table.sort(Purchases, sortOrder) | table.sort(Purchases, sortOrder) | ||
end | end | ||
for i, purchase in | for i, purchase in ipairs(Purchases) do | ||
local purchName = p._getPurchaseName(purchase) | |||
local purchExpIcon = p._getPurchaseExpansionIcon(purchase) | |||
local purchOverride = nil | local purchOverride = nil | ||
if purchOverrides ~= nil then | if purchOverrides ~= nil then | ||
purchOverride = purchOverrides[ | purchOverride = purchOverrides[purchName] | ||
end | end | ||
Line 386: | Line 538: | ||
purchLink = purchOverride.link .. '|' | purchLink = purchOverride.link .. '|' | ||
end | end | ||
end | end | ||
local purchSortName = purchName | |||
if iconNoLink == nil or iconNoLink ~= true then purchName = '[[' .. purchLink .. purchName .. ']]' end | if iconNoLink == nil or iconNoLink ~= true then purchName = '[[' .. purchLink .. purchName .. ']]' end | ||
Line 397: | Line 548: | ||
table.insert(resultPart, '|style="min-width:25px"|' .. p._getPurchaseIcon({purchase, notext=true, size='50'})) | table.insert(resultPart, '|style="min-width:25px"|' .. p._getPurchaseIcon({purchase, notext=true, size='50'})) | ||
--table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({iconName, type=iconType, notext=true, nolink=iconNoLink, size='50'})) | --table.insert(resultPart, '|style="min-width:25px"|' .. Icons.Icon({iconName, type=iconType, notext=true, nolink=iconNoLink, size='50'})) | ||
table.insert(resultPart, '| ' .. purchName) | table.insert(resultPart, '| data-sort-value="'..purchSortName..'"|'..purchExpIcon .. purchName) | ||
elseif column == 'Type' then | elseif column == 'Type' then | ||
table.insert(resultPart, '| ' .. purchType) | table.insert(resultPart, '| ' .. purchType) | ||
elseif column == 'Description' then | elseif column == 'Description' then | ||
table.insert(resultPart, '| ' .. purchase | table.insert(resultPart, '| ' .. p._getPurchaseDescription(purchase)) | ||
elseif column == 'Cost' then | elseif column == 'Cost' then | ||
local cellProp = '|style="text-align:right;"' | local cellProp = '|style="text-align:right;"' | ||
Line 408: | Line 559: | ||
table.insert(resultPart, cellProp .. '| ' .. costString) | table.insert(resultPart, cellProp .. '| ' .. costString) | ||
elseif column == 'Requirements' then | elseif column == 'Requirements' then | ||
table.insert(resultPart, '| ' .. p.getRequirementString(purchase. | table.insert(resultPart, '| ' .. p.getRequirementString(purchase.purchaseRequirements)) | ||
elseif column == 'Buy Limit' then | elseif column == 'Buy Limit' then | ||
local buyLimit = p._getPurchaseBuyLimit(purchase, false) | local buyLimit = p._getPurchaseBuyLimit(purchase, false) | ||
Line 432: | Line 583: | ||
-- sortOrder: A function determining the order in which table items appear | -- sortOrder: A function determining the order in which table items appear | ||
-- purchaseHeader: Specifies header text for the Purchase column if not 'Purchase' | -- purchaseHeader: Specifies header text for the Purchase column if not 'Purchase' | ||
-- stickyHeader: Specifies if the table will have a sticky header or not | |||
function p.getShopTable(frame) | function p.getShopTable(frame) | ||
local cat = frame.args ~= nil and frame.args[1] or frame | local cat = frame.args ~= nil and frame.args[1] or frame | ||
Line 439: | Line 591: | ||
if frame.args.purchaseHeader ~= nil then options.purchaseHeader = frame.args.purchaseHeader end | if frame.args.purchaseHeader ~= nil then options.purchaseHeader = frame.args.purchaseHeader end | ||
if frame.args.sortOrder ~= nil then options.sortOrder = frame.args.sortOrder end | if frame.args.sortOrder ~= nil then options.sortOrder = frame.args.sortOrder end | ||
if frame.args.stickyHeader ~= nil then options.stickyHeader = frame.args.stickyHeader end | |||
if frame.args.columnProps ~= nil then | if frame.args.columnProps ~= nil then | ||
local columnPropValues = Shared.splitString(frame.args.columnProps, ',') | local columnPropValues = Shared.splitString(frame.args.columnProps, ',') | ||
Line 451: | Line 604: | ||
end | end | ||
end | end | ||
local shopCat = GameData.getEntityByName('shopCategories', cat) | |||
if shopCat == nil then | if shopCat == nil then | ||
return ' | return Shared.printError('Invalid category ' .. cat) | ||
else | else | ||
return p._getShopTable( | local catPurchases = p.getPurchases(function(purch) return purch.category == shopCat.id end) | ||
return p._getShopTable(catPurchases, options) | |||
end | end | ||
end | end | ||
function p.getItemCostArray(itemID) | function p.getItemCostArray(itemID) | ||
local purchaseArray = {} | |||
for i, purchase in ipairs(GameData.rawData.shopPurchases) do | |||
if purchase.cost ~= nil and purchase.cost.items ~= nil then | |||
for j, itemCost in ipairs(purchase.cost.items) do | |||
if itemCost.id == itemID then | |||
table.insert(purchaseArray, { ["purchase"] = purchase, ["qty"] = itemCost.quantity }) | |||
break | |||
end | |||
end | |||
end | |||
end | |||
return purchaseArray | |||
end | end | ||
function p.getItemSourceArray(itemID) | function p.getItemSourceArray(itemID) | ||
local purchaseArray = {} | |||
for i, purchase in ipairs(GameData.rawData.shopPurchases) do | |||
if purchase.contains ~= nil then | |||
if purchase.contains.items ~= nil then | |||
for j, itemContains in ipairs(purchase.contains.items) do | |||
if itemContains.id == itemID then | |||
table.insert(purchaseArray, { ["purchase"] = purchase, ["qty"] = itemContains.quantity }) | |||
break | |||
end | |||
end | |||
end | |||
if purchase.contains.itemCharges ~= nil and purchase.contains.itemCharges.id == itemID then | |||
table.insert(purchaseArray, { ["purchase"] = purchase, ["qty"] = 1 }) | |||
end | |||
end | |||
end | |||
return purchaseArray | |||
end | end | ||
Line 517: | Line 652: | ||
result = result..'\r\n!colspan="2"|'..Icons.Icon({'Shop'})..' Purchase' | result = result..'\r\n!colspan="2"|'..Icons.Icon({'Shop'})..' Purchase' | ||
if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 1 then | if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 1 then | ||
result = result..' - '..Icons.Icon({purchase | result = result..' - '..p._getPurchaseExpansionIcon(purchase)..Icons.Icon({p._getPurchaseName(purchase), type='item'}) | ||
end | end | ||
Line 524: | Line 659: | ||
result = result..'\r\n|-\r\n!style="text-align:right;"|Requirements' | result = result..'\r\n|-\r\n!style="text-align:right;"|Requirements' | ||
result = result..'\r\n|'..p.getRequirementString(purchase. | result = result..'\r\n|'..p.getRequirementString(purchase.purchaseRequirements) | ||
result = result..'\r\n|-\r\n!style="text-align:right;"|Contains' | result = result..'\r\n|-\r\n!style="text-align:right;"|Contains' | ||
Line 537: | Line 672: | ||
local purchaseArray = p.getItemSourceArray(item.id) | local purchaseArray = p.getItemSourceArray(item.id) | ||
for i, purchase in | for i, purchase in ipairs(purchaseArray) do | ||
table.insert(tableArray, p._getPurchaseTable(purchase)) | table.insert(tableArray, p._getPurchaseTable(purchase.purchase)) | ||
end | end | ||
Line 548: | Line 683: | ||
local item = Items.getItem(itemName) | local item = Items.getItem(itemName) | ||
if item == nil then | if item == nil then | ||
return | return Shared.printError('No item named ' .. itemName .. ' exists in the data module') | ||
end | end | ||
Line 555: | Line 690: | ||
function p.getShopMiscUpgradeTable() | function p.getShopMiscUpgradeTable() | ||
local purchList = p.getPurchases(function( | local purchList = p.getPurchases(function(purch) return (purch.category == 'melvorD:General' and string.find(purch.id, '^melvorD:Auto_Eat') == nil) or Shared.contains({'melvorTotH:SignOfTheStars', 'melvorTotH:SummonersAltar'}, purch.id) end) | ||
return p._getShopTable(purchList, { columns = { 'Purchase', 'Description', 'Cost', 'Requirements' }, purchaseHeader = 'Upgrade' }) | return p._getShopTable(purchList, { columns = { 'Purchase', 'Description', 'Cost', 'Requirements' }, purchaseHeader = 'Upgrade' }) | ||
end | end | ||
function p. | function p._getShopSkillcapeTable(showSuperior) | ||
local capeList = p.getPurchases(function( | local categoryID = (showSuperior and 'melvorTotH:SuperiorSkillcapes') or 'melvorD:Skillcapes' | ||
local sortOrderFunc = function(a, b) | local capeList = p.getPurchases(function(purch) return purch.category == categoryID end) | ||
local sortOrderFunc = | |||
function(a, b) | |||
local costA, costB = p._getPurchaseSortValue(a), p._getPurchaseSortValue(b) | |||
if costA == costB then | |||
return p._getPurchaseName(a) < p._getPurchaseName(b) | |||
else | |||
return costA < costB | |||
end | |||
end | |||
return p._getShopTable(capeList, { | return p._getShopTable(capeList, { | ||
columns = { 'Purchase', 'Description', 'Cost' }, | columns = { 'Purchase', 'Description', 'Cost' }, | ||
purchaseHeader = 'Cape', | purchaseHeader = 'Cape', | ||
sortOrder = sortOrderFunc, | sortOrder = sortOrderFunc, | ||
stickyHeader = false, | |||
headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'} | headerProps = {["Purchase"] = 'colspan="2" style="width:200px;"', ["Cost"] = 'style=width:120px;'} | ||
}) | }) | ||
end | |||
function p.getShopSkillcapeTable(frame) | |||
local capeCategory = frame.args ~= nil and frame.args[1] or frame | |||
local showSuperior = string.lower(capeCategory) == 'superior' | |||
return p._getShopSkillcapeTable(showSuperior) | |||
end | |||
function p.getSkillcapeTable(frame) | |||
local skillName = frame.args ~= nil and frame.args[1] or frame | |||
local capeList = p.getPurchases(function(purch) return Shared.contains({'melvorD:Skillcapes', 'melvorTotH:SuperiorSkillcapes'}, purch.category) and string.find(p._getPurchaseName(purch), skillName) end) | |||
if Shared.tableIsEmpty(capeList) then | |||
return '' | |||
else | |||
local resultPart = {} | |||
table.insert(resultPart, '{| class="wikitable"\r\n') | |||
table.insert(resultPart, '!Skillcape!!Name!!Requirements!!Effect') | |||
for i, cape in ipairs(capeList) do | |||
local capeItem = Items.getItemByID(cape.contains.items[1].id) | |||
if capeItem ~= nil then | |||
table.insert(resultPart, '\r\n|-\r\n| ' .. Icons.Icon({capeItem.name, type='item', size='60', notext=true})) | |||
table.insert(resultPart, '\r\n| data-sort-value="'..capeItem.name..'"|'..Icons.getExpansionIcon(capeItem.id) .. Icons.Icon({capeItem.name, type='item', noicon=true})) | |||
table.insert(resultPart, '\r\n| ' .. p.getRequirementString(cape.purchaseRequirements)) | |||
table.insert(resultPart, '\r\n| ' .. p._getPurchaseDescription(cape)) | |||
end | |||
end | |||
table.insert(resultPart, '\r\n|}') | |||
return table.concat(resultPart) | |||
end | |||
end | end | ||
function p.getAutoEatTable() | function p.getAutoEatTable() | ||
local resultPart = {} | local resultPart = {} | ||
local purchasesAE = p.getPurchases(function( | local purchasesAE = p.getPurchases(function(purch) return purch.category == 'melvorD:General' and string.find(purch.id, '^melvorD:Auto_Eat') ~= nil end) | ||
-- Table header | -- Table header | ||
Line 587: | Line 758: | ||
local mods = {["increasedAutoEatEfficiency"] = 0, ["increasedAutoEatHPLimit"] = 0, ["increasedAutoEatThreshold"] = 0} | local mods = {["increasedAutoEatEfficiency"] = 0, ["increasedAutoEatHPLimit"] = 0, ["increasedAutoEatThreshold"] = 0} | ||
for i, purchase in ipairs(purchasesAE) do | for i, purchase in ipairs(purchasesAE) do | ||
local purchaseName = p._getPurchaseName(purchase) | |||
-- Modifiers must be accumulated as we go | -- Modifiers must be accumulated as we go | ||
for modName, modValue in pairs(mods) do | for modName, modValue in pairs(mods) do | ||
Line 594: | Line 766: | ||
end | end | ||
table.insert(resultPart, '|-\r\n|style="min-width:25px; text-align:center;" data-sort-value="' .. purchaseName .. '"| ' .. Icons.Icon({purchaseName, type='upgrade', size=50, notext=true})) | |||
table.insert(resultPart, '|-\r\n|style="min-width:25px; text-align:center;" data-sort-value="' .. | table.insert(resultPart, '| ' .. Icons.Icon({purchaseName, type='upgrade', noicon=true})) | ||
table.insert(resultPart, '| ' .. Icons.Icon({ | |||
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.increasedAutoEatThreshold .. '" | ' .. Shared.formatnum(Shared.round(mods.increasedAutoEatThreshold, 0, 0)) .. '%') | table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.increasedAutoEatThreshold .. '" | ' .. Shared.formatnum(Shared.round(mods.increasedAutoEatThreshold, 0, 0)) .. '%') | ||
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.increasedAutoEatEfficiency .. '" | ' .. Shared.formatnum(Shared.round(mods.increasedAutoEatEfficiency, 0, 0)) .. '%') | table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.increasedAutoEatEfficiency .. '" | ' .. Shared.formatnum(Shared.round(mods.increasedAutoEatEfficiency, 0, 0)) .. '%') | ||
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.increasedAutoEatHPLimit .. '" | ' .. Shared.formatnum(Shared.round(mods.increasedAutoEatHPLimit, 0, 0)) .. '%') | table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.increasedAutoEatHPLimit .. '" | ' .. Shared.formatnum(Shared.round(mods.increasedAutoEatHPLimit, 0, 0)) .. '%') | ||
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. | table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. p._getPurchaseSortValue(purchase) .. '" | ' .. p.getCostString(purchase.cost, false)) | ||
end | end | ||
table.insert(resultPart, '|}') | table.insert(resultPart, '|}') | ||
Line 613: | Line 784: | ||
local getGodDungeon = | local getGodDungeon = | ||
function(reqs) | function(reqs) | ||
for i, req in ipairs(reqs) do | |||
if req.type == 'DungeonCompletion' and string.find(req.dungeonID, 'God_Dungeon$') ~= nil then | |||
return GameData.getEntityByID('dungeons', req.dungeonID) | |||
end | |||
end | |||
end | |||
local upgradeList = p.getPurchases( | local upgradeList = p.getPurchases( | ||
function( | function(purch) | ||
if | if purch.category == 'melvorD:SkillUpgrades' and purch.purchaseRequirements ~= nil then | ||
return getGodDungeon(purch. | return getGodDungeon(purch.purchaseRequirements) ~= nil | ||
end | end | ||
return false | return false | ||
end) | end) | ||
if Shared. | if Shared.tableIsEmpty(upgradeList) then | ||
return '' | |||
end | |||
-- Table header | -- Table header | ||
Line 637: | Line 809: | ||
-- Rows for each God upgrade | -- Rows for each God upgrade | ||
for i, upgrade in ipairs(upgradeList) do | for i, upgrade in ipairs(upgradeList) do | ||
local dung = getGodDungeon(upgrade. | local upgradeName = p._getPurchaseName(upgrade) | ||
local dung = getGodDungeon(upgrade.purchaseRequirements) | |||
local costSortValue = p._getPurchaseSortValue(upgrade) | local costSortValue = p._getPurchaseSortValue(upgrade) | ||
table.insert(resultPart, '|-\r\n|style="min-width:25px; text-align:center;" data-sort-value="' .. | table.insert(resultPart, '|-\r\n|style="min-width:25px; text-align:center;" data-sort-value="' .. upgradeName .. '"| ' ..p._getPurchaseExpansionIcon(upgrade).. Icons.Icon({upgradeName, type='upgrade', size=50, notext=true})) | ||
table.insert(resultPart, '| ' .. Icons.Icon({ | table.insert(resultPart, '| ' .. Icons.Icon({upgradeName, type='upgrade', noicon=true})) | ||
table.insert(resultPart, '| ' .. upgrade | table.insert(resultPart, '| ' .. p._getPurchaseDescription(upgrade)) | ||
table.insert(resultPart, '| data-sort-value="' .. dung.name .. '"| ' .. Icons.Icon({dung.name, type='dungeon'})) | table.insert(resultPart, '| data-sort-value="' .. dung.name .. '"| ' .. Icons.Icon({dung.name, type='dungeon'})) | ||
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. costSortValue .. '"| ' .. p.getCostString(upgrade.cost, false)) | table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. costSortValue .. '"| ' .. p.getCostString(upgrade.cost, false)) | ||
Line 648: | Line 821: | ||
return table.concat(resultPart, '\r\n') | return table.concat(resultPart, '\r\n') | ||
end | |||
function p.getToolTable(toolName, searchString, modifiers, skillID) | |||
local skillName = nil | |||
if type(skillID) == 'string' then | |||
skillName = Constants.getSkillName(skillID) | |||
end | |||
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 | |||
local modTotal = {} | |||
for i, modDef in ipairs(modifiers) do | |||
modTotal[modDef.name] = 0 | |||
end | |||
local headerRowSpan = (Shared.tableIsEmpty(toolArray) and 1) or 2 | |||
local resultPart = {} | |||
table.insert(resultPart, '{| class="wikitable"') | |||
table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '" colspan="2"| Name') | |||
table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '"| ' .. (skillName == nil and 'Requirements' or Icons.Icon({skillName, type='skill', notext=true}) .. ' Level')) | |||
table.insert(resultPart, '\n!rowspan="' .. headerRowSpan .. '"| Cost') | |||
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 | |||
modTotal[modName] = modTotal[modName] + modVal | |||
else | |||
modVal = 0 | |||
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 | |||
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 | end | ||
Line 655: | Line 958: | ||
local validCategories = {'Cooking Fire', 'Furnace', 'Pot'} | local validCategories = {'Cooking Fire', 'Furnace', 'Pot'} | ||
if category == nil or not Shared.contains({'Cooking Fire', 'Furnace', 'Pot'}, category) then | if category == nil or not Shared.contains({'Cooking Fire', 'Furnace', 'Pot'}, category) then | ||
return ' | return Shared.printError('Invalid category specified. Must be one of the following: ' .. mw.text.listToText(validCategories, ', ', ' or ')) | ||
end | end | ||
local categoryShort = string.match(category, '[^%s]+$') | local categoryShort = string.match(category, '[^%s]+$') | ||
local | local modifiers = { | ||
['Cooking Fire'] = { | |||
{ name = 'increasedSkillXP', skillID = 'melvorD:Cooking', header = 'Bonus ' .. Icons.Icon({'Cooking', type='skill', notext=true}) .. ' XP', sign = '+', suffix = '%' }, | |||
{ name = 'increasedChancePerfectCookFire', header = 'Fire Perfect Cook Chance', sign ='+', suffix = '%' }, | |||
{ name = 'decreasedPassiveCookInterval', header = 'Passive Cook Time Decrease', 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) | |||
return | |||
end | end | ||
return p | return p |