17,097
edits
Tag: Undo |
(Amend various functions for AoD support) |
||
Line 183: | Line 183: | ||
return decorator(cost.initial) .. '<br/>+' .. decorator(cost.scaling) .. ' for each purchase' | return decorator(cost.initial) .. '<br/>+' .. decorator(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 | -- 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 decorator(cost.cost) | return decorator(cost.cost) | ||
Line 425: | Line 425: | ||
table.insert(resultPart, '|}') | table.insert(resultPart, '|}') | ||
return table.concat(resultPart, ' | return table.concat(resultPart, '\n') | ||
end | end | ||
Line 543: | Line 543: | ||
function p.getShopMiscUpgradeTable() | function p.getShopMiscUpgradeTable() | ||
local purchList = p.getPurchases(function(purch) return | -- All purchases in the general category besides Auto Eat, which is handled by getAutoEatTable() | ||
local purchList = p.getPurchases(function(purch) return purch.category == 'melvorD:General' and string.find(purch.id, '^melvorD:Auto_Eat') == nil end) | |||
return p._getShopTable(purchList, { columns = { 'Purchase', 'Description', 'Cost', 'Requirements' }, purchaseHeader = 'Upgrade' }) | |||
end | |||
function p.getShopSkillUpgradeTable() | |||
-- All purchaes in the SkillUpgrades category except tools and any upgrades displayed as | |||
-- tools (e.g. ship upgrades) | |||
local purchList = p.getPurchases( | |||
function(purch) | |||
return purch.category == 'melvorD:SkillUpgrades' | |||
-- Exclude tools, handled by p.getToolTable() | |||
and string.find(purch.id, '_Axe$') == nil | |||
and string.find(purch.id, '_Pickaxe$') == nil | |||
and string.find(purch.id, '_Rod$') == nil | |||
and string.find(purch.id, '_Pickaxe$') == nil | |||
and string.find(purch.id, 'Fire$') == nil | |||
and string.find(purch.id, 'Furnace$') == nil | |||
and string.find(purch.id, 'Pot$') == nil | |||
and string.find(purch.id, 'Sieve$') == nil | |||
and string.find(purch.id, 'Trowel$') == nil | |||
and string.find(purch.id, 'Brush$') == nil | |||
and string.find(purch.id, 'Shovel$') == nil | |||
and string.find(purch.id, 'ShipUpgrade') == nil | |||
-- Exclude God upgrades, handled by p.getGodUpgradeTable() | |||
and p.getGodUpgradeDungeon(purch) == nil | |||
end | |||
) | |||
return p._getShopTable(purchList, { columns = { 'Purchase', 'Description', 'Cost', 'Requirements' }, purchaseHeader = 'Upgrade' }) | return p._getShopTable(purchList, { columns = { 'Purchase', 'Description', 'Cost', 'Requirements' }, purchaseHeader = 'Upgrade' }) | ||
end | |||
function p.isSkillcapePurchase(purch, isSuperior, skillID) | |||
-- Returns true or false depending on whether the purchase is a skillcape or not. | |||
-- If isSuperior is true, then this checks for superior skillcapes, false checks | |||
-- for regular skillcapes, and nil checks for both. | |||
-- If skillID is specified, then the skillcape must also relate to that skill | |||
local checkCategories = (isSuperior == nil and {'melvorTotH:SuperiorSkillcapes', 'melvorD:Skillcapes'}) or (isSuperior and {'melvorTotH:SuperiorSkillcapes'}) or {'melvorD:Skillcapes'} | |||
-- Some skillcapes (such as Archaeology & Cartography) reside outside of the usual categories | |||
local overrideIDs = { | |||
['melvorTotH:SuperiorSkillcapes'] = { | |||
'melvorAoD:Superior_Archaeology_Skillcape', | |||
'melvorAoD:Superior_Cartography_Skillcape', | |||
'melvorAoD:Cape_of_Completion_AoD' | |||
}, | |||
['melvorD:Skillcapes'] = { | |||
'melvorAoD:Archaeology_Skillcape', | |||
'melvorAoD:Cartography_Skillcape' | |||
} | |||
} | |||
for i, cat in ipairs(checkCategories) do | |||
if purch.category == cat or Shared.contains(overrideIDs[cat], purch.id) then | |||
if skillID == nil then | |||
return true | |||
else | |||
-- Also validate purchase requirements for relevant SkillLevel requirement | |||
local hasReq = false | |||
if type(purch.purchaseRequirements) == 'table' then | |||
for j, req in ipairs(purch.purchaseRequirements) do | |||
if req.type == 'SkillLevel' then | |||
if req.skillID == skillID then | |||
hasReq = true | |||
else | |||
-- The presence of any other skill's requirement indicates | |||
-- this is not a skillcape for skill with ID skillID | |||
return false | |||
end | |||
end | |||
end | |||
end | |||
return hasReq | |||
end | |||
end | |||
end | |||
return false | |||
end | end | ||
function p._getShopSkillcapeTable(showSuperior) | function p._getShopSkillcapeTable(showSuperior) | ||
local capeList = p.getPurchases(function(purch) return p.isSkillcapePurchase(purch, showSuperior) end) | |||
local capeList = p.getPurchases(function(purch) return purch | |||
local sortOrderFunc = | local sortOrderFunc = | ||
function(a, b) | function(a, b) | ||
Line 572: | Line 645: | ||
local capeCategory = frame.args ~= nil and frame.args[1] or frame | local capeCategory = frame.args ~= nil and frame.args[1] or frame | ||
local showSuperior = string.lower(capeCategory) == 'superior' | local showSuperior = string.lower(capeCategory) == 'superior' | ||
return p._getShopSkillcapeTable(showSuperior) | return p._getShopSkillcapeTable(showSuperior) | ||
end | end | ||
Line 578: | Line 651: | ||
function p.getSkillcapeTable(frame) | function p.getSkillcapeTable(frame) | ||
local skillName = frame.args ~= nil and frame.args[1] or frame | local skillName = frame.args ~= nil and frame.args[1] or frame | ||
local skillID = Constants.getSkillID(skillName) | |||
local | if skillID == nil then | ||
if | return Shared.printError('No such skill "' .. (skillName or 'nil') .. '"') | ||
end | end | ||
local capeList = p.getPurchases(function(purch) return p.isSkillcapePurchase(purch, nil, skillID) end) | |||
if Shared.tableIsEmpty(capeList) then | if Shared.tableIsEmpty(capeList) then | ||
return '' | return '' | ||
else | else | ||
capeList = GameData.sortByOrderTable(capeList, GameData.rawData.shopDisplayOrder, true) | |||
local resultPart = {} | local resultPart = {} | ||
table.insert(resultPart, '{| class="wikitable" | table.insert(resultPart, '{| class="wikitable"\n') | ||
table.insert(resultPart, '!Skillcape!!Name!!Requirements!!Effect') | table.insert(resultPart, '!Skillcape!!Name!!Requirements!!Effect') | ||
for i, cape in ipairs(capeList) do | for i, cape in ipairs(capeList) do | ||
local capeItem = Items.getItemByID(cape.contains.items[1].id) | local capeItem = Items.getItemByID(cape.contains.items[1].id) | ||
if capeItem ~= nil then | if capeItem ~= nil then | ||
table.insert(resultPart, ' | table.insert(resultPart, '\n|-\n| ' .. Icons.Icon({capeItem.name, type='item', size='60', notext=true})) | ||
table.insert(resultPart, ' | table.insert(resultPart, '\n| data-sort-value="'..capeItem.name..'"|'..Icons.getExpansionIcon(capeItem.id) .. Icons.Icon({capeItem.name, type='item', noicon=true})) | ||
table.insert(resultPart, ' | table.insert(resultPart, '\n| ' .. Common.getRequirementString(cape.purchaseRequirements, 'None')) | ||
table.insert(resultPart, ' | table.insert(resultPart, '\n| ' .. p._getPurchaseDescription(cape)) | ||
end | end | ||
end | end | ||
table.insert(resultPart, ' | table.insert(resultPart, '\n|}') | ||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end | ||
Line 637: | Line 710: | ||
end | end | ||
function p. | function p.getGodUpgradeDungeon(purch) | ||
-- Identifies skill upgrades which have a dungeon completion requirement for an area | |||
-- | -- whose name ends with 'God Dungeon'. Returns the ID of the dungeon which must be | ||
-- | -- completed before the purchase may be bought if the purchase is a god upgrade | ||
if purch.category == 'melvorD:SkillUpgrades' and type(purch.purchaseRequirements) == 'table' then | |||
for i, req in ipairs(purch.purchaseRequirements) do | |||
if req.type == 'DungeonCompletion' and string.find(req.dungeonID, 'God_Dungeon$') ~= nil then | |||
return req.dungeonID | |||
end | end | ||
end | end | ||
end | |||
end | |||
function p.getGodUpgradeTable() | |||
local resultPart = {} | |||
local upgradeList = p.getPurchases( | local upgradeList = p.getPurchases( | ||
function(purch) | function(purch) | ||
return p.getGodUpgradeDungeon(purch) ~= nil | |||
end) | end) | ||
if Shared.tableIsEmpty(upgradeList) then | if Shared.tableIsEmpty(upgradeList) then | ||
Line 669: | Line 741: | ||
for i, upgrade in ipairs(upgradeList) do | for i, upgrade in ipairs(upgradeList) do | ||
local upgradeName = Common.getPurchaseName(upgrade) | local upgradeName = Common.getPurchaseName(upgrade) | ||
local dung = | local dung = GameData.getEntityByID('dungeons', p.getGodUpgradeDungeon(upgrade)) | ||
local costSortValue = p._getPurchaseSortValue(upgrade) | local costSortValue = p._getPurchaseSortValue(upgrade) | ||
table.insert(resultPart, '|-\r\n|class="table-img" data-sort-value="' .. upgradeName .. '"| ' ..p._getPurchaseExpansionIcon(upgrade).. Icons.Icon({upgradeName, type='upgrade', size=50, notext=true})) | table.insert(resultPart, '|-\r\n|class="table-img" data-sort-value="' .. upgradeName .. '"| ' ..p._getPurchaseExpansionIcon(upgrade).. Icons.Icon({upgradeName, type='upgrade', size=50, notext=true})) | ||
Line 680: | Line 752: | ||
return table.concat(resultPart, '\r\n') | return table.concat(resultPart, '\r\n') | ||
end | |||
function p.getAoDTable(frame) | |||
-- All purchases in the Atlas of Discovery category except for skillcapes, which are handled | |||
-- by p.getShopSKilcapeTable() | |||
local purchList = p.getPurchases( | |||
function(purch) | |||
return purch.category == 'melvorAoD:AtlasOfDiscovery' and not p.isSkillcapePurchase(purch) | |||
end | |||
) | |||
return p._getShopTable(purchList, { columns = { 'Purchase', 'Description', 'Cost', 'Requirements' } }) | |||
end | end | ||
Line 873: | Line 957: | ||
{ name = 'increasedSurveyRange', header = 'Increased Survey Range', sign = '+', suffix = ''}, | { name = 'increasedSurveyRange', header = 'Increased Survey Range', sign = '+', suffix = ''}, | ||
} | } | ||
return p.getToolTable('Ship', 'Ship', modifiers, 'melvorAoD:Cartography') | return p.getToolTable('Ship', 'Ship', modifiers, 'melvorAoD:Cartography') | ||
end | end |