4,951
edits
Falterfire (talk | contribs) (Added shop icon to purchase list) |
Falterfire (talk | contribs) (Added p.getPurchases for use in the ModifierTables module I'm working on) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 8: | Line 8: | ||
local Constants = require('Module:Constants') | local Constants = require('Module:Constants') | ||
local Areas = require('Module:CombatAreas') | local Areas = require('Module:CombatAreas') | ||
function p.processPurchase(category, purchaseID) | function p.processPurchase(category, purchaseID) | ||
Line 90: | Line 76: | ||
table.insert(reqArray, Icons.Icon({purchase.name, type=(isUpgrade and 'upgrade' or 'item')})..' Purchased') | table.insert(reqArray, Icons.Icon({purchase.name, type=(isUpgrade and 'upgrade' or 'item')})..' Purchased') | ||
end | end | ||
end | |||
if reqs.completionPercentage ~= nil then | |||
table.insert(reqArray, tostring(reqs.completionPercentage) .. '% Completion Log') | |||
end | end | ||
Line 151: | Line 141: | ||
for k, costLine in Shared.skpairs(purchase.cost.items) do | for k, costLine in Shared.skpairs(purchase.cost.items) do | ||
if costLine[1] == itemID then | if costLine[1] == itemID then | ||
local temp = p.processPurchase(catName, j - 1) | |||
temp.qty = costLine[2] | |||
table.insert(purchaseArray, temp) | |||
break | break | ||
end | end | ||
Line 170: | Line 162: | ||
for k, containsLine in Shared.skpairs(purchase.contains.items) do | for k, containsLine in Shared.skpairs(purchase.contains.items) do | ||
if containsLine [1] == itemID then | if containsLine [1] == itemID then | ||
local temp = p.processPurchase(catName, j - 1) | |||
temp.qty = containsLine[2] | |||
table.insert(purchaseArray, temp) | |||
break | break | ||
end | end | ||
Line 178: | Line 172: | ||
end | end | ||
if | return purchaseArray | ||
end | |||
function p.getPurchases(checkFunc) | |||
local purchaseList = {} | |||
for category, purchaseArray in Shared.skpairs(ShopData.Shop) do | |||
for i, purchase in Shared.skpairs(purchaseArray) do | |||
if checkFunc(purchase) then | |||
table.insert(purchaseList, p.processPurchase(category, i - 1)) | |||
end | |||
end | |||
end | end | ||
return purchaseList | |||
return | |||
end | end | ||