Módulo:Tabela de coleções
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:Tabela de coleções/doc. [editar]
Módulo:Tabela de coleções's a função main é invocada por Predefinição:Tabela de coleções.
Módulo:Tabela de coleções requer Módulo:Addcommas.
Módulo:Tabela de coleções requer Módulo:Currency short.
Módulo:Tabela de coleções requer Módulo:ExchangeLite.
Módulo:Tabela de coleções requer Módulo:Skill clickpic.
-- <nowiki>
local Skillpic = require('Módulo:Skill clickpic')
local commas = require('Módulo:Addcommas')._add
local exchange = require('Módulo:ExchangeLite')
local currency = require('Módulo:Currency short')._amount
local p = {}
function p.main(frame)
local args = frame:getParent().args
return p._main(args)
end
function p._main(args)
local ret = mw.html.create('table')
ret:addClass('wikitable sticky-header lighttable')
:tag('tr')
:tag('th'):wikitext('Artefato'):done()
:tag('th'):wikitext(Skillpic._main("Arqueologia") .. " Nível"):done()
:tag('th'):wikitext(Skillpic._main("Arqueologia") .. " EXP"):done()
:tag('th'):wikitext('Cronotas'):done()
:tag('th'):wikitext('Obtenção'):done()
:tag('th'):wikitext('Materiais'):done()
:tag('th'):wikitext('Custo de materiais'):done()
:done()
local totmats = {}
local totchro = 0
local totxp = 0
local tot_price = 0
local collectioncompletionchronotesbonus = args.collectioncompletionchronotesbonus or args.collectionCompletionChronotesBonus or 0
for _,i in ipairs(args) do
i = mw.text.trim(i)
local query = {
'[['..i..']]',
'?=#',
'?Cronotas',
'?Production JSON',
limit = 1,
}
local smwdata = mw.smw.ask(query)
if not smwdata then
return string.format('Falha ao encontrar %s - certifique-se de que o nome do objeto está escrito corretamente.', i)
end
local chronotes = smwdata[1]['Cronotas'] or '?'
if tonumber(chronotes, 10) then
totchro = totchro + tonumber(chronotes, 10)
end
local matsjson = smwdata[1]['Production JSON']
if type(matsjson) == 'string' then
matsjson = { matsjson }
end
local mats = {}
local level = "?"
local _xp = "?"
local price = 0
if matsjson then
for _,mat_json in ipairs(matsjson) do
local json_good, mats_t = pcall(mw.text.jsonDecode, mw.text.decode(mat_json))
if json_good then
if mats_t.level then
level = mats_t.level
end
if mats_t.exp and tonumber( mats_t.exp ) then
_xp = tonumber(mats_t.exp)
totxp = totxp + _xp
end
for _, mat_info in ipairs(mats_t.mats) do
local qty = string.gsub(mat_info.quantity, '%-', '–')
qty = tonumber(qty, 10) or 1
local matnm = mat_info.name
if totmats[matnm] then
totmats[matnm] = totmats[matnm] + qty
elseif not string.find(matnm, 'danificad') then
totmats[matnm] = qty
end
-- Skip if it's the damaged one
if not string.find(matnm, i, nil, true) then
-- Try using production data (in case added in the future)
local mat_price = mat_info.price
if not (mat_info.price and tonumber( mat_info.price )) then
local noErr, p = pcall(exchange.price, matnm)
if noErr then
mat_price = p
else
mat_price = 0
end
end
if not (mat_price) then
mat_price = 0
end
price = price + (mat_price * qty)
end
table.insert(mats, string.format('%s × [[Arquivo:%s.png|link=%s]] [[%s]]', qty,matnm,matnm,matnm) )
end
tot_price = tot_price + price
end
end
else
table.insert(mats, 'N/A')
end
local dmgname = i
--if string.find(dmgname, '%)$') then
-- dmgname = dmgname..'(danificado)'
--else
-- dmgname = dmgname..' (danificado)'
--end
function try_to_query2(dmgname)
local query2 = {
'[[Objeto largado::'..dmgname..']]',
'?Escavado de#-',
'?Recompensa de#-',
'?Escavado de.Sítio de escavação=Sítio de escavação',
limit = 5,
}
return query2
end
function return_dmgname(dmgname)
if mw.smw.ask(try_to_query2(dmgname..' (danificado)')) then
dmgname2 = dmgname..' (danificado)'
elseif mw.smw.ask(try_to_query2(dmgname..' (danificados)')) then
dmgname2 = dmgname..' (danificados)'
elseif mw.smw.ask(try_to_query2(dmgname..' (danificada)')) then
dmgname2 = dmgname..' (danificada)'
elseif mw.smw.ask(try_to_query2(dmgname..' (danificadas)')) then
dmgname2 = dmgname..' (danificadas)'
else
dmgname2 = dmgname
end
return dmgname2
end
local smwdata2 = mw.smw.ask(try_to_query2(return_dmgname(dmgname)))
local sources = {}
if not smwdata2 then
table.insert(sources, 'Desconhecido')
else
for _,v in pairs(smwdata2) do
if v['Escavado de'] then
if v['Dig site'] then
table.insert(sources, '[['..v['Escavado de']..']] ('..v['Sítio de escavação']..')')
else
table.insert(sources, '[['..v['Escavado de']..']]')
end
elseif v['Recompensa de'] then
table.insert(sources, '[['..v['Recompensa de']..']]')
end
end
end
-- if price == 0 then
-- price = '?'
-- else
-- price = commas(price)
-- end
ret:tag('tr')
:tag('td'):wikitext( string.format('[[Arquivo:%s.png|link=%s]] [[%s]]', i,i,i) ):done()
:tag('td'):wikitext( level ):done()
:tag('td'):attr('data-sort-value', _xp):wikitext( commas(_xp) ):done()
:tag('td'):attr('data-sort-value', chronotes):wikitext( commas(chronotes) ):done()
:tag('td'):wikitext( table.concat(sources, '<br>') ):done()
:tag('td'):wikitext( table.concat(mats, '<br>') ):done()
:tag('td'):attr('data-sort-value', price):wikitext( currency(price, 'moedas', true) ):done()
:done()
end
local mats = {}
for m,n in pairs(totmats) do
table.insert(mats, string.format('%s × [[Arquivo:%s.png|link=%s]] [[%s]]', n,m,m,m) )
end
local chronotes_price = 0
local noErrChronotes, chronotesp = pcall(exchange.price, 'Cronotas')
if noErrChronotes then
chronotes_price = chronotesp
else
chronotes_price = 0
end
local total_chronotes_price = chronotes_price * (totchro + collectioncompletionchronotesbonus)
ret:tag('tr'):addClass('nohighlight')
:tag('th'):attr("colspan", "2"):wikitext('Totais (EXP e cronotas):'):css('font-weight', 'bold'):done()
:tag('td'):attr('data-sort-value', totxp):wikitext( commas(totxp) ):done()
:tag('td'):attr('data-sort-value', totchro):wikitext( commas(totchro)..' + '..commas(collectioncompletionchronotesbonus)..'<br><span class="nowrap">'..currency(total_chronotes_price, 'coins', true)..'</span>' ):done()
:tag('th'):wikitext('Total de materiais:'):css('font-weight', 'bold'):done()
:tag('td'):wikitext( table.concat(mats, '<br>') ):done()
:tag('td'):attr('data-sort-value', tot_price):wikitext( currency(tot_price, 'moedas', true) ):done()
:done()
return tostring(ret)
end
return p
-- </nowiki>