Module:Raffle table
Jump to navigation
Jump to search
Module documentation
This documentation is transcluded from Module:Raffle table/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:Raffle table/doc. [edit]
Module:Raffle table requires Module:Addcommas.
Module:Raffle table requires Module:Coins.
Module:Raffle table requires Module:Exchange.
| Function list |
|---|
| L 8 — p.main L 57 — plinkp |
-- <pre>
local p = {}
local coins = require('Module:Coins')._amount
local gep = require('Module:Exchange')._price
local commas = require('Module:Addcommas')._add
function p.main(frame)
local args = frame:getParent().args
local items = {}
for _, v in ipairs(args) do
local amt, itm = string.match(mw.text.trim(v),'%s*(%d+)%s*%*%s*(.*)')
table.insert(items,{ n = itm, x = amt })
end
local ret = mw.html.create('table')
:addClass('wikitable')
:addClass('sortable')
:addClass('mw-collapsible')
:css('text-align','right')
:tag('caption')
:wikitext('Raffle prize pool')
:done()
:tag('tr')
:tag('th')
:addClass('unsortable')
:wikitext('Prize')
:done()
:tag('th')
:wikitext('GE value')
:done()
:done()
local total_value = 0
for _, v in ipairs(items) do
local item_ge
if string.lower(v.n) == 'coins' then
item_ge = 1
else
item_ge = gep(v.n)
end
ret:tag('tr')
:tag('td')
:wikitext(commas(v.x) .. ' × ' .. plinkp(v.n))
:done()
:tag('td')
:wikitext(coins(item_ge * v.x))
:done()
:done()
total_value = total_value + item_ge * v.x
end
ret:tag('b')
:wikitext('Total value: ' .. coins(total_value))
:done()
return ret
end
function plinkp(item)
local item_img
if string.lower(item) == 'coins' then
item_img = 'Coins 1000'
else
item_img = item
end
return string.format('[[File:%s.png|link=%s]]',item_img,item)
end
return p
