2,875
edits
No edit summary |
No edit summary |
||
Line 49: | Line 49: | ||
end | end | ||
local function getSellablePurchases(checkFunc) | |||
local function getSellablePurchases() | |||
local func = | local func = | ||
function(purchase, name) | function(purchase, name) | ||
-- Exclude SC Purchases that provide no items. | |||
local items = purchase.contains.items | local items = purchase.contains.items | ||
if items == nil or Shared.tableIsEmpty(items) then | |||
return false | |||
end | |||
if checkFunc == nil then | |||
return true | |||
end | |||
return checkFunc(purchase) | |||
end | end | ||
Line 64: | Line 68: | ||
end | end | ||
local function getMostProfitablePurchases(amount) | local function getMostProfitablePurchases(amount, includeOnlyBulk) | ||
amount = tonumber(amount) | amount = tonumber(amount) | ||
if includeOnlyBulk == nil then includeOnlyBulk = true end | |||
local func = function(x) | |||
if includeOnlyBulk == true then | |||
return x.allowQuantityPurchase == true | |||
else | |||
return true | |||
end | |||
end | |||
local data = {} | local data = {} | ||
-- Gather value data about SC Shop Items | -- Gather value data about SC Shop Items | ||
for _, v in pairs(getSellablePurchases()) do | for _, v in pairs(getSellablePurchases(func)) do | ||
local gpValue = getPurchaseValue(v) | local gpValue = getPurchaseValue(v) | ||
local scCost = (v.cost.slayerCoins or {}).cost or 0 | local scCost = (v.cost.slayerCoins or {}).cost or 0 | ||
Line 98: | Line 109: | ||
function p.getSCItemProfits(frame) | function p.getSCItemProfits(frame) | ||
local args = frame:getParent().args | local args = frame:getParent().args | ||
return p._getSCItemProfits(args[1]) | return p._getSCItemProfits(args[1], args[2] or true) | ||
end | end | ||
function p._getSCItemProfits(amount) | function p._getSCItemProfits(amount, includeOnlyBulk) | ||
local purchases = getMostProfitablePurchases(amount) | local purchases = getMostProfitablePurchases(amount, includeOnlyBulk) | ||
local html = mw.html.create('table') | local html = mw.html.create('table') | ||
Line 160: | Line 171: | ||
end | end | ||
function p.test() | |||
mw.logObject(getPurchase("Magical Ring")) | |||
end | |||
return p | return p |
edits