Module:PlayerTeamHistoryCompact

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 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) end

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

function PTH:init(name) self:super('init', name) util_table.mergeArrays(		self.PRELOADS_TO_IGNORE,		{			-- insignificant team changes			'to_main_also_stay',			'loan_return',			'loaned_to',			-- 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 util_table.mergeArrays(		self.PRELOADS_TO_IGNORE.leave, {			-- role changes			'confirm_role_swap',			'gcd_to_sub',			'role_swap',			-- modifier changes			'sub_to_trainee',			'to_active',			'to_inactive',			'to_starting',			'to_sub',			'to_trainee',			-- insignificant team changes			'team_rename_same_page',		}	) end

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

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 end return not index end

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 return end for _, v in ipairs({ 'Role', 'RoleArgs', 'Status', 'Team', 'RoleModifier', 'Roles', 'RolesIngame', 'RolesStaff' }) do line[v .. 'Join'] = row[v .. 'Join'] end end

return p