1,131
edits
No edit summary |
mNo edit summary |
||
| (35 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-------------------------- | |||
-- Module for [[Template:Store_locations_list]] | |||
-- | |||
-- | |||
------------------------ | |||
-- <pre> | -- <pre> | ||
local p = {} | local p = {} | ||
| Line 6: | Line 12: | ||
local yesNo = require("Module:Yesno") | local yesNo = require("Module:Yesno") | ||
local purge = require("Module:Purge")._purge | local purge = require("Module:Purge")._purge | ||
local inspect = require("Module:Inspect") | |||
--local p2pIcon = '[[File:Member icon.png|frameless|link=Pay-to-play]]' | |||
--local f2pIcon = '[[File:Free-to-play icon.png|frameless|link=Free-to-play]]' | |||
local p2pIcon = ' | local p2pIcon = 'Yes' | ||
local f2pIcon = ' | local f2pIcon = 'No' | ||
function p.main(frame) | function p.main(frame) | ||
| Line 14: | Line 24: | ||
end | end | ||
function p._main(args) | function p._main(args) | ||
| Line 45: | Line 43: | ||
:tag('th'):wikitext('Seller'):done() | :tag('th'):wikitext('Seller'):done() | ||
:tag('th'):wikitext('Location'):done() | :tag('th'):wikitext('Location'):done() | ||
:tag('th'):wikitext(' | :tag('th'):wikitext('Buyable for'):attr('data-sort-type', 'number'):done() | ||
:tag('th'):wikitext(' | :tag('th'):wikitext('Sellable for'):attr('data-sort-type', 'number'):done() | ||
:tag('th'):wikitext('Members?'):done() | :tag('th'):wikitext('Members?'):done() | ||
:done() | :done() | ||
local function addShopRow(shop, location) | |||
restbl:tag('tr') | |||
:tag('td'):wikitext(shop.seller):done() | |||
:tag('td'):wikitext(location):done() | |||
:tag('td') | |||
:attr({['data-sort-value']=shop.buySortValue}) | |||
:wikitext(shop.buyvalue) | |||
:done() | |||
:tag('td') | |||
:attr({['data-sort-value']=shop.sellSortValue}) | |||
:wikitext(shop.sellvalue) | |||
:done() | |||
:tag('td') | |||
:attr({['data-sort-value']=shop.membersSortValue}) | |||
:wikitext(shop.members):done() | |||
:done() | |||
end | |||
-- Create the rows for the output table | -- Create the rows for the output table | ||
for _, shop in ipairs(data) do | for _, shop in ipairs(data) do | ||
for i, location in ipairs(shop.location) do | for i, location in ipairs(shop.location) do | ||
addShopRow(shop, location) | |||
end | |||
if #shop.location == 0 then | |||
addShopRow(shop, 'N/A') | |||
end | end | ||
end | end | ||
| Line 82: | Line 90: | ||
'?Sold by.Is members only = Is members only', | '?Sold by.Is members only = Is members only', | ||
'?Sold by.NPC location = NPC location', | '?Sold by.NPC location = NPC location', | ||
'?Sold item Members', | |||
'?Sold by.Has subobject.NPC location=NPC location subobj', | '?Sold by.Has subobject.NPC location=NPC location subobj', | ||
'?Sold item image', | '?Sold item image', | ||
| Line 90: | Line 99: | ||
'?Store currency #', | '?Store currency #', | ||
'?Store notes', | '?Store notes', | ||
'?Members #', | |||
'?Is members only #', | |||
offset = 0, | offset = 0, | ||
limit = limit or 500, | limit = limit or 500, | ||
| Line 112: | Line 123: | ||
table.insert(members, item['Store Is members only']) | table.insert(members, item['Store Is members only']) | ||
elseif type(item['Is members only']) == 'boolean' then | elseif type(item['Is members only']) == 'boolean' then | ||
table.insert(members, item['Is members only']) | |||
elseif type(item['Is members only']) == 'string' then | |||
table.insert(members, item['Is members only']) | table.insert(members, item['Is members only']) | ||
end | end | ||
| Line 131: | Line 144: | ||
item['Location'] = location | item['Location'] = location | ||
-- item['Region'] = region | -- item['Region'] = region | ||
if #members == 1 then | if #members == 1 then | ||
item['Members'] = members[1] | item['Members'] = members[1] | ||
else | else | ||
| Line 144: | Line 158: | ||
-- Process the item and add it to the final data table | -- Process the item and add it to the final data table | ||
local dataline = p.processData(item, editbtn) | local dataline = p.processData(item, editbtn) | ||
table.insert(data, dataline) | table.insert(data, dataline) | ||
| Line 175: | Line 187: | ||
local sellvalue = item['Store sell price'] or '' | local sellvalue = item['Store sell price'] or '' | ||
local sellSortValue = 0 | local sellSortValue = 0 | ||
mw.log("sellvalue", sellvalue) | |||
mw.log("sell is 1e10", tonumber(sellvalue) == 1e10) | |||
if not(sellvalue == 1e10) then | if not(sellvalue =='N/A') and not(tonumber(sellvalue) == 1e10) then | ||
sellvalue = tonumber(sellvalue) | sellvalue = tonumber(sellvalue) | ||
| Line 197: | Line 212: | ||
sellvalue = 'N/A' | sellvalue = 'N/A' | ||
end | end | ||
mw.log("sellvalue 2", sellvalue) | |||
local buyvalue = item['Store buy price'] or '' | local buyvalue = item['Store buy price'] or '' | ||
local buySortValue = 0 | local buySortValue = 0 | ||
if not(buyvalue == 'N/A') then | |||
mw.log("buyvalue", buyvalue) | |||
mw.log("buy is 1e10", tonumber(buyvalue) == 1e10) | |||
if not(buyvalue == 'N/A') and not(tonumber(buyvalue) == 1e10) then | |||
buyvalue = tonumber(buyvalue) | buyvalue = tonumber(buyvalue) | ||
mw.log("buyvalue 2", buyvalue) | |||
if buyvalue then | if buyvalue then | ||
buySortValue = buyvalue | buySortValue = buyvalue | ||
buyvalue = commas(buyvalue) | buyvalue = commas(buyvalue) | ||
local currencyImg = '' | |||
if(params.has_content(currencyImg)) then | buyvalue = string.format('%s [[%s]]', buyvalue, currency) | ||
end | -- local currencyImg = '' | ||
-- if(params.has_content(currencyImg)) then | |||
-- currencyImg = string.format('[[File:%s|link=%s]] ', currencyImg, currency) | |||
-- buyvalue = currencyImg .. buyvalue | |||
-- end | |||
else | |||
buyvalue = editbtn -- If buyvalue can't be converted to a number it will default to the edit button | |||
end | |||
else | |||
buySortValue = buyvalue | |||
buyvalue = 'N/A' | |||
end | |||
-- members only? | -- members only? | ||
local members = item['Members'] | local members = item['Members'] | ||
if type(members) == 'table' then | if type(members) == 'table' then | ||
-- contains yes and/or no | -- contains yes and/or no | ||