4,978
edits
(Revert: "Use Recipe icon for source icons when available"; Purchase outputs no longer show icon text when in a table; Add more fallbacks to display N/A when data is nil) |
(Separate Rune costs in Creation Table; Add Township and Superheat creation data into Creation Table;) |
||
Line 325: | Line 325: | ||
for i, altSpell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | for i, altSpell in ipairs(Magic.getSpellsBySpellBook('altMagic')) do | ||
if altSpell.produces == itemID then | if altSpell.produces == itemID then | ||
local imgType = Magic._getSpellIconType(altSpell) | |||
table.insert(tableData, { | table.insert(tableData, { | ||
['skill'] = 'Magic', | ['skill'] = 'Magic', | ||
Line 330: | Line 331: | ||
['isAbyssal'] = false, | ['isAbyssal'] = false, | ||
['xp'] = altSpell.baseExperience, | ['xp'] = altSpell.baseExperience, | ||
['costs'] = altSpell | ['costs'] = Magic._getAltSpellCostText(altSpell), | ||
['qty'] = altSpell.productionRatio, | ['qty'] = altSpell.productionRatio, | ||
['source'] = Icons.Icon({ altSpell.name, type= | ['source'] = Icons.Icon({ altSpell.name, type=imgType }), | ||
['time'] = 2, | ['time'] = 2, | ||
[' | ['runeCost'] = Magic._getSpellRunes(altSpell) | ||
}) | }) | ||
end | end | ||
Line 366: | Line 367: | ||
local showRequirements = false | local showRequirements = false | ||
local showInputs = false | local showInputs = false | ||
local showRunes = false | |||
local showOutputs = false | local showOutputs = false | ||
local showXP = false | local showXP = false | ||
Line 383: | Line 385: | ||
if not showInputs and tableData[1].costs ~= tableData[i].costs then | if not showInputs and tableData[1].costs ~= tableData[i].costs then | ||
showInputs = true | showInputs = true | ||
colspan = colspan + 1 | |||
end | |||
if not showRunes and tableData[1].runeCost ~= tableData[i].runeCost then | |||
showRunes = true | |||
colspan = colspan + 1 | colspan = colspan + 1 | ||
end | end | ||
Line 422: | Line 428: | ||
end | end | ||
else | else | ||
local costStr = data.costs:gsub(', ', '<br>') | |||
costsRow:wikitext(costStr) | |||
local costStr = data. | |||
costsRow:wikitext( | |||
end | end | ||
end | end | ||
Line 438: | Line 440: | ||
if showRequirements then tableHeader:tag('th'):wikitext('Requires') end | if showRequirements then tableHeader:tag('th'):wikitext('Requires') end | ||
if showInputs then tableHeader:tag('th'):wikitext('Costs') end | if showInputs then tableHeader:tag('th'):wikitext('Costs') end | ||
if showRunes then tableHeader:tag('th'):wikitext('Runes') end | |||
if showOutputs then tableHeader:tag('th'):wikitext('Outputs') end | if showOutputs then tableHeader:tag('th'):wikitext('Outputs') end | ||
if showXP then tableHeader:tag('th'):wikitext('Exp') end | if showXP then tableHeader:tag('th'):wikitext('Exp') end | ||
Line 459: | Line 462: | ||
if data.costs ~= nil then | if data.costs ~= nil then | ||
addCostsRow(recipeRow, data, 1) | addCostsRow(recipeRow, data, 1) | ||
else | |||
recipeRow:tag('td'):wikitext('N/A'):addClass('table-na') | |||
end | |||
end | |||
if showRunes then | |||
if data.runeCost ~= nil then | |||
recipeRow:tag('td'):wikitext(data.runeCost):addClass('center') | |||
else | else | ||
recipeRow:tag('td'):wikitext('N/A'):addClass('table-na') | recipeRow:tag('td'):wikitext('N/A'):addClass('table-na') | ||
Line 474: | Line 485: | ||
end | end | ||
end | end | ||
if showXP then | if showXP then | ||
if data.skill ~= nil and data.xp ~= nil then | if data.skill ~= nil and data.xp ~= nil then | ||
Line 494: | Line 506: | ||
if showChance then | if showChance then | ||
if data.weight ~= nil then | if data.weight ~= nil then | ||
recipeRow:tag('td'):wikitext(Num.fraction(data.weight, (data.totalWeight or 100))) | recipeRow:tag('td'):wikitext(Num.fraction(data.weight, (data.totalWeight or 100))):addClass('center') | ||
recipeRow:tag('td'):wikitext(Num.round2(data.weight / (data.totalWeight or 100) * 100, 2) .. '%') | recipeRow:tag('td'):wikitext(Num.round2(data.weight / (data.totalWeight or 100) * 100, 2) .. '%'):addClass('center') | ||
else | else | ||
recipeRow:tag('td'):wikitext('100%'):addClass('center'):attr('colspan', 2) | recipeRow:tag('td'):wikitext('100%'):addClass('center'):attr('colspan', 2) | ||
Line 508: | Line 520: | ||
:tag('td'):attr('colspan', colspan):wikitext(tableData[1].source) | :tag('td'):attr('colspan', colspan):wikitext(tableData[1].source) | ||
end | end | ||
if not showRequirements and tableData[1].reqs ~= nil then | if not showRequirements and tableData[1].reqs ~= nil then | ||
local reqRow = resultTable:tag('tr') | local reqRow = resultTable:tag('tr') | ||
Line 513: | Line 526: | ||
:tag('td'):wikitext(tableData[1].reqs):attr('colspan', colspan) | :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') | ||
Line 519: | Line 533: | ||
addCostsRow(costRow, tableData[1], colspan) | addCostsRow(costRow, tableData[1], colspan) | ||
end | end | ||
if showRunes and type(tableData[1].runeCost) == 'string' then | |||
local costStr = tableData[1].runeCost:gsub(', ', '<br>') | |||
recipeRow:tag('td'):wikitext('<br>' .. costStr):addClass('center') | |||
end | |||
if not showOutputs and tableData[1].qty ~= nil then | if not showOutputs and tableData[1].qty ~= nil then | ||
local outputRow = resultTable:tag('tr') | local outputRow = resultTable:tag('tr') | ||
Line 529: | Line 549: | ||
end | 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') | local xpText = (tableData[1].isAbyssal and ' AXP' or ' XP') | ||
Line 535: | Line 556: | ||
:tag('td'):attr('colspan', colspan):wikitext(Num.formatnum(tableData[1].xp) .. xpText) | :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') | ||
Line 546: | Line 568: | ||
end | end | ||
end | end | ||
if not showChance and tableData[1].weight ~= nil then | if not showChance and tableData[1].weight ~= nil then | ||
local chanceData = resultTable:tag('tr') | local chanceData = resultTable:tag('tr') | ||
Line 1,451: | Line 1,474: | ||
end | end | ||
function p. | function p._getItemSuperheatTableData(item, tableData) | ||
if tableData == nil then tableData = {} end | |||
-- Validate that the item can be superheated | -- Validate that the item can be superheated | ||
local smithRecipe = p._getSuperheatSmithRecipe(item) | local smithRecipe = p._getSuperheatSmithRecipe(item) | ||
Line 1,459: | Line 1,483: | ||
end | end | ||
local oreStringPart, coalString = {}, '' | local oreStringPart, coalString, smithingReq = {}, '', Icons._SkillReq('Smithing', smithRecipe.level, false) | ||
for i, mat in ipairs(smithRecipe.itemCosts) do | for i, mat in ipairs(smithRecipe.itemCosts) do | ||
local matItem = Items.getItemByID(mat.id) | local matItem = Items.getItemByID(mat.id) | ||
if mat.id == 'melvorD:Coal_Ore' then | if mat.id == 'melvorD:Coal_Ore' then | ||
coalString = Icons.Icon({matItem.name, type='item | coalString = Icons.Icon({ matItem.name, type='item', qty=mat.quantity }) | ||
else | else | ||
table.insert(oreStringPart, Icons.Icon({matItem.name, type='item | table.insert(oreStringPart, Icons.Icon({ matItem.name, type='item', qty=mat.quantity })) | ||
end | end | ||
end | end | ||
--Loop through all the variants | --Loop through all the variants | ||
Line 1,483: | Line 1,498: | ||
if spell.specialCost ~= nil and Shared.contains({ 'BarIngredientsWithCoal', 'BarIngredientsWithoutCoal' }, spell.specialCost.type) then | if spell.specialCost ~= nil and Shared.contains({ 'BarIngredientsWithCoal', 'BarIngredientsWithoutCoal' }, spell.specialCost.type) then | ||
local imgType = Magic._getSpellIconType(spell) | local imgType = Magic._getSpellIconType(spell) | ||
local costs = table.concat(oreStringPart, '<br>') | |||
if spell.specialCost.type == 'BarIngredientsWithCoal' and coalString ~= '' then | if spell.specialCost.type == 'BarIngredientsWithCoal' and coalString ~= '' then | ||
costs = costs .. '<br>' .. coalString | |||
end | end | ||
table.insert( | |||
table.insert(tableData, { | |||
['skill'] = 'Magic', | |||
['reqs'] = smithingReq .. '<br>' .. Icons._SkillReq('Magic', spell.level, false), | |||
['isAbyssal'] = false, | |||
['xp'] = spell.baseExperience, | |||
['costs'] = costs, | |||
['qty'] = spell.productionRatio, | |||
['source'] = Icons.Icon({ spell.name, type=imgType }), | |||
['time'] = 2, | |||
['runeCost'] = Magic._getSpellRunes(spell) | |||
}) | |||
end | end | ||
end | end | ||
return tableData | |||
return | |||
end | end | ||
Line 1,507: | Line 1,528: | ||
end | end | ||
return p. | return p.buildCreationTable(p._getItemSuperheatTableData(item), item) | ||
end | end | ||
function p. | function p._getTownshipTraderTableData(item, tableData) | ||
if tableData == nil then tableData = {} end | |||
for i, tsResource in ipairs(SkillData.Township.itemConversions.fromTownship) do | for i, tsResource in ipairs(SkillData.Township.itemConversions.fromTownship) do | ||
for j, tradeDef in ipairs(tsResource.items) do | for j, tradeDef in ipairs(tsResource.items) do | ||
if tradeDef.itemID == item.id then | if tradeDef.itemID == item.id then | ||
-- Item found, | -- Item found, insert the data | ||
local res = GameData.getEntityByID(SkillData.Township.resources, tsResource.resourceID) | local res = GameData.getEntityByID(SkillData.Township.resources, tsResource.resourceID) | ||
local resName = (res ~= nil and res.name) or 'Unknown' | local resName = (res ~= nil and res.name) or 'Unknown' | ||
local resQty = math.max(item.sellsFor, 2) | local resQty = math.max(item.sellsFor, 2) | ||
table.insert(tableData, { | |||
table.insert( | ['reqs'] = Shop.getRequirementString(tradeDef.unlockRequirements), | ||
['isAbyssal'] = namespace == 'melvorItA', | |||
['costs'] = Icons.Icon({ resName, qty=resQty, type='resource' }), | |||
['qty'] = 1, | |||
['source'] = Icons.Icon({'Township', 'Trader', type='skill'}), | |||
}) | |||
break | |||
end | end | ||
end | end | ||
end | end | ||
return | |||
return tableData | |||
end | end | ||
-- TODO: Remove this maybe? | -- TODO: Remove this maybe? | ||
function p._getItemShopTableData(item, tableData) | function p._getItemShopTableData(item, tableData) | ||
Line 1,571: | Line 1,594: | ||
local resultPart = {} | local resultPart = {} | ||
local sourceData = {} | local sourceData = {} | ||
-- Is the item Created or Produced by anything? | |||
p._getCreationTableData(item, sourceData) | p._getCreationTableData(item, sourceData) | ||
-- Can the item be obtained by upgrading? | |||
p._getItemUpgradeTableData(item, sourceData) | p._getItemUpgradeTableData(item, sourceData) | ||
-- Can the item be obtained by Superheating? | |||
if p._getSuperheatSmithRecipe(item) ~= nil then | |||
p._getItemSuperheatTableData(item, sourceData) | |||
end | |||
-- Can the item be traded for in Township? | |||
p._getTownshipTraderTableData(item, sourceData) | |||
-- Can the item be purchased? | |||
p._getItemShopTableData(item, sourceData) | p._getItemShopTableData(item, sourceData) | ||
Line 1,581: | Line 1,612: | ||
end | end | ||
--[[ TODO: Uncomment this section | --[[ TODO: Uncomment this section | ||
local lootTable = p._getItemLootSourceTable(item) | local lootTable = p._getItemLootSourceTable(item) | ||
if lootTable ~= '' then | if lootTable ~= '' then | ||
Line 1,737: | Line 1,757: | ||
"Coal Ore", | "Coal Ore", | ||
"Rune Essence", | "Rune Essence", | ||
" | "Dragonite Bar", | ||
-- "Rune Platebody", | -- "Rune Platebody", | ||
"Arrow Shafts", | "Arrow Shafts", |