4,683
edits
(Update for v1.3) |
(Ceil Summoning recipes and fixed max abyssal recipe costs; Fixes for Abyssal Level/XP;) |
||
Line 24: | Line 24: | ||
local maxTime = nil | local maxTime = nil | ||
local lvl = 0 | local lvl = 0 | ||
local isAbyssal = false | |||
local xp = 0 | local xp = 0 | ||
local qty = nil | local qty = nil | ||
Line 55: | Line 56: | ||
local skillData = SkillData[localSkillID] | local skillData = SkillData[localSkillID] | ||
local skill = skillData.name | local skill = skillData.name | ||
local lvl, xp, qty, req, time, maxTime = 0, 0, 0, nil, 0, nil | local lvl, isAbyssal, xp, qty, req, time, maxTime = 0, false, 0, 0, nil, 0, nil | ||
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do | for i, recipe in ipairs(skillData[dataProp.recipeKey]) do | ||
if recipe.productId == itemID then | if recipe.productId == itemID then | ||
lvl = recipe | lvl, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe) | ||
xp = recipe.baseExperience | xp = recipe.baseAbyssalExperience or recipe.baseExperience | ||
qty = recipe.baseQuantity or 1 | qty = recipe.baseQuantity or 1 | ||
if localSkillID == 'Farming' then | if localSkillID == 'Farming' then | ||
Line 81: | Line 82: | ||
specialReq = Icons.Icon({'Mastery', notext=true}) .. Shared.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]' | specialReq = Icons.Icon({'Mastery', notext=true}) .. Shared.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]' | ||
end | end | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq)) | table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, time, maxTime, specialReq)) | ||
-- Assumes item has a single source per skill | -- Assumes item has a single source per skill | ||
break | break | ||
Line 93: | Line 94: | ||
local skillData = SkillData[localSkillID] | local skillData = SkillData[localSkillID] | ||
local skill = skillData.name | local skill = skillData.name | ||
local lvl, xp, qty, req, time, maxTime = 0, 0, 0, nil, 0, nil | local lvl, isAbyssal, xp, qty, req, time, maxTime = 0, false, 0, 0, nil, 0, nil | ||
for i, recipe in ipairs(skillData.recipes) do | for i, recipe in ipairs(skillData.recipes) do | ||
if recipe.productID == itemID or | if recipe.productID == itemID or | ||
(localSkillID == 'Cooking' and recipe.perfectCookID == itemID) or | (localSkillID == 'Cooking' and recipe.perfectCookID == itemID) or | ||
(localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, itemID)) then | (localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, itemID)) then | ||
lvl = recipe | lvl, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe) | ||
xp = recipe.baseExperience | xp = recipe.baseAbyssalExperience or recipe.baseExperience | ||
qty = recipe.baseQuantity or 1 | qty = recipe.baseQuantity or 1 | ||
-- Action time | -- Action time | ||
Line 124: | Line 125: | ||
if localSkillID == 'Summoning' then | if localSkillID == 'Summoning' then | ||
local shardCostArray, otherCostArray = {}, {} | local shardCostArray, otherCostArray = {}, {} | ||
local | local recipeCost = 0 | ||
if isAbyssal == true then | |||
recipeCost = skillData.recipeAPCost | |||
else | |||
recipeCost = skillData.recipeGPCost | |||
end | |||
-- Shards | -- Shards | ||
for j, itemCost in ipairs(recipe.itemCosts) do | for j, itemCost in ipairs(recipe.itemCosts) do | ||
Line 138: | Line 144: | ||
if nonShard ~= nil then | if nonShard ~= nil then | ||
local itemValue = math.max(nonShard.sellsFor, 20) | local itemValue = math.max(nonShard.sellsFor, 20) | ||
local nonShardQty = math.max(1, math. | local nonShardQty = math.max(1, math.ceil(recipeCost / itemValue)) | ||
table.insert(otherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty})) | table.insert(otherCostArray, Icons.Icon({nonShard.name, type='item', notext=true, qty=nonShardQty})) | ||
end | end | ||
Line 148: | Line 154: | ||
end | end | ||
specialReq = 'At least 1 ' .. Icons.Icon({'Summoning%23Summoning Marks', item.name, img=item.name, type='mark'}) .. ' mark discovered' | specialReq = 'At least 1 ' .. Icons.Icon({'Summoning%23Summoning Marks', item.name, img=item.name, type='mark'}) .. ' mark discovered' | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qty, time, nil, specialReq)) | table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, time, nil, specialReq)) | ||
-- Some items (such as Arrow shafts) have multiple recipes | -- Some items (such as Arrow shafts) have multiple recipes | ||
elseif type(recipe.alternativeCosts) == 'table' then | elseif type(recipe.alternativeCosts) == 'table' then | ||
Line 170: | Line 176: | ||
req = table.concat(reqPart, sep) | req = table.concat(reqPart, sep) | ||
local qtyText = table.concat(qtyPart, sep) | local qtyText = table.concat(qtyPart, sep) | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, req, qtyText, time, maxTime, specialReq)) | table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qtyText, time, maxTime, specialReq)) | ||
-- Finally, normal recipes with a single set of item costs | -- Finally, normal recipes with a single set of item costs | ||
elseif type(recipe.itemCosts) == 'table' and not Shared.tableIsEmpty(recipe.itemCosts) then | elseif type(recipe.itemCosts) == 'table' and not Shared.tableIsEmpty(recipe.itemCosts) then | ||
table.insert(tables, p.buildCreationTable(skill, lvl, xp, recipe.itemCosts, qty, time, maxTime, specialReq, recipe.currencyCosts)) | table.insert(tables, p.buildCreationTable(skill, lvl, isAbyssal, xp, recipe.itemCosts, qty, time, maxTime, specialReq, recipe.currencyCosts)) | ||
end | end | ||
end | end | ||
Line 230: | Line 236: | ||
end | end | ||
function p.buildCreationTable(skill, lvl, xp, req, qty, time, maxTime, specialReq, currencyCost) | function p.buildCreationTable(skill, lvl, isAbyssal, xp, req, qty, time, maxTime, specialReq, currencyCost) | ||
if qty == nil then qty = 1 end | if qty == nil then qty = 1 end | ||
local resultPart = {} | local resultPart = {} | ||
Line 236: | Line 242: | ||
table.insert(resultPart, '\r\n!colspan="2"|Item ' .. (req == nil and 'Creation' or 'Production')) | table.insert(resultPart, '\r\n!colspan="2"|Item ' .. (req == nil and 'Creation' or 'Production')) | ||
table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Requirements') | table.insert(resultPart, '\r\n|-\r\n!style="text-align: right;"|Requirements') | ||
table.insert(resultPart, '\r\n|'..Icons. | table.insert(resultPart, '\r\n|'..Icons._GetSkillReq(skill, lvl, false, isAbyssal)) | ||
if specialReq ~= nil then table.insert(resultPart, '<br/>'..specialReq) end | if specialReq ~= nil then table.insert(resultPart, '<br/>'..specialReq) end | ||
Line 448: | Line 454: | ||
end | end | ||
else | else | ||
table.insert(lineArray, Icons. | local level, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe) | ||
table.insert(lineArray, Icons._GetSkillReq(skill, level, false, isAbyssal)) | |||
end | end | ||
break | break | ||
Line 463: | Line 470: | ||
(localSkillID == 'Cooking' and recipe.perfectCookID == item.id) or | (localSkillID == 'Cooking' and recipe.perfectCookID == item.id) or | ||
(localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, item.id)) then | (localSkillID == 'Herblore' and Shared.contains(recipe.potionIDs, item.id)) then | ||
table.insert(lineArray, Icons. | local level, isAbyssal = Skills.getRecipeLevelRealm(localSkillID, recipe) | ||
table.insert(lineArray, Icons._GetSkillReq(skill, level, false, isAbyssal)) | |||
break | break | ||
end | end | ||
Line 1,348: | Line 1,356: | ||
end | end | ||
--[ | --[[ | ||
-- Uncomment this block and execute 'p.test()' within the debug console | -- Uncomment this block and execute 'p.test()' within the debug console | ||
-- to test after making changes | -- to test after making changes | ||
Line 1,395: | Line 1,403: | ||
"Lemon", | "Lemon", | ||
"Aranite Brush", | "Aranite Brush", | ||
"Barrier Dust" | "Barrier Dust", | ||
"Shadow Raven Nest", | |||
"Void Wisp" | |||
} | } | ||
local checkFuncs = { | local checkFuncs = { | ||
p.getItemSourceTables, | --p.getItemSourceTables, | ||
--p.getCreationTable, | --p.getCreationTable, | ||
p.getItemSources, | --p.getItemSources, | ||
--p.getItemLootSourceTable, | --p.getItemLootSourceTable, | ||
} | } | ||
Line 1,423: | Line 1,433: | ||
end | end | ||
end | end | ||
--] | --]] | ||
return p | return p |