Halo Esports Wiki

We are currently performing extensive maintenance to this wiki and as a result there will likely be errors. Please be patient while we work to fix all problems.

READ MORE

Halo Esports Wiki
Advertisement

Documentation for this module may be created at Module:PlayerResultsAbstract/doc

local util_args = require('Module:ArgsUtil')
local util_cargo = require('Module:CargoUtil')
local util_esports = require('Module:EsportsUtil')
local util_html = require('Module:HtmlUtil')
local util_map = require('Module:MapUtil')
local util_table = require('Module:TableUtil')
local util_text = require('Module:TextUtil')
local util_toggle = require('Module:ToggleUtil')
local util_tournament = require('Module:TournamentUtil')
local util_vars = require('Module:VarsUtil')
local i18n = require('Module:i18nUtil')
local m_team = require('Module:Team')
local lang = mw.getLanguage('en')

local Results = require('Module:TournamentResultsQueryAbstract'):extends()

function Results:finalizeTable(tbl, result, subject)
	local td = tbl:tag("tr")
		:tag("th"):attr("colspan",#self.COLUMNS)
		:wikitext(i18n.print('totalPrize'))
		:wikitext(self:getTotalEarnings(result))
end

function Results:getTotalEarnings(result)
	local earnings = {}
	for _, row in ipairs(result) do
		if row.PrizeUnit then
			util_vars.log(row.Prize)
			earnings[row.PrizeUnit] = (earnings[row.PrizeUnit] or 0) + (tonumber(row.Prize,10) or 0)
		end
	end
	local earningstable = {}
	
	for currency, amount in pairs(earnings) do
		earningstable[#earningstable+1] = currency .. " " .. lang:formatNum(amount)
	end
	return util_table.concat(earningstable," • ")
end

return Results
Advertisement