12,714
edits
(_getShopTable: Add override support for purchases with increasing costs) |
m (Fix typo) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
local ShopData = mw.loadData('Module:Shop/data') | local ShopData = mw.loadData('Module:Shop/data') | ||
local ConstantData = mw.loadData('Module:Constants/data') | local ConstantData = mw.loadData('Module:Constants/data') | ||
-- Data instead of Module:CombatAreas to avoid loop | -- Data instead of Module:CombatAreas to avoid loop when that module attempts to require Module:Shop | ||
local AreaData = require('Module:CombatAreas/data') | local AreaData = require('Module:CombatAreas/data') | ||
Line 55: | Line 55: | ||
elseif stat == 'type' then | elseif stat == 'type' then | ||
return p._getPurchaseType(purchase) | return p._getPurchaseType(purchase) | ||
elseif stat == 'buyLimit' then | |||
return p._getPurchaseBuyLimit(purchase, not displayInline) | |||
else | else | ||
return purchase[stat] | return purchase[stat] | ||
Line 183: | Line 185: | ||
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 197: | ||
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, '| data-sort-value="' .. GPVal .. '"| ' .. Icons.GP(GPVal)) | |||
end | end | ||
end | end | ||
Line 204: | Line 210: | ||
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, '| 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| ' .. Icons.GP(GPTotal) .. '\r\n|}') | |||
end | |||
local delim = (asList and '<br/>' or '\r\n') | local delim = (asList and '<br/>' or '\r\n') |