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.


Halo Esports Wiki

Documentation for this module may be created at Module:PlayerTeamHistoryCompact/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_math = require("Module:MathUtil")
local util_news = require("Module:NewsUtil")
local util_source = require("Module:SourceUtil")
local util_table = require("Module:TableUtil")
local util_text = require("Module:TextUtil")
local util_time = require("Module:TimeUtil")
local util_timedelta = require("Module:TimedeltaUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require('Module:i18nUtil')
local lang = mw.getLanguage('en')

local m_team = require('Module:Team')
local m_region = require('Module:Region')

local PTH = require('Module:PlayerTeamHistoryEmbeddedAbstract'):extends()

PTH.CargoStoreTableName = 'TenuresUnbroken'

local h = {}

local p = {}
function p.main(frame)
	local args = util_args.merge()
	return p._main(args)

function p._main(args)
	return PTH('PlayerTeamHistory'):run(args)

function PTH:init(name)
	self:super('init', name)
			-- insignificant team changes
			-- not sure why this next one was ignored...?
			-- 'loan_end_and_join',

	-- because we want to know current status on teams, we need to
	-- retrieve information about players' statuses/roles/etc changing
	-- this is effectively additional ancillary data
	-- otherwise we'd just ignore completely, as opposed to ignoring only the leave parts
		self.PRELOADS_TO_IGNORE.leave, {
			-- role changes
			-- modifier changes
			-- insignificant team changes

function PTH:getKey(row)
	return row.TeamPage or row.Team

function PTH:doWeNeedANewLine(changesByLine, row, index)
	if not index then return true end
	if not row.TeamLeave then
		-- if this is a join, we want to make a new row iff we have a leave
		-- in the most recent row in the index
		local currentLineNumber = self:getMostRecentLineNumberFromIndex(index)
		return changesByLine[currentLineNumber].TeamLeave
	return not index

function PTH:addNewTeamToExistingLine(line, row)
	-- in the "normal" version, it's not possible to need to do this because
	-- the key encodes role and role modifier. but in this version we don't record that
	-- so here we'll make sure that the key information is all accurate for current
	-- this part is only needed for lines that the player is currently on but
	-- since we have no way to determine which lines those are until we're done,
	-- we'll just do it for everything
	-- team is needed here because TeamPage might group different teams together
	if line.TeamLeave then return end
	util_table.push(line.RosterChangeIds, row.RosterChangeId)
	-- remember this so we don't have to modify row at all during this operation
	-- since we'll overwrite the copy in line if we do the merge
	local rosterChangeIds = line.RosterChangeIds
	if row.TeamLeave then
		util_table.merge(line, row)
		line.RosterChangeIds = rosterChangeIds
	for _, v in ipairs({ 'Role', 'RoleArgs', 'Status', 'Team', 'RoleModifier', 'Roles', 'RolesIngame', 'RolesStaff' }) do
		line[v .. 'Join'] = row[v .. 'Join']

return p