17,370
edits
(_getShopTable: Add override support for purchases with increasing costs) |
m (_getPurchaseContents: Add sale value) |
||
Line 183: | Line 183: | ||
if asList == nil then asList = true end | if asList == nil then asList = true end | ||
local containArray = {} | local containArray = {} | ||
local GPTotal = 0 | |||
if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 0 then | if purchase.contains.items ~= nil and Shared.tableCount(purchase.contains.items) > 0 then | ||
if not asList then | if not asList then | ||
table.insert(containArray, '{| class="wikitable sortable stickyHeader"') | table.insert(containArray, '{| class="wikitable sortable stickyHeader"') | ||
table.insert(containArray, '|- class="headerRow-0"') | table.insert(containArray, '|- class="headerRow-0"') | ||
table.insert(containArray, '! colspan="2" | Item !! Quantity') | table.insert(containArray, '! colspan="2" | Item !! Quantity !! Price') | ||
end | end | ||
for i, itemLine in Shared.skpairs(purchase.contains.items) do | for i, itemLine in Shared.skpairs(purchase.contains.items) do | ||
Line 194: | Line 195: | ||
table.insert(containArray, Icons.Icon({item.name, type='item', qty=itemLine[2]})) | table.insert(containArray, Icons.Icon({item.name, type='item', qty=itemLine[2]})) | ||
else | else | ||
local GPVal = item.sellsFor * itemLine[2] | |||
GPTotal = GPTotal + GPVal | |||
table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({item.name, type='item', notext=true, size='25'})) | table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({item.name, type='item', notext=true, size='25'})) | ||
table.insert(containArray, '| ' .. Icons.Icon({item.name, type='item', noicon=true}) .. '\r\n| data-sort-value="' .. itemLine[2] .. '" style="text-align:right" | ' .. Shared.formatnum(itemLine[2])) | table.insert(containArray, '| ' .. Icons.Icon({item.name, type='item', noicon=true}) .. '\r\n| data-sort-value="' .. itemLine[2] .. '" style="text-align:right" | ' .. Shared.formatnum(itemLine[2])) | ||
table.insert(containArray, '| style="text-align:right;" data-sort-value="' .. GPVal .. '"| ' .. Icons.GP(GPVal)) | |||
end | end | ||
end | end | ||
Line 204: | Line 208: | ||
else | else | ||
table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({purchase.name, type='item', notext=true, size='25'})) | table.insert(containArray, '|-\r\n| style="min-width:25px"| ' .. Icons.Icon({purchase.name, type='item', notext=true, size='25'})) | ||
table.insert(containArray, '| ' .. Icons.Icon({ | table.insert(containArray, '| ' .. Icons.Icon({purchase.name, type='item', noicon=true}) .. ' Charges\r\n| data-sort-value="' .. purchase.charges .. '" style="text-align:right" | ' .. Shared.formatnum(purchase.charges)) | ||
table.insert(containArray, '| style="text-align:right; data-sort-value="0"| ' .. Icons.GP(0)) | |||
end | end | ||
end | end | ||
if not asList and Shared.tableCount(containArray) > 0 then table.insert(containArray, '|}') end | if not asList and Shared.tableCount(containArray) > 0 then | ||
table.insert(containArray, '|- class="sortbottom"\r\n! colspan="3"| Total\r\n| style="text-align:right;"| ' .. Icons.GP(GPTotal) .. '\r\n|}') | |||
end | |||
local delim = (asList and '<br/>' or '\r\n') | local delim = (asList and '<br/>' or '\r\n') | ||
Line 222: | Line 229: | ||
return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]" | return "ERROR: Couldn't find purchase with name '" .. purchaseName .. "'[[Category:Pages with script errors]]" | ||
else | else | ||
return p._getPurchaseContents(purchase, asList) | return p._getPurchaseContents(purchase, asList) .. '[[Category:GetPurchaseContents]]' | ||
end | end | ||
end | end |