17,101
edits
(getPurchaseByID: Implement) |
(getItemSourceArray: Fix handling of itemCharges contents) |
||
Line 579: | Line 579: | ||
function p.getItemSourceArray(itemID) | function p.getItemSourceArray(itemID) | ||
if purch.contains.items ~= nil and not Shared.tableIsEmpty(purch.contains.items) then | |||
item = Items.getItemByID(purch.contains.items[1].id) | |||
elseif purch.contains.itemCharges ~= nil and not Shared.tableIsEmpty(purch.contains.itemCharges) then | |||
item = Items.getItemByID(purch.contains.itemCharges.id) | |||
end | |||
local purchaseArray = {} | local purchaseArray = {} | ||
for i, purchase in ipairs(GameData.rawData.shopPurchases) do | for i, purchase in ipairs(GameData.rawData.shopPurchases) do | ||
if purchase.contains ~= nil | if purchase.contains ~= nil then | ||
if purchase.contains.items ~= nil then | |||
for j, itemContains in ipairs(purchase.contains.items) do | |||
if itemContains.id == itemID then | |||
table.insert(purchaseArray, { ["purchase"] = purchase, ["qty"] = itemContains.quantity }) | |||
break | |||
end | |||
end | |||
end | |||
if purchase.contains.itemCharges ~= nil and purchase.contains.itemCharges.id == itemID then | |||
table.insert(purchaseArray, { ["purchase"] = purchase, ["qty"] = 1 }) | |||
end | |||
end | end | ||
end | end |