Módulo:Porter calc
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:Porter calc/doc. [editar]
Módulo:Porter calc's a função main é invocada por Predefinição:Calculadora sinal do transportador.
Módulo:Porter calc requer Módulo:Mercado.
Módulo:Porter calc requer Módulo:Moedas.
Módulo:Porter calc requer Módulo:Porter items/data.
-- <nowiki>
local p = {}
-- mw.loadData would be better but it can't handle it (#data.items[1] == 0 with mw.loadData)
local data = require('Módulo:Porter_items/data')
local gep = require('Módulo:Mercado')._price
local coins = require('Módulo:Moedas')._amount
function p.main(frame)
local info = {
{'I', 30, 'pálida', 'safira', 5},
{'II', 35, 'resplandecente', 'safira', 10},
{'III', 40, 'faiscante', 'esmeralda', 15},
{'IV', 45, 'lampejante', 'esmeralda', 20},
{'V', 60, 'radiante', 'rubi', 25},
{'VI', 80, 'luminosa', 'diamante', 30},
{'VII',120, 'incandescente', 'dragolito', 50},
}
local function get_price(name)
local _, n = pcall(gep,name)
return n
end
local cost = {}
for i, v in ipairs(info) do
local c = (v[2] * get_price('Energia ' .. v[3]) + get_price('Colar de ' .. v[4])) / v[5]
table.insert(cost, c)
end
local function sign_name(n)
return 'Sinal do transportador ' .. info[n][1]
end
local function link(title, text)
local s = '[[' .. title
if text then
s = s .. '|' .. text
end
return s .. ']]'
end
local function get_profit(item, i)
local p = get_price(item)
if type(p) ~= 'number' then
return 'Não negociável'
else
local profit = p - cost[i]
return coins(profit)
end
end
local container = mw.html.create('div')
local cols = #info + 1
for i, category in ipairs(data.categories) do
local t = container:tag('table'):addClass('wikitable mw-collapsible mw-collapsed')
t:tag('tr'):tag('th'):attr('colspan', cols):wikitext(category == 'Outro' and category or link(category))
local header = t:tag('tr')
for j=0, #info do
local text
if j == 0 then
text = 'Objeto'
else
text = link(sign_name(j), info[j][1])
end
header:tag('th'):wikitext(text)
end
for _, item in ipairs(data.items[i]) do
local row = t:tag('tr')
:tag('td')
:wikitext('[[Arquivo:'..item..'.png|link='..item..
']][['..item..']]')
:done()
for j, v in ipairs(info) do
row:tag('td'):wikitext(get_profit(item, j))
end
end
end
return container
end
return p