Anonymous

Module:Shop: Difference between revisions

From Melvor Idle
Remove getAutoEatTable in favour of manual table
(getAutoEatTable: Fix modifier handling)
(Remove getAutoEatTable in favour of manual table)
Line 563: Line 563:


function p.getShopMiscUpgradeTable()
function p.getShopMiscUpgradeTable()
-- All purchases in the general category besides Auto Eat, which is handled by getAutoEatTable()
-- All purchases in the general category besides Auto Eat, which is conained within a separate table
local purchList = p.getPurchases(function(purch) return purch.category == 'melvorD:General' and string.find(purch.id, '^melvorD:Auto_Eat') == nil end)
local purchList = p.getPurchases(function(purch) return purch.category == 'melvorD:General' and string.find(purch.id, '^melvorD:Auto_Eat') == nil end)


Line 708: Line 708:
return table.concat(resultPart)
return table.concat(resultPart)
end
end
end
function p.getAutoEatTable()
local resultPart = {}
local purchasesAE = p.getPurchases(function(purch) return purch.category == 'melvorD:General' and string.find(purch.id, '^melvorD:Auto_Eat') ~= nil end)
-- Table header
table.insert(resultPart, '{| class="wikitable sortable stickyHeader"')
table.insert(resultPart, '|- class="headerRow-0"')
table.insert(resultPart, '!colspan="2"|Auto Eat Tier!!Minimum Threshold!!Efficiency!!Max Healing!!Cost')
-- Rows for each Auto Eat tier
local mods = {["autoEatEfficiency"] = 0, ["autoEatHPLimit"] = 0, ["autoEatThreshold"] = 0}
for i, purchase in ipairs(purchasesAE) do
local purchaseName = Common.getPurchaseName(purchase)
-- Modifiers must be accumulated as we go
for modName, modValue in pairs(mods) do
if purchase.contains.modifiers[modName] ~= nil then
mods[modName] = mods[modName] + purchase.contains.modifiers[modName]
end
end
table.insert(resultPart, '|-\r\n|class="table-img" data-sort-value="' .. purchaseName .. '"| ' .. Icons.Icon({purchaseName, type='upgrade', notext=true}))
table.insert(resultPart, '| ' .. Icons.Icon({purchaseName, type='upgrade', noicon=true}))
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.autoEatThreshold .. '" | ' .. Num.formatnum(Num.round(mods.autoEatThreshold, 0, 0)) .. '%')
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.autoEatEfficiency .. '" | ' .. Num.formatnum(Num.round(mods.autoEatEfficiency, 0, 0)) .. '%')
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. mods.autoEatHPLimit .. '" | ' .. Num.formatnum(Num.round(mods.autoEatHPLimit, 0, 0)) .. '%')
table.insert(resultPart, '| style="text-align:right;" data-sort-value="' .. p._getPurchaseSortValue(purchase) .. '" | ' .. p.getCostString(purchase.cost, false))
end
table.insert(resultPart, '|}')
return table.concat(resultPart, '\r\n')
end
end