Módulo:Store Line
Ir para navegação
Ir para pesquisar
Documentação do módulo
Esta documentação é transcluída de Predefinição:Sem documentação/doc. [editar] [atualizar]
Este módulo não possui nenhuma documentação. Por favor, considere adicionar uma documentação em Módulo:Store Line/doc. [editar]
Módulo:Store Line's a função main é invocada por Predefinição:ObjetoVendido.
Módulo:Store Line requer Módulo:Currency Image.
Módulo:Store Line requer Módulo:Mercado.
Módulo:Store Line requer Módulo:Mw.html extension.
Módulo:Store Line requer Módulo:Paramtest.
Módulo:Store Line requer Módulo:Yesno.
-- <nowiki>
require("Módulo:Mw.html extension")
local p = {}
local params = require('Módulo:Paramtest')
local lang = mw.language.getContentLanguage()
local curr_image = require('Módulo:Currency Image')
local exchange = require('Módulo:Mercado')
local yesno = require('Módulo:Yesno')
local geprice = exchange._price
local f_gealch = exchange._highalch
local _gealch = '<span class="dropsline-gealch" style="margin-left:0.3em;">[[Arquivo:Alquimia avançada.png|link=Alquimia avançada|frameless|20px]]</span>'
local _altval = '<span class="dropsline-altval" style="margin-left:0.3em;">[[Arquivo:AltValue.png|link=|frameless|20px]]</span>'
local ptitle = mw.title.getCurrentTitle()
local ns = ptitle.nsText
local title = ptitle.fullText
local pgTitle = ptitle.text
local _priceStrings = {
sell = "A loja vende por %s %s cada.",
sellF = "Amostra grátis.",
buy = "A loja compra por %s %s cada.",
ge = "%s moeda%s cada.",
geP = "%s moeda%s por pacote; este é o total por todos os objetos do pacote.",
alch = "%s moeda%s cada; este é o valor de alquimia avançada já que o objeto não pode ser negociado no Mercado Geral.",
alchP = "%s moeda%s por pacote; este é o valor total de alquimia avançada de todos os objetos do pacote já que eles não podem ser negociados no Mercado Geral já que eles não podem ser negociados no Mercado Geral.",
alt = "%s %s cada; este objeto possui um valor dinstinto, mesmo que ele não possa ser negociado no Mercado Geral ou ser alquimiado.",
res = "%s %s no total",
resEqu = "%s moeda%s por %s",
resOne = "%s %s cada. Estoque infinito disponível.",
resErr = "%s %s cada. Erro: O estoque inserido não é um número."
}
local smwData = nil
function getSMWInfo(item)
if smwData ~= nil then
return smwData
end
local smw = mw.smw.ask({
'[['..item..']]',
'?Alquimia Avançada',
'?É somente para membros'
})
if smw and smw[1] then
smwData = {
alch = smw[1]['Alquimia Avançada'],
members = smw[1]['É somente para membros']
}
else
smwData = false
end
return smwData
end
function commas(n)
if tonumber(n) then
return lang:formatNum(tonumber(n))
else
return n
end
end
-- function to get the currency image and name (singular vs plural)
function currencyInfo(currency,price)
price = tostring(price)
-- body
local lowcur = string.lower(currency)
local clean = price:gsub('%W','')
local retcur, img
if tonumber(clean) and tonumber(clean) ~= 1 then
retcur = currency
else
if lowcur == 'zemomarcos' or lowcur == 'tokkul' or lowcur == 'teci' then
retcur = currency
elseif lowcur == 'peças de oito' then
retcur = 'peça de oito'
else
retcur = string.sub(currency,1,(string.len(currency)-1))
end
end
img = curr_image(currency,price) or 'AltValue.png'
img = '<span class="dropsline-altval" style="margin-left:0.3em;">[[File:'..img..'|link=|frameless|20px]]</span>'
return img, retcur
end
function buysell(value)
if not tonumber(value) then
local val = yesno(value, value)
if type(val) == 'boolean' then
value = val
else
val = string.lower(val)
if val == 'não vendido' or
val == 'não comprado' or
val == 'nenhum' or
val== 'n/d' then
value = 'não'
end
end
end
return value
end
function p.main(frame)
local args = frame:getParent().args
local tempArgs = frame.args
-- Params and defaults
local name, namenotes, stock, sell, buy, altcur, pack, packNum = params.defaults{
{args.nome,'Objeto'}, --args.Name
{args.nomeNotas,''}, --args.Namenotes
{args.estoque,'Desconhecido'}, --args.Stock
{args.vender,'0'}, --args.Sell
{args.comprar,'0'}, --args.Buy
{args.moedaAlt,''}, --args.AltCurrency
{args.pacote, ''}, --args.Pack
{args.pacoteNum, '50'} --args.PackNum
}
local displayname = params.default_to(args.mostrarNome,name)
local gemwname = params.default_to(args.gemwname,args.pacote)
gemwname = gemwname or name
local arc = yesno(tempArgs.Arco or 'não', false)
local currency = params.default_to(tempArgs.Moeda,args.Moeda)
currency = currency or ''
-- Override currency from table head with currency set on line
if params.has_content(args.Moeda) then
currency = args.Moeda
end
local nosmw
if params.has_content(args.nosmw) then
nosmw = true
end
if params.has_content(tempArgs.nosmw) then
nosmw = true
end
-- Override for historical (removed items)
-- local historical = false
-- if params.has_content(args.Historical) then
-- historical = yesno(args.Historical,false)
-- end
-- if params.has_content(tempargs.Historical) then
-- historical = yesno(tempargs.Historical,false)
-- end
-- Check pack number
if not tonumber(packNum) then
packNum = '50'
end
-- Remove version number from potions, enchanted jewellery, waterskins etc for smw
local cleanedName
local dropVers = ''
if gemwname:match(' %(%d%)$') then
cleanedName, dropVers = mw.ustring.match(gemwname, '^(.-) (%(%d%))$')
elseif gemwname:match('%#') then
cleanedName, dropVers = mw.ustring.match(gemwname, '^(.-)%#([%w%s%(%)_]+)$')
else
cleanedName = mw.ustring.gsub(gemwname, ' %(%d%)$', '')
end
cleanedName = mw.text.trim(cleanedName)
dropVers = mw.text.trim(dropVers)
local smwname = cleanedName
if dropVers ~= '' then
-- get subobject instead
smwname = cleanedName..'#'..dropVers
end
stock = mw.ustring.lower(stock)
local gemw = true
if params.has_content(tempArgs.gemw) then
gemw = yesno(tempArgs.gemw or 'sim', false)
end
if yesno(args.gemw) ~= nil then
gemw = yesno(args.gemw)
end
local alch = yesno(args.alquimia or 'sim', false)
local hasAltCur = false
if params.has_content(altcur) and mw.ustring.lower(altcur) ~= 'moedas' then
hasAltCur = true
end
-- Test for existance of alch value
local hasmwalch, smwalchval
local valueInfo = {
alch = {
has = false,
value = 0,
from = nil
},
ge = {
has = false,
value = 0,
from = nil
}
}
if alch then
if gemw then
-- does not have no-ge override
-- lookup in GEMW
local hasgealch, gealchval = pcall(f_gealch,gemwname)
-- alch is not disabled
if hasgealch then
if gealchval > -1 then
-- has a alch value from GEMW
if #pack > 0 then
gealchval = tonumber(gealchval) * tonumber(packNum)
end
valueInfo.alch = {
has = true,
value = tonumber(gealchval),
from = 'ge'
}
end
end
end
if not valueInfo.alch.has then
-- failed to find alch in GEMW or has no-ge override
-- lookup in SMW
local smwret = getSMWInfo(smwname)
if smwret and smwret.alch ~= nil then
-- alch is defined, use it
if #pack > 0 then
smwret.alch = tonumber(smwret.alch) * tonumber(packNum)
end
valueInfo.alch = {
has = true,
value = smwret.alch,
from = 'smw'
}
elseif args.valorAlt then
--AltValue set, no alch from GE or SMW, use alt as regular alch
valueInfo.alch = {
has = true,
value = tonumber(args.valorAlt),
from = 'alt'
}
if hasAltCur then
valueInfo.alch.curr = altcur
end
else
alch = false
end
end
else
-- alch is disabled
if args.valorAlt then
--Altvalue set, no alch value
valueInfo.alch = {
has = true,
value = tonumber(args.valorAlt),
from = 'alt'
}
if hasAltCur then
valueInfo.alch.curr = altcur
end
end
end
-- Test for existence of an exchange page
if gemw then
local hasgemw, gepric = pcall(geprice,gemwname)
if hasgemw then
if #pack > 0 then
gepric = tonumber(gepric) * tonumber(packNum)
end
valueInfo.ge = {
has = true,
value = gepric,
from = 'ge'
}
else
valueInfo.ge = {
has = true,
value = valueInfo.alch.value,
from = 'alch'
}
if valueInfo.alch.curr then
valueInfo.ge.curr = valueInfo.alch.curr
end
if valueInfo.alch.from == 'alt' then
valueInfo.ge.from = 'alt'
end
end
elseif args.valorAlt then
valueInfo.ge = {
has = true,
value = tonumber(args.valorAlt),
from = 'alt'
}
if hasAltCur then
valueInfo.ge.curr = altcur
end
elseif alch then
valueInfo.ge = {
has = true,
value = valueInfo.alch.value,
from = 'alch'
}
if valueInfo.alch.curr then
valueInfo.ge.curr = valueInfo.alch.curr
end
end
-- Use 'File:<name>.png' if no image param
-- Use 'File:<image>' if image param; image param will include extension
local image,image_n
image_n = params.default_to(args.imagem, name .. '.png')
image_n = mw.ustring.gsub(image_n, '#.+$', '.png')
if image_n:lower() == 'não' or params.is_empty(args.nome) then
image = ''
else
image = mw.ustring.format('[[File:%s|link=%s|alt=%s: %s sells %s of %s for %s and buys them for %s]]', image_n, name, image_n, title, stock, name, sell, buy)
end
local description = args['descrição']
-- Table row
local ret
if arc then
currency = 'Sinos'
ret = p._arc{ name,displayname,
stock,sell,buy,currency,
pack,packNum,
image,
valueInfo,gemw,alch,
tempArgs,
cleanedName,dropVers,smwname,historical,nosmw }
else
ret = p._main{
name = name,
displayname = displayname,
namenotes = namenotes,
stock = stock,
sell = sell,
--sellnotes = sellnotes,
buy = buy,
currency = currency,
pack = pack,
packNum = packNum,
image = image,
valueInfo = valueInfo,
tempArgs = tempArgs,
smwname = smwname,
historical = historical,
nosmw = nosmw,
description = description,
}
end
return ret
end
-- main function to generate the row
function p._main(args)
-- Stock display
local stockSort, stockDisp, stockTtl
local infStock = false
local stockNum = tonumber(args.stock)
args.stock = string.lower(string.gsub(args.stock, ',', ''))
if args.stock == '∞' or args.stock == 'inf' or args.stock == 'infinito' then
stockSort = '10e99'
stockTtl = 'Infinito disponível'
stockDisp = '<span style="font-size:120%;">∞</span>'
infStock = true
elseif stockNum then
stockSort = args.stock
stockTtl = 'Estoque base de '..args.stock
stockDisp = commas(stockNum)
else
stockSort = -1
stockTtl = 'Estoque inválido de '..args.stock..'foi fornecido'
stockDisp = '<span style="color:#FF0000; border-bottom:1px dashed; font-weight:bold;">Erro</span>'
end
-- Correct currencies
if not args.currency or args.currency == '' then
args.currency = 'moedas'
end
if not args.valueInfo.ge.curr or args.valueInfo.ge.curr == '' then
args.valueInfo.ge.curr = 'moedas'
end
-- Clean buy, sell values
args.buy = buysell(args.buy)
args.sell = buysell(args.sell)
-- Sell, buy Display
local sellDisp, sellSort, sellTtl, buyDisp, buySort, buyTtl
local sellNum = tonumber(args.sell)
local buyNum = tonumber(args.buy)
if sellNum == 0 then
sellNum = 0
sellSort = sellNum
sellTtl = _priceStrings.sellF
sellDisp = 'Grátis'
elseif sellNum then
sellSort = sellNum
local sImg, sCur = currencyInfo(args.currency, sellNum)
sellTtl = mw.ustring.format(_priceStrings.sell, commas(sellNum), sCur)
sellDisp = commas(sellNum) .. sImg
elseif args.sell == 'não' or args.sell == false then
sellSort = -1
sellTtl = 'Este objeto não é vendido por esta loja'
sellDisp = 'Não vendido'
else
sellSort = tonumber('10e99')
sellTtl = 'O preço de venda inserido é inválido ou nenhum foi fornecido.'
sellDisp = '<span style="color:#FF0000; border-bottom:1px dashed; font-weight:bold;">Erro</span>'
end
if buyNum then
buySort = buyNum
local bImg, bCur = currencyInfo(args.currency,buyNum)
buyTtl = mw.ustring.format(_priceStrings.buy,commas(buyNum),bCur)
buyDisp = commas(buyNum)..bImg
elseif args.buy == 'não' or args.buy == false then
buySort = -1
buyTtl = 'Este objeto não pode ser vendido para esta loja'
buyDisp = 'Não comprado'
else
buySort = tonumber('10e99')
buyTtl = 'O preço de compra inserido é inválido ou nenhum foi fornecido.'
buyDisp = '<span style="color:#FF0000; border-bottom:1px dashed; font-weight:bold;">Erro</span>'
end
-- GE value and display
local geSort, geDisp, geTtl
local geImg, geCur = currencyInfo(args.valueInfo.ge.curr, args.valueInfo.ge.value)
if args.valueInfo.ge.from == 'ge' then
geSort = args.valueInfo.ge.value
if #args.pack > 0 then
geTtl = mw.ustring.format(_priceStrings.geP,commas(args.valueInfo.ge.value),lang:plural(args.valueInfo.ge.value or 0, '', 's'))
else
geTtl = mw.ustring.format(_priceStrings.ge,commas(args.valueInfo.ge.value),lang:plural(args.valueInfo.ge.value or 0, '', 's'))
end
geDisp = commas(args.valueInfo.ge.value)..geImg
elseif args.valueInfo.ge.from == 'alch' then
geSort = args.valueInfo.ge.value
if #args.pack > 0 then
geTtl = mw.ustring.format(_priceStrings.alchP,commas(args.valueInfo.ge.value),lang:plural(args.valueInfo.ge.value or 0, '', 's'))
else
geTtl = mw.ustring.format(_priceStrings.alch,commas(args.valueInfo.ge.value),lang:plural(args.valueInfo.ge.value or 0, '', 's'))
end
geDisp = commas(args.valueInfo.ge.value).._gealch
elseif args.valueInfo.ge.from == 'alt' then
geSort = args.valueInfo.ge.value - tonumber('10e10')
geTtl = mw.ustring.format(_priceStrings.alt,commas(args.valueInfo.ge.value),geCur)
geDisp = commas(args.valueInfo.ge.value)..geImg.._altval
else
-- No GE
geSort = 0 - tonumber('10e99')
geTtl = 'O objeto não pode ser vendido ou alquimiado'
geDisp = 'N/D'
end
-- Resale value cell contents
-- Resale = 0 if currencies don't match
local resale, resaleSort, resaleDisp, resaleTtl
local difCur = false
if args.valueInfo.ge.has and args.valueInfo.ge.value and sellNum then
if args.valueInfo.ge.curr == args.currency then
resale = args.valueInfo.ge.value - sellNum
if stockNum and not infStock then
resale = stockNum * resale
end
else
resale = args.valueInfo.ge.value / sellNum
resale = math.floor((resale * 100) + 0.5) / 100
difCur = true
end
end
if resale and difCur then
local sinImg, sinCur = currencyInfo(args.currency,1)
local resImg, resCur = currencyInfo('moedas',resale)
resaleSort = resale - tonumber('10e10')
resaleTtl = mw.ustring.format(_priceStrings.resEqu,commas(resale),lang:plural(resale or 0, '', 's'),sinCur)
resaleDisp = commas(resale)..resImg..'/'..sinImg
elseif resale and infStock then
local resImg, resCur = currencyInfo(args.currency,resale)
resaleSort = tonumber('10e99')
resaleTtl = mw.ustring.format(_priceStrings.resOne,commas(resale),resCur)
resaleDisp = mw.ustring.format('<span style="font-size:120%%;">∞</span> (%s)%s',commas(resale),resImg)
elseif resale and stockNum then
local resImg, resCur = currencyInfo(args.currency,resale)
resaleSort = resale
resaleTtl = mw.ustring.format(_priceStrings.res,commas(resale),resCur)
resaleDisp = commas(resale)..resImg
elseif resale then
local resImg, resCur = currencyInfo(args.currency,resale)
resaleSort = 0 - tonumber('10e97')
resaleTtl = mw.ustring.format(_priceStrings.resErr,commas(resale),resCur)
resaleDisp = mw.ustring.format('<span style="color:#FF0000; border-bottom:1px dashed; font-weight:bold;">%s%s</span>',commas(resale),resImg)
elseif difCur then
resaleSort = 0 - tonumber('10e98')
resaleTtl = 'Custo e valor são moedas diferentes'
resaleDisp = 'N/D'
else
resaleSort = 0 - tonumber('10e99')
resaleTtl = 'O objeto não é negociável ou alquimiável e nenhum valor foi fornecido'
resaleDisp = 'N/D'
end
local ret = mw.html.create('tr')
-- inventory image
:td{
css = {'text-align', 'center'},
class = 'inventory-image',
wikitext = args.image,
}
-- item name
:td{
css = {'text-align', 'left'},
class = 'item-col',
wikitext = string.format('[[%s|%s]]%s', args.name, args.displayname, #args.namenotes > 3 and args.namenotes or ''),
}
-- stock
:td{
css = {'text-align', 'center'},
class = 'stock-col',
attr = {
['data-sort-value'] = stockSort,
['title'] = stockTtl,
},
wikitext = stockDisp,
}
-- sell price
:td{
css = {
['text-align'] = 'right',
cursor = 'help',
},
class = 'sell-col ref-left',
attr = {
['data-sort-value'] = sellSort,
['title'] = sellTtl,
},
wikitext = sellDisp,
}
-- buy price
:td{
css = {
['text-align'] = 'right',
cursor = 'help',
},
class = 'buy-col',
attr = {
['data-sort-value'] = buySort,
['title'] = buyTtl,
},
wikitext = buyDisp,
}
-- GE price
:td{
css = {
['text-align'] = 'right',
cursor = 'help'
},
class = 'ge-column',
attr = {
['data-sort-value'] = geSort,
['title'] = geTtl,
},
wikitext = geDisp,
}
-- resale value
:td{
css = {
['text-align'] = 'right',
cursor = 'help',
},
class = 'resale-col',
attr = {
['data-sort-value'] = resaleSort,
['title'] = resaleTtl,
},
wikitext = resaleDisp,
}
-- description
:IF(args.description)
:td{
css = {'text-align', 'left'},
class = 'description-col',
wikitext = args.description,
}
:END()
:done()
--Add class if line but not table is historical
if args.historical and not yesno(args.tempargs.Historical,false) then
ret:addClass('storeline-hist')
end
-- SMW
if ns == '' and not args.nosmw then
local smw = {}
local smw_sub = {}
local source = pgTitle
--add function to reduce image to File:Some name.png
if args.historical then
smw['Sells item hist'] = args.name
smw_sub = {
['Sold by hist'] = source,
['Sold item image'] = mw.text.encode(args.image),
['Sold item hist'] = args.name,
['Sold item text'] = args.displayname,
['Store stock'] = stockNum,
['Store sell price'] = args.sell,
['Store buy price'] = args.buy,
['Store currency'] = args.currency,
}
else
smw['Sells item'] = args.name
smw_sub = {
['Sold by'] = source,
['Sold item image'] = mw.text.encode(args.image),
['Sold item'] = args.name,
['Sold item text'] = args.displayname,
['Store stock'] = stockNum,
['Store sell price'] = args.sell,
['Store buy price'] = args.buy,
['Store currency'] = args.currency,
}
end
if infStock then
smw_sub['Store stock infinite'] = true
smw_sub['Store stock'] = nil
end
if #args.pack > 0 and args.historical then
smw_sub['Pack of hist'] = args.pack
smw_sub['Pack amount'] = args.packNum
elseif #args.pack > 0 then
smw_sub['Pack of'] = args.pack
smw_sub['Pack amount'] = args.packNum
end
mw.smw.subobject(smw_sub, args.smwname .. ' ' .. args.stock .. ' ' .. args.sell) -- add item subobject to page
mw.smw.set(smw) -- add data to page
end
return tostring(ret)
end
-- main function to generate the row
function p._arc(...)
local name,displayname,
stock,sell,buy,currency,
pack,packNum,
image,
valueInfo,gemw,alch,
tempArgs,
cleanedName,dropVers,smwname,historical,nosmw = unpack(...)
-- Stock display
local stockSort, stockDisp, stockTtl
local infStock = false
stock = string.lower(string.gsub(stock, ',', ''))
if stock == '∞' or stock == 'inf' or stock == 'infinito' then
stockSort = '10e99'
stockTtl = 'Infinito disponível'
stockDisp = '<span style="font-size:120%;">∞</span>'
infStock = true
elseif tonumber(stock) then
stockSort = stock
stockTtl = 'Estoque base de '..stock
stockDisp = commas(tonumber(stock))
else
stockSort = -1
stockTtl = 'Estoque inválido de '..stock..'foi fornecido'
stockDisp = '<span style="color:#FF0000; border-bottom:1px dashed; font-weight:bold;">Erro</span>'
end
-- Correct currencies
if not currency or currency == '' then
currency = 'moedas'
end
if not valueInfo.ge.curr or valueInfo.ge.curr == '' then
valueInfo.ge.curr = 'moedas'
end
-- Clean buy, sell values
buy = buysell(buy)
sell = buysell(sell)
-- Sell, buy Display
local sellDisp, sellSort, sellTtl, buyDisp, buySort, buyTtl
local sellNum, buyNum
local buy1Disp, buy1Sort, buy1Ttl, buy2Disp, buy2Sort, buy2Ttl
if tonumber(sell) and tonumber(sell) == 0 then
sellNum = 0
sellSort = sellNum
sellTtl = _priceStrings.sellF
sellDisp = 'Grátis'
elseif tonumber(sell) then
sellNum = tonumber(sell)
sellSort = sellNum
local sImg, sCur = currencyInfo(currency,sellNum)
sellTtl = mw.ustring.format(_priceStrings.sell,commas(sellNum),sCur)
sellDisp = commas(sellNum)..sImg
-- Buy price depends on sell price, having an additional buy parameter
-- is both pointless and makes buy prices inaccurate
buyNum = tonumber(sell)
buySort = math.floor(buyNum * 0.1)
buy1Sort = math.floor(buyNum * 0.11)
buy2Sort = math.floor(buyNum * 0.12)
local bImg, bCur = currencyInfo(currency,buySort)
buyTtl = mw.ustring.format(_priceStrings.buy,commas(buySort),bCur)
buy1Ttl = mw.ustring.format(_priceStrings.buy,commas(buy1Sort),bCur)
buy2Ttl = mw.ustring.format(_priceStrings.buy,commas(buy2Sort),bCur)
buyDisp = commas(buySort)..bImg
buy1Disp = commas(buy1Sort)..bImg
buy2Disp = commas(buy2Sort)..bImg
elseif sell == 'não' or sell == false then
sellSort = -1
sellTtl = 'Este objeto não é vendido por esta loja'
sellDisp = 'Não vendido'
else
sellSort = tonumber('10e99')
sellTtl = 'O preço de venda inserido é inválido ou nenhum foi fornecido.'
sellDisp = '<span style="color:#FF0000; border-bottom:1px dashed; font-weight:bold;">Erro</span>'
end
if tonumber(buy) and tonumber(buy) ~= 0 then
buyNum = tonumber(buy)
buySort = buyNum
buy1Sort = math.floor(buyNum * 1.1)
buy2Sort = math.floor(buyNum * 1.2)
local bImg, bCur = currencyInfo(currency,buyNum)
buyTtl = mw.ustring.format(_priceStrings.buy,commas(buyNum),bCur)
buy1Ttl = mw.ustring.format(_priceStrings.buy,commas(buy1Sort),bCur)
buy2Ttl = mw.ustring.format(_priceStrings.buy,commas(buy2Sort),bCur)
buyDisp = commas(buyNum)..bImg
buy1Disp = commas(buy1Sort)..bImg
buy2Disp = commas(buy2Sort)..bImg
elseif buy == 'não' or buy == false then
buySort = -1
buy1Sort, buy2Sort = buySort, buySort
buyTtl = 'Este objeto não pode ser vendido para esta loja'
buy1Ttl, buy2Ttl = buyTtl, buyTtl
buyDisp = 'Não comprado'
buy1Disp, buy2Disp = buyDisp, buyDisp
end
local ret = mw.html.create('tr')
-- inventory image
:tag('td')
:css('text-align','center')
:addClass('inventory-image')
:wikitext(image)
:done()
-- item name
:tag('td')
:css('text-align','left')
:addClass('item-col')
:wikitext(string.format('[[%s|%s]]%s',args.name,args.displayname,#args.namenotes > 3 and args.namenotes or ''))
:done()
-- stock
:tag('td')
:css('text-align','center')
:addClass('stock-col')
:attr({
['data-sort-value'] = stockSort,
['title'] = stockTtl
})
:wikitext(stockDisp)
:done()
-- sell price
:tag('td')
:css({
['text-align'] = 'right',
cursor = 'help'
})
:addClass('sell-col')
:attr({
['data-sort-value'] = sellSort,
['title'] = sellTtl
})
:wikitext(sellDisp)
:done()
-- buy price
:tag('td')
:css({
['text-align'] = 'right',
cursor = 'help'
})
:addClass('buy-col')
:attr({
['data-sort-value'] = buySort,
['title'] = buyTtl
})
:wikitext(buyDisp)
:done()
-- buy (upgrade 1) price
:tag('td')
:css({
['text-align'] = 'right',
cursor = 'help'
})
:addClass('buy1-col')
:attr({
['data-sort-value'] = buy1Sort,
['title'] = buy1Ttl
})
:wikitext(buy1Disp)
:done()
-- buy (upgrade 2) value
:tag('td')
:css({
['text-align'] = 'right',
cursor = 'help'
})
:addClass('buy2-col')
:attr({
['data-sort-value'] = buy2Sort,
['title'] = buy2Ttl
})
:wikitext(buy2Disp)
:done()
--Add class if line but not table is historical
if historical and not yesno(tempargs.Historical,false) then
ret:addClass('storeline-hist')
end
-- SMW
if ns == '' and not nosmw then
local smw = {}
local smw_sub = {}
local source = pgTitle
--add function to reduce image to File:Some name.png
if historical then
smw['Sells item hist'] = name
smw_sub = {['Sold by hist'] = source, ['Sold item image'] = mw.text.encode(image), ['Sold item hist'] = name, ['Sold item text']=displayname, ['Store stock']=tonumber(stock) or tonumber("10e99"), ['Store sell price']=sell, ['Store buy price']=buy, ['Store currency']=currency}
else
smw['Sells item'] = name
smw_sub = {['Sold by'] = source, ['Sold item image'] = mw.text.encode(image), ['Sold item'] = name, ['Sold item text']=displayname, ['Store stock']=tonumber(stock) or tonumber("10e99"), ['Store sell price']=sell, ['Store buy price']=buy, ['Store currency']=currency}
end
if infStock then
smw_sub['Store stock infinite'] = true
smw_sub['Store stock'] = nil
end
if #pack > 0 and historical then
smw_sub['Pack of hist'] = pack
smw_sub['Pack amount'] = packNum
elseif #pack > 0 then
smw_sub['Pack of'] = pack
smw_sub['Pack amount'] = packNum
end
mw.smw.subobject(smw_sub, smwname .. ' ' .. stock .. ' ' .. sell) -- add item subobject to page
mw.smw.set(smw) -- add data to page
end
return tostring(ret)
end
return p
-- </nowiki>