4,978
edits
mNo edit summary |
(Added 1/x values to Chances; Use Recipe icon for source icons when available; Merge Shop and Upgrade sources into Creation Table; Changed 'Inputs' to 'Costs'; Add output quantity for upgraded items; Fix Ash requirements, apparently) |
||
Line 10: | Line 10: | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
local Shop = require('Module:Shop') | local Shop = require('Module:Sandbox/Shop') -- TODO: Remove Sandbox/ when pushing live | ||
local Monsters = require('Module:Monsters') | local Monsters = require('Module:Monsters') | ||
local Skills = require('Module:Skills') | local Skills = require('Module:Skills') | ||
Line 19: | Line 19: | ||
} | } | ||
--[[ | |||
TODO: | |||
-- | -- Move Township Task and Cartography Disovery rewards under Item Sources (?) | ||
-- Center Quantity & Chance in Loot Tables | |||
Creation-Tables: | |||
-- Move anything that isn't Combat, Thieving, or Chests out of Loot Sources and into Creation Tables (Alt Magic Spells & Gems) (?) | |||
Use-Tables: | |||
-- Shrink icon size down (to 25px?) | |||
-- Or change "Item Created" to a single cell? (1 (IMG) Barrier Touch Potion I) | |||
-- Change Type header to Source | |||
-- Change Requirements header to Requires | |||
-- Change XP header to Exp | |||
-- Change XP display to: Icon - Value - (' XP' or ' AXP' if abyssal) | |||
-- Remove right alignment on XP, Requirements | |||
-- Add 'table-na' to cells with N/A | |||
--]] | |||
local function doesRecipeHaveItemID(recipe, itemID) | |||
if recipe.productId == itemID then | |||
return true | |||
elseif Shared.contains(recipe.primaryProducts, itemID) or Shared.contains(recipe.secondaryProducts, itemID) then | |||
return true | |||
elseif type(recipe.products) == 'table' then | |||
return GameData.getEntityByProperty(recipe.products, 'itemID', itemID) ~= nil | |||
end | |||
return false | |||
end | |||
function p._getCreationTableData(item, tableData) | |||
if tableData == nil then tableData = {} end | |||
} | |||
local skill = '' | |||
local reqs = nil | |||
local source = nil | |||
local time = 0 | |||
local maxTime = nil | |||
local lvl = 0 | |||
local isAbyssal = false | |||
local xp = 0 | |||
local qty = 1 | |||
local costs = nil | |||
local weight = nil | |||
local totalWeight = nil | |||
local itemID = item.id | |||
--First figure out what skill is used to make this... | |||
local itemID = item.id | |||
--First figure out what skill is used to make this... | |||
local skillIDs = { | local skillIDs = { | ||
['Gathering'] = { | ['Gathering'] = { | ||
['Farming'] = { recipeKey = 'recipes' }, | ['Farming'] = { recipeKey = 'recipes', recipeType = 'item' }, | ||
['Woodcutting'] = { recipeKey = 'trees' }, | ['Woodcutting'] = { recipeKey = 'trees', recipeType = 'tree' }, | ||
['Fishing'] = { recipeKey = 'fish' }, | ['Fishing'] = { recipeKey = 'fish', recipeType = 'item' }, | ||
['Firemaking'] = { recipeKey = 'logs' }, | ['Firemaking'] = { recipeKey = 'logs', recipeType = 'item' }, | ||
['Mining'] = { recipeKey = 'rockData' }, | ['Mining'] = { recipeKey = 'rockData', recipeType = 'rock' }, | ||
['Cartography'] = { recipeKey = 'paperRecipes' }, | ['Cartography'] = { recipeKey = 'paperRecipes', recipeType = 'item' }, | ||
['Harvesting'] = { recipeKey = 'veinData' } | ['Harvesting'] = { recipeKey = 'veinData', recipeType = 'vein' } | ||
}, | }, | ||
['Artisan'] = { | ['Artisan'] = { | ||
Line 144: | Line 92: | ||
local skillData = SkillData[localSkillID] | local skillData = SkillData[localSkillID] | ||
local skill = skillData.name | local skill = skillData.name | ||
local lvl, isAbyssal, xp, qty, source, costs, time, maxTime, | local reqs, lvl, isAbyssal, xp, qty, source, costs, time, maxTime, weight, totalWeight = nil, 0, false, 0, 1, nil, nil, 0, nil, nil, nil | ||
for i, recipe in ipairs(skillData[dataProp.recipeKey]) do | for i, recipe in ipairs(skillData[dataProp.recipeKey]) do | ||
local hasProduct = doesRecipeHaveItemID(recipe, itemID) | local hasProduct = doesRecipeHaveItemID(recipe, itemID) | ||
Line 151: | Line 99: | ||
xp = recipe.baseAbyssalExperience or recipe.baseExperience | xp = recipe.baseAbyssalExperience or recipe.baseExperience | ||
qty = recipe.baseQuantity or 1 | qty = recipe.baseQuantity or 1 | ||
reqs = Icons._SkillReq(skill, lvl, false, (isAbyssal and 'melvorItA:Abyssal' or nil)) | |||
if | -- Source Icon | ||
if recipe.name ~= nil then | |||
source = Icons.Icon({ skill, img=recipe.name, type=dataProp.recipeType }) | |||
else | |||
source = Icons.Icon({ skill, type='skill', class=(isAbyssal and 'abyss-icon' or nil) }) | |||
end | end | ||
-- Action time | -- Action time | ||
Line 167: | Line 116: | ||
elseif skillData.baseInterval ~= nil then | elseif skillData.baseInterval ~= nil then | ||
time = skillData.baseInterval / 1000 | time = skillData.baseInterval / 1000 | ||
end | end | ||
-- | -- Custom Chance, Qty, and Costs data | ||
if localSkillID == 'Farming' then | |||
costs = { recipe.seedCost } | |||
local catData = GameData.getEntityByID(skillData.categories, recipe.categoryID) | |||
qty = 5 * catData.harvestMultiplier | |||
elseif localSkillID == 'Firemaking' then | |||
local itemChanceData = GameData.getEntityByProperty(SkillData.Firemaking.primaryProducts, 'itemID', itemID) | local itemChanceData = GameData.getEntityByProperty(SkillData.Firemaking.primaryProducts, 'itemID', itemID) | ||
if itemChanceData ~= nil then | if itemChanceData ~= nil then | ||
weight = itemChanceData.chance | |||
elseif itemID == 'melvorD:Generous_Fire_Spirit' then | elseif itemID == 'melvorD:Generous_Fire_Spirit' then | ||
weight = 0.1 | |||
end | end | ||
Line 192: | Line 143: | ||
end | end | ||
elseif localSkillID == 'Cartography' then | elseif localSkillID == 'Cartography' then | ||
time = 5 | |||
local costItem = Items.getItemByID(recipe.costs.items[1].id) | local costItem = Items.getItemByID(recipe.costs.items[1].id) | ||
costs = Icons.Icon({ costItem.name, type='item', qty=1 }) | costs = Icons.Icon({ costItem.name, type='item', qty=1 }) | ||
elseif localSkillID == 'Harvesting' then | elseif localSkillID == 'Harvesting' then | ||
local itemChanceData = nil | local itemChanceData = nil | ||
totalWeight = 0 | |||
for i, product in ipairs(recipe.products) do | for i, product in ipairs(recipe.products) do | ||
Line 205: | Line 158: | ||
if itemChanceData ~= nil then | if itemChanceData ~= nil then | ||
weight = itemChanceData.weight | |||
reqs = reqs .. '<br>' .. itemChanceData.minIntensityPercent .. '% ' .. Icons.Icon({ recipe.name, type='vein', notext=true }) .. ' Intensity' | |||
end | end | ||
end | end | ||
-- Special requirements | -- Special requirements | ||
if recipe.totalMasteryRequired ~= nil then | if recipe.totalMasteryRequired ~= nil then | ||
reqs = reqs .. '<br>' .. Icons.Icon({ 'Mastery', notext=true }) .. ' ' .. Num.formatnum(recipe.totalMasteryRequired) .. ' total [[' .. skill .. ']] [[Mastery]]' | |||
end | end | ||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = skill, | ['skill'] = skill, | ||
[' | ['reqs'] = reqs, | ||
['isAbyssal'] = isAbyssal, | ['isAbyssal'] = isAbyssal, | ||
['xp'] = xp, | ['xp'] = xp, | ||
Line 223: | Line 176: | ||
['time'] = time, | ['time'] = time, | ||
['maxTime'] = maxTime, | ['maxTime'] = maxTime, | ||
[' | ['weight'] = weight, | ||
[' | ['totalWeight'] = totalWeight | ||
}) | }) | ||
-- Most recipes have a single item source or the item source data | -- Most recipes have a single item source or the item source data | ||
Line 238: | Line 191: | ||
local skillData = SkillData[localSkillID] | local skillData = SkillData[localSkillID] | ||
local skill = skillData.name | local skill = skillData.name | ||
local lvl, isAbyssal, xp, qty, source, costs, time, maxTime = 0, false, 0, | local reqs, lvl, isAbyssal, xp, qty, source, costs, time, maxTime = nil, 0, false, 0, 1, Icons.Icon({ skill, type='skill' }), 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 | ||
Line 246: | Line 199: | ||
xp = recipe.baseAbyssalExperience or recipe.baseExperience | xp = recipe.baseAbyssalExperience or recipe.baseExperience | ||
qty = recipe.baseQuantity or 1 | qty = recipe.baseQuantity or 1 | ||
source = Icons.Icon({ skill, type='skill', class=(isAbyssal and 'abyss-icon' or | reqs = Icons._SkillReq(skill, lvl, false, (isAbyssal and 'melvorItA:Abyssal' or nil)) | ||
source = Icons.Icon({ skill, type='skill', class=(isAbyssal and 'abyss-icon' or nil) }) | |||
-- Action time | -- Action time | ||
if recipe.baseMinInterval ~= nil then | if recipe.baseMinInterval ~= nil then | ||
Line 263: | Line 217: | ||
local levelUnlock = GameData.getEntityByProperty(skillData.masteryLevelUnlocks, 'descriptionID', item.tier + 1) | local levelUnlock = GameData.getEntityByProperty(skillData.masteryLevelUnlocks, 'descriptionID', item.tier + 1) | ||
if levelUnlock ~= nil then | if levelUnlock ~= nil then | ||
reqs = reqs .. '<br>' .. Icons._MasteryReq(item.name, levelUnlock.level, false) | |||
end | end | ||
end | end | ||
Line 279: | Line 233: | ||
end | end | ||
if categoryIconName ~= nil and categoryName ~= nil then | if categoryIconName ~= nil and categoryName ~= nil then | ||
reqs = reqs .. '<br>' .. Icons.Icon({ 'Cooking', categoryName, section = 'Cooking Upgrades', img = categoryIconName, type = 'upgrade' }) | |||
end | end | ||
end | end | ||
Line 314: | Line 268: | ||
costs = costs .. '<br>' .. (costLen == 1 and '' or 'and one of the following:<br>') .. table.concat(otherCostArray, "<br>'''OR''' ") | costs = costs .. '<br>' .. (costLen == 1 and '' or 'and one of the following:<br>') .. table.concat(otherCostArray, "<br>'''OR''' ") | ||
end | end | ||
reqs = reqs .. '<br>At least 1 ' .. Icons.Icon({ 'Summoning', item.name, img=item.name, type='mark', section='Summoning Marks' }) .. ' mark discovered' | |||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = skill, | ['skill'] = skill, | ||
[' | ['reqs'] = Icons._SkillReq(skill, lvl, false, (isAbyssal and 'melvorItA:Abyssal' or nil)), | ||
['isAbyssal'] = isAbyssal, | ['isAbyssal'] = isAbyssal, | ||
['xp'] = xp, | ['xp'] = xp, | ||
Line 323: | Line 277: | ||
['qty'] = qty, | ['qty'] = qty, | ||
['source'] = source, | ['source'] = source, | ||
['time'] = time | ['time'] = time | ||
}) | }) | ||
-- Some items (such as Arrow shafts) have multiple recipes | -- Some items (such as Arrow shafts) have multiple recipes | ||
Line 340: | Line 293: | ||
end | end | ||
end | end | ||
costsStr = costsStr .. | costsStr = costsStr .. Common.getCostString({ ["items"] = {}, ["currencies"] = recipe.currencyCosts }, '') | ||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = skill, | ['skill'] = skill, | ||
[' | ['reqs'] = Icons._SkillReq(skill, lvl, false, (isAbyssal and 'melvorItA:Abyssal' or nil)), | ||
['isAbyssal'] = isAbyssal, | ['isAbyssal'] = isAbyssal, | ||
['xp'] = xp, | ['xp'] = xp, | ||
['costs'] = costsStr, | ['costs'] = costsStr, | ||
['qty'] = | ['qty'] = qty * altCost.quantityMultiplier, | ||
['source'] = Icons.Icon({ skill, type='skill' }), | ['source'] = Icons.Icon({ skill, type='skill' }), | ||
['time'] = time, | ['time'] = time, | ||
['maxTime'] = maxTime | ['maxTime'] = maxTime | ||
}) | }) | ||
end | end | ||
Line 358: | Line 310: | ||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = skill, | ['skill'] = skill, | ||
[' | ['reqs'] = Icons._SkillReq(skill, lvl, false, (isAbyssal and 'melvorItA:Abyssal' or nil)), | ||
['isAbyssal'] = isAbyssal, | ['isAbyssal'] = isAbyssal, | ||
['xp'] = xp, | ['xp'] = xp, | ||
Line 366: | Line 318: | ||
['time'] = time, | ['time'] = time, | ||
['maxTime'] = maxTime, | ['maxTime'] = maxTime, | ||
['currencyCost'] = recipe.currencyCosts | ['currencyCost'] = recipe.currencyCosts | ||
}) | }) | ||
Line 378: | Line 329: | ||
-- Gems are handled by _getItemLootSourceTable() | -- Gems are handled by _getItemLootSourceTable() | ||
for i, altSpell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | for i, altSpell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | ||
if altSpell.produces == | if altSpell.produces == itemID then | ||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = 'Magic', | ['skill'] = 'Magic', | ||
[' | ['reqs'] = Icons._SkillReq('Magic', altSpell.level, false), | ||
['isAbyssal'] = false, | ['isAbyssal'] = false, | ||
['xp'] = altSpell.baseExperience, | ['xp'] = altSpell.baseExperience, | ||
Line 401: | Line 352: | ||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = 'Astrology', | ['skill'] = 'Astrology', | ||
[' | ['reqs'] = Icons._SkillReq('Astrology', 1, false, (isAbyssal and 'melvorItA:Abyssal' or nil)), | ||
['isAbyssal'] = isAbyssal, | ['isAbyssal'] = isAbyssal, | ||
['xp'] = (isAbyssal and 1238 or 5), -- Use the | ['qty'] = qty, | ||
['source'] = Icons.Icon({ 'Astrology', type='skill', class=(isAbyssal and 'abyss-icon' or | ['xp'] = (isAbyssal and 1238 or 5), -- Use the XP value for the first constellation | ||
['source'] = Icons.Icon({ 'Astrology', type='skill', class=(isAbyssal and 'abyss-icon' or nil) }), | |||
['time'] = 3, | ['time'] = 3, | ||
[' | ['weight'] = stardustChanceData.chance | ||
}) | }) | ||
end | end | ||
return tableData | |||
end | end | ||
function p.buildCreationTable(tableData | function p.buildCreationTable(item, tableData) | ||
if Shared.tableIsEmpty(tableData) then return '' end | |||
local showSource = false | local showSource = false | ||
local showRequirements = false | local showRequirements = false | ||
Line 432: | Line 382: | ||
colspan = colspan + 1 | colspan = colspan + 1 | ||
end | end | ||
if not showRequirements and tableData[1]. | if not showRequirements and tableData[1].reqs ~= tableData[i].reqs then | ||
showRequirements = true | showRequirements = true | ||
colspan = colspan + 1 | colspan = colspan + 1 | ||
Line 452: | Line 402: | ||
colspan = colspan + 1 | colspan = colspan + 1 | ||
end | end | ||
if not showChance and tableData[1]. | if not showChance and tableData[1].weight ~= tableData[i].weight then | ||
showChance = true | showChance = true | ||
colspan = colspan + | colspan = colspan + 2 | ||
end | end | ||
end | end | ||
Line 469: | Line 419: | ||
costsRow:wikitext(mat.quantity .. 'x ?????') | costsRow:wikitext(mat.quantity .. 'x ?????') | ||
else | else | ||
costsRow:wikitext(Icons.Icon({matItem.name, type='item', qty=mat.quantity})) | costsRow:wikitext(Icons.Icon({ matItem.name, type='item', qty=mat.quantity })) | ||
end | end | ||
end | end | ||
if data.currencyCost ~= nil then | if data.currencyCost ~= nil then | ||
costsRow:wikitext('<br>' .. | costsRow:wikitext('<br>' .. Common.getCostString({ ["items"] = {}, ["currencies"] = data.currencyCost }, '')) | ||
end | end | ||
else | else | ||
Line 480: | Line 430: | ||
end | end | ||
if data.altCosts | if type(data.altCosts) == 'string' then | ||
local costStr = data.altCosts:gsub(', ', '<br>') | |||
costsRow:wikitext('<br>' .. costStr) | |||
end | end | ||
end | end | ||
Line 495: | Line 446: | ||
if showXP then tableHeader:tag('th'):wikitext('Exp') end | if showXP then tableHeader:tag('th'):wikitext('Exp') end | ||
if showTime then tableHeader:tag('th'):wikitext('Time') end | if showTime then tableHeader:tag('th'):wikitext('Time') end | ||
if showChance then tableHeader:tag('th'):wikitext('Chance') end | if showChance then tableHeader:tag('th'):wikitext('Chance'):attr('colspan', 2) end | ||
-- Populate table data with any unique entries (Ex: Ash's Inputs, Outputs, Exp, Time) | |||
for i, data in ipairs(tableData) do | for i, data in ipairs(tableData) do | ||
local recipeRow = resultTable:tag('tr') | local recipeRow = resultTable:tag('tr') | ||
if showSource then recipeRow:tag('td'):wikitext(data.source) end | if showSource then recipeRow:tag('td'):wikitext(data.source) end | ||
if showRequirements then recipeRow:tag('td'):wikitext((data.reqs or 'None')) end | |||
if showRequirements then | |||
if showInputs and data.costs ~= nil then | if showInputs and data.costs ~= nil then | ||
Line 518: | Line 461: | ||
end | end | ||
if showOutputs then recipeRow:tag('td'):wikitext(Icons.Icon({item.name, type='item', notext=true, qty=data.qty})):addClass('center') end | if showOutputs then | ||
if showXP | if type(data.qty) == 'string' then | ||
if showTime then recipeRow:tag('td'):wikitext(Shared.timeString(data.time, true)):addClass('center') end | local outputData = recipeRow:tag('td'):wikitext(data.qty) | ||
if showChance then recipeRow:tag('td'):wikitext((data. | if data.center then outputData:addClass('center') end | ||
end | else | ||
recipeRow:tag('td'):wikitext(Icons.Icon({ item.name, type='item', notext=true, qty=(data.qty or 1) })):addClass('center') | |||
end | |||
end | |||
if showXP and data.skill ~= nil and data.xp ~= nil then | |||
local iconClass = (data.isAbyssal and 'abyss-icon' or nil) | |||
local xpText = (data.isAbyssal and ' AXP' or ' XP') | |||
recipeRow:tag('td') | |||
:wikitext(Icons.Icon({ data.skill, notext=true, type='skill', class=iconClass })) | |||
:wikitext(' ' .. Num.formatnum(data.xp) .. xpText) | |||
end | |||
if showTime and data.time ~= nil then recipeRow:tag('td'):wikitext(Shared.timeString(data.time, true)):addClass('center') end | |||
if showChance then | |||
if data.weight ~= nil then | |||
recipeRow:tag('td'):wikitext(Num.fraction(data.weight, (data.totalWeight or 100))) | |||
recipeRow:tag('td'):wikitext(Num.round2(data.weight / (data.totalWeight or 100) * 100, 2) .. '%') | |||
else | |||
recipeRow:tag('td'):wikitext('100%'):addClass('center'):attr('colspan', 2) | |||
end | |||
end | |||
end | |||
-- Add all non-unique data below the table data (Ex: Ash's Source, Requires, Chance) | |||
if not showSource and tableData[1].source ~= nil then | if not showSource and tableData[1].source ~= nil then | ||
resultTable:tag('tr') | resultTable:tag('tr') | ||
:tag('th') | :tag('th'):wikitext('Source'):css('text-align', 'right') | ||
:tag('td'):attr('colspan', colspan):wikitext(tableData[1].source) | |||
end | end | ||
if not showRequirements and tableData[1]. | if not showRequirements and tableData[1].reqs ~= nil then | ||
local reqRow = resultTable:tag('tr') | local reqRow = resultTable:tag('tr') | ||
:tag('th') | :tag('th'):wikitext('Requires'):css('text-align', 'right') | ||
:tag('td'):wikitext(tableData[1].reqs):attr('colspan', colspan) | |||
end | end | ||
if not showInputs and tableData[1].costs ~= nil then | if not showInputs and tableData[1].costs ~= nil then | ||
local costRow = resultTable:tag('tr') | local costRow = resultTable:tag('tr') | ||
:tag('th'):wikitext('Costs'):css('text-align', 'right') | |||
addCostsRow(costRow, tableData[1], colspan) | addCostsRow(costRow, tableData[1], colspan) | ||
end | end | ||
if not showOutputs and tableData[1].qty ~= nil then | if not showOutputs and tableData[1].qty ~= nil then | ||
resultTable:tag('tr') | local outputRow = resultTable:tag('tr') | ||
:tag('th') | :tag('th'):wikitext('Outputs'):css('text-align', 'right') | ||
if type(tableData[1].qty) == 'string' then | |||
:tag('td'):attr('colspan', colspan):wikitext(Icons.Icon({ item.name, type='item', qty=tableData[1].qty })) | outputRow:tag('td'):wikitext(tableData[1].qty) | ||
else | |||
outputRow:tag('td'):attr('colspan', colspan):wikitext(Icons.Icon({ item.name, type='item', qty=(tableData[1].qty or 1) })) | |||
end | |||
end | end | ||
if not showXP and tableData[1].xp ~= nil then | if not showXP and tableData[1].xp ~= nil then | ||
local xpText = (tableData[1].isAbyssal and ' AXP' or ' XP') | |||
resultTable:tag('tr') | resultTable:tag('tr') | ||
:tag('th') | :tag('th'):wikitext('Base Exp'):css('text-align', 'right') | ||
:tag('td'):attr('colspan', colspan):wikitext(Num.formatnum(tableData[1].xp) .. xpText) | |||
end | end | ||
if not showTime and tableData[1].time ~= nil then | if not showTime and tableData[1].time ~= nil then | ||
resultTable:tag('tr') | resultTable:tag('tr') | ||
local timeHeader = resultTable:tag('th') | local timeHeader = resultTable:tag('th'):wikitext('Base Time'):css('text-align', 'right') | ||
local timeData = timeHeader:tag('td'):attr('colspan', colspan) | local timeData = timeHeader:tag('td'):attr('colspan', colspan) | ||
Line 579: | Line 531: | ||
end | end | ||
end | end | ||
if not showChance and tableData[1]. | if not showChance and tableData[1].weight ~= nil then | ||
resultTable:tag('tr') | local chanceData = resultTable:tag('tr') | ||
:tag('th') | :tag('th'):wikitext('Base Chance'):css('text-align', 'right') | ||
:tag('td'):attr('colspan', colspan) | |||
:wikitext(Num.fraction(tableData[1].weight, (tableData[1].totalWeight or 100))) | |||
:wikitext(' (' .. Num.round2(tableData[1].weight / (tableData[1].totalWeight or 100) * 100, 2) .. '%)') | |||
end | end | ||
return | return tostring(resultTable) | ||
end | end | ||
Line 597: | Line 549: | ||
end | end | ||
return p. | return p.buildCreationTable(p._getCreationTableData(item), item) | ||
end | end | ||
Line 644: | Line 596: | ||
} | } | ||
for entity, dungeons in pairs(dungeonEntities) do | for entity, dungeons in pairs(dungeonEntities) do | ||
for i, dungeon in ipairs(dungeons) do | for i, dungeon in ipairs(dungeons) do | ||
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or | if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or | ||
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then | (type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then | ||
table.insert(dungeonStrPart, Icons.Icon({dungeon.name, type= | table.insert(dungeonStrPart, Icons.Icon({dungeon.name, type='combatArea', notext=true})) | ||
elseif dungeon.eventID ~= nil then | elseif dungeon.eventID ~= nil then | ||
-- Is the item dropped from a combat event (e.g. Impending Darkness event)? | -- Is the item dropped from a combat event (e.g. Impending Darkness event)? | ||
Line 656: | Line 607: | ||
if item.id == itemRewardID then | if item.id == itemRewardID then | ||
local dungPrefix = (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or eventCycle .. (eventCycle == 1 and ' cycle' or ' cycles') .. ' of ') | local dungPrefix = (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or eventCycle .. (eventCycle == 1 and ' cycle' or ' cycles') .. ' of ') | ||
table.insert(dungeonStrPart, dungPrefix .. Icons.Icon({dungeon.name, type= | table.insert(dungeonStrPart, dungPrefix .. Icons.Icon({dungeon.name, type='combatArea', notext=true})) | ||
break | break | ||
end | end | ||
Line 983: | Line 934: | ||
-- Mining: Gems | -- Mining: Gems | ||
if (GameData.getEntityByProperty('randomGems', 'itemID', item.id) ~= nil or | if (GameData.getEntityByProperty('randomGems', 'itemID', item.id) ~= nil or | ||
GameData.getEntityByProperty('randomSuperiorGems', 'itemID', item.id) ~= nil) then | GameData.getEntityByProperty('randomSuperiorGems', 'itemID', item.id) ~= nil or | ||
GameData.getEntityByProperty('randomAbyssalGems', 'itemID', item.id) ~= nil) then | |||
table.insert(lineArray, Icons.Icon({"Mining", type='skill', notext=true})..' [[Mining#Gems|Gem]]') | table.insert(lineArray, Icons.Icon({"Mining", type='skill', notext=true})..' [[Mining#Gems|Gem]]') | ||
elseif item.id == SkillData.Mining.runestoneItemID then | elseif item.id == SkillData.Mining.runestoneItemID then | ||
Line 1,144: | Line 1,096: | ||
levelValue = level:match('%[%[.-%]%]%s*(%w+)$') or '' | levelValue = level:match('%[%[.-%]%]%s*(%w+)$') or '' | ||
end | end | ||
table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon.. level) | table.insert(rowPart, '\r\n|style="text-align: left;" data-sort-value="'..levelValue..'"|'..expIcon..' '..level) | ||
table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Num.formatnum(minqty)) | table.insert(rowPart, '\r\n|style="text-align: right;" data-sort-value="'..qty..'"|'..Num.formatnum(minqty)) | ||
if qty ~= minqty then table.insert(rowPart, ' - '..Num.formatnum(qty)) end | if qty ~= minqty then table.insert(rowPart, ' - '..Num.formatnum(qty)) end | ||
Line 1,220: | Line 1,172: | ||
} | } | ||
for entity, dungeons in pairs(dungeonEntities) do | for entity, dungeons in pairs(dungeonEntities) do | ||
for i, dungeon in ipairs(dungeons) do | for i, dungeon in ipairs(dungeons) do | ||
if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or | if (dungeon.oneTimeRewardID ~= nil and item.id == dungeon.oneTimeRewardID) or | ||
(type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then | (type(dungeon.rewardItemIDs) == 'table' and Shared.contains(dungeon.rewardItemIDs, item.id)) then | ||
table.insert(dropRows, { | table.insert(dropRows, { | ||
source = Icons.Icon({dungeon.name, type= | source = Icons.Icon({dungeon.name, type='combatArea'}), | ||
level = '[['..entity..']]', | level = '[['..entity..']]', | ||
minqty = 1, | minqty = 1, | ||
Line 1,238: | Line 1,189: | ||
for eventCycle, itemRewardID in ipairs(event.itemRewardIDs) do | for eventCycle, itemRewardID in ipairs(event.itemRewardIDs) do | ||
if item.id == itemRewardID then | if item.id == itemRewardID then | ||
local sourceTxt = Icons.Icon({dungeon.name, type= | local sourceTxt = Icons.Icon({dungeon.name, type='combatArea'}) .. (eventCycle == Shared.tableCount(event.itemRewardIDs) and '' or ', Cycle ' .. eventCycle) | ||
table.insert(dropRows, { | table.insert(dropRows, { | ||
source = sourceTxt, | source = sourceTxt, | ||
Line 1,361: | Line 1,312: | ||
-- Mining: Gems, and also Alt. Magic spells producing random gems | -- Mining: Gems, and also Alt. Magic spells producing random gems | ||
if Shared.contains({'Gem', 'Superior Gem'}, item.type) then | if Shared.contains({'Gem', 'Superior Gem', 'Abyssal Gem'}, item.type) then | ||
local gemKeys = { 'randomGems', 'randomSuperiorGems' } | local gemKeys = { 'randomGems', 'randomSuperiorGems', 'randomAbyssalGems' } | ||
for i, gemKey in ipairs(gemKeys) do | for i, gemKey in ipairs(gemKeys) do | ||
local thisGem, totalGemWeight = nil, 0 | local thisGem, totalGemWeight = nil, 0 | ||
Line 1,396: | Line 1,347: | ||
-- Check for Alt. Magic spells also | -- Check for Alt. Magic spells also | ||
local producesKey = (gemKey == 'randomGems' and 'RandomGem') or 'RandomSuperiorGem' | local producesKey = (gemKey == 'randomGems' and 'RandomGem') or (gemKey == 'randomSuperiorGems' and 'RandomSuperiorGem') or nil | ||
for j, spell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | if producesKey ~= nil then | ||
for j, spell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | |||
if spell.produces ~= nil and spell.produces == producesKey then | |||
table.insert(dropRows, { | |||
source = Icons.Icon({spell.name, type=Magic._getSpellIconType(spell)}), | |||
level = Icons.Icon({'Alternative Magic', type='skill', img='Magic', notext=true}) .. ' Level ' .. spell.level, | |||
levelNum = spell.level, | |||
minqty = thisGem.minQuantity, | |||
qty = thisGem.maxQuantity, | |||
weight = thisGem.weight, | |||
totalWeight = totalGemWeight, | |||
expIcon = Icons.getExpansionIcon(spell.id)}) | |||
end | |||
end | end | ||
end | end | ||
Line 1,446: | Line 1,399: | ||
end | end | ||
function p. | function p._getItemUpgradeTableData(item, tableData) | ||
if tableData == nil then tableData = {} end | |||
local upgrade = GameData.getEntityByProperty('itemUpgrades', 'upgradedItemID', item.id) | local upgrade = GameData.getEntityByProperty('itemUpgrades', 'upgradedItemID', item.id) | ||
if upgrade ~= nil then | if upgrade ~= nil then | ||
Line 1,455: | Line 1,409: | ||
}) | }) | ||
table.insert( | table.insert(tableData, { | ||
['costs'] = upgradeCost, | |||
['qty'] = 1, | |||
['source'] = '[[Upgrading Items|Item Upgrade]]' | |||
}) | |||
end | end | ||
return | |||
return tableData | |||
end | end | ||
Line 1,470: | Line 1,426: | ||
end | end | ||
return p. | return p.buildCreationTable(p._getItemUpgradeTableData(item), item) | ||
end | end | ||
Line 1,563: | Line 1,519: | ||
return '' | return '' | ||
end | end | ||
-- TODO: Remove this maybe? | |||
function p._getItemShopTableData(item, tableData) | |||
if tableData == nil then tableData = {} end | |||
local purchaseArray = Shop.getItemSourceArray(item.id) | |||
for i, purchaseData in ipairs(purchaseArray) do | |||
local purchase = purchaseData.purchase | |||
local namespace, localID = Shared.getLocalID(purchase.id) | |||
local source = nil | |||
-- Show icon text when it's the only entry in the table | |||
local notext = (Shared.tableCount(tableData) + Shared.tableCount(purchaseArray) > 1) | |||
if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 1 then | |||
source = Shop._getPurchaseExpansionIcon(purchase) .. Common.getPurchaseIcon({purchase}) | |||
-- Always show icon text when there's multiple items | |||
table.insert( | notext = false | ||
else | |||
source = Icons.Icon({'Shop'}) .. ' Purchase' | |||
end | |||
table.insert(tableData, { | |||
['reqs'] = Common.getRequirementString(purchase.purchaseRequirements, 'None'), | |||
['isAbyssal'] = namespace == 'melvorItA', | |||
['costs'] = Shop.getCostString(purchase.cost, false), | |||
['qty'] = Shop._getPurchaseContents(purchase, true, notext), | |||
['source'] = source, | |||
['center'] = notext | |||
}) | |||
end | end | ||
local | return tableData | ||
end | |||
function p._getItemSourceTables(item) | |||
local resultPart = {} | |||
local sourceData = {} | |||
p._getCreationTableData(item, sourceData) | |||
p._getItemUpgradeTableData(item, sourceData) | |||
p._getItemShopTableData(item, sourceData) | |||
local sourceTable = p.buildCreationTable(item, sourceData) | |||
if sourceTable ~= '' then | |||
table.insert(resultPart, sourceTable) | |||
end | end | ||
--[[ TODO: Uncomment this section | |||
local townshipTable = p._getTownshipTraderTable(item) | local townshipTable = p._getTownshipTraderTable(item) | ||
Line 1,599: | Line 1,582: | ||
table.insert(resultPart, '===Loot===\r\n'..lootTable) | table.insert(resultPart, '===Loot===\r\n'..lootTable) | ||
end | end | ||
--]] | |||
return table.concat(resultPart) | return table.concat(resultPart) | ||
end | end | ||
Line 1,722: | Line 1,706: | ||
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 | ||
function p.test() | function p.test() | ||
local checkItems = { | local checkItems = { | ||
"Circlet of Rhaelyx", | -- "Circlet of Rhaelyx", | ||
"Jewel of Rhaelyx", | -- "Jewel of Rhaelyx", | ||
"Signet Ring Half (a)", | -- "Signet Ring Half (a)", | ||
"Signet Ring Half (b)", | -- "Signet Ring Half (b)", | ||
"Gold Topaz Ring", | -- "Astrology Lesser Relic", | ||
" | -- "Mysterious Stone", | ||
" | -- "Gold Topaz Ring", | ||
"Charcoal", | |||
"Ash", | |||
"Coal Ore", | |||
"Rune Essence", | |||
"Gold Bar", | "Gold Bar", | ||
-- "Rune Platebody", | |||
"Arrow Shafts", | "Arrow Shafts", | ||
"Yew Longbow", | -- "Yew Longbow", | ||
"Water Rune", | -- "Water Rune", | ||
"Steam Rune", | "Steam Rune", | ||
-- "Wolf", | |||
"Fox", | |||
" | |||
"Leprechaun", | "Leprechaun", | ||
"Redwood Logs", | "Void Wisp", | ||
-- "Redwood Logs", | |||
-- "Shadow Raven Nest", | |||
"Raw Shrimp", | |||
"Shrimp", | |||
"Carrot Cake", | "Carrot Cake", | ||
"Carrot Cake (Perfect)", | -- "Carrot Cake (Perfect)", | ||
"Mantalyme Herb", | -- "Mantalyme Herb", | ||
"Carrot", | "Carrot", | ||
"Controlled Heat Potion II", | |||
"Topaz", | "Topaz", | ||
" | "Oricha", | ||
"Sanguine Blade", | "Nightopal", | ||
"Ring of Power", | -- "Sanguine Blade", | ||
"Infernal Claw", | -- "Ring of Power", | ||
"Chapeau Noir", | -- "Infernal Claw", | ||
-- "Chapeau Noir", | |||
"Stardust", | "Stardust", | ||
"Golden Stardust", | |||
"Abyssal Stardust", | |||
"Rope", | "Rope", | ||
"Ancient Ring of Mastery", | "Ancient Ring of Mastery", | ||
"Mastery Token (Cooking)", | "Mastery Token (Cooking)", | ||
"Gem Gloves", | "Gem Gloves", | ||
"Magic Bones", | |||
"Bowstring", | |||
"Superior Max Skillcape", | |||
"Thief's Moneysack", | "Thief's Moneysack", | ||
"Golden Star", | "Golden Star", | ||
"Slayer Deterer", | -- "Slayer Deterer", | ||
"Paper", | "Paper", | ||
"Lemon", | -- "Lemon", | ||
"Aranite Brush", | "Aranite Brush", | ||
"Barrier Dust", | "Barrier Dust", | ||
" | "Gloom Resin", | ||
" | "Gloom Amber", | ||
"Gloom Vine", | |||
"Gloom Vein Seed", | |||
"Elite Chest", | |||
"Abyssal Coin Contract II", | |||
"Dark Summon Consumable II", | |||
} | } | ||
local checkFuncs = { | local checkFuncs = { | ||
p.getItemSourceTables, | |||
--p.getCreationTable, | --p.getCreationTable, | ||
--p.getItemSources, | --p.getItemSources, | ||
Line 1,799: | Line 1,799: | ||
end | end | ||
end | end | ||
return p | return p |