Overview
The Team class represents one of the two teams in a match, managing its roster of players, score tracking, timeout state, and round-by-round history.
Team Class
export class Team {
// Identity
public teamName: string;
public teamTricode: string;
public teamUrl: string = "";
// Game State
public ingameTeamId: number = 0; // 0 or 1
public isAttacking: boolean = false;
public roundsWon: number = 0;
// Players
private players: Player[] = [];
private playerCount: number = 0;
private hasDuplicateAgents: boolean = false;
// Economy
private spentThisRound: number = 0;
// Round History
private roundRecord: RecordEntry[] = [];
// Configuration
private removeTricode: boolean = false;
private hasHandledTeam: boolean = false;
}
Properties
Identity
Full team name (e.g., “Sentinels”).
3-letter team code (e.g., “SEN”).
Game State
In-game team identifier.
0: Attacking team at match start
1: Defending team at match start
Switches sides at round 13 and every 2 rounds in overtime.
Whether the team is currently on the attacking side.
Total rounds won in the match.
Players
Array of up to 5 players on the team.
Number of players currently in the roster (0-5).
Whether any two players have selected the same agent (affects assist tracking).
Economy
Total credits spent by all team members in the current round.
Round History
Array of round results and win conditions.Pre-initialized with 26 “upcoming” entries.
Constructor
constructor(team: AuthTeam, removeTricode: boolean)
Team configuration from authentication data:{
name: string; // Team name
tricode: string; // 3-letter code
url: string; // Logo URL
attackStart: boolean; // Starting side
}
Whether to strip the tricode prefix from player names (from playercams settings).
Core Methods
receiveTeamSpecificData
public receiveTeamSpecificData(data: IAuthedData | IAuthedAuxData | IFormattedAuxiliary): void
Routes incoming event data to the appropriate handler and updates team/player state.
data
IAuthedData | IAuthedAuxData | IFormattedAuxiliary
required
ROSTER: Player roster updates → processRosterData()
SCOREBOARD: Observer scoreboard → processScoreboardData()
KILLFEED: Kill events → processKillfeedData()
AUX_SCOREBOARD: Auxiliary scoreboard → processAuxScoreboardData()
AUX_ABILITIES: Ability charges → processAuxAbilityData()
AUX_HEALTH: Player health → processAuxHealthData()
AUX_ASTRA_TARGETING: Astra cosmic form → processAuxAstraTargeting()
AUX_CYPHER_CAM: Cypher camera → processAuxCypherCam()
receiveAuxScoreboardTeamData
public receiveAuxScoreboardTeamData(scoreboards: IFormattedAuxScoreboardTeam[]): void
Batch processes scoreboard data for all team members from auxiliary client.
switchSides
public switchSides(): void
Toggles the isAttacking flag. Called at half (round 13) and every 2 rounds in overtime.
resetRoundSpecificValues
public resetRoundSpecificValues(isSideSwitch: boolean): void
Resets round-specific data for all players at the start of each round.
If true, resets player money to 800 (pistol round economy).
addRoundReason
public addRoundReason(reason: RecordType, roundNumber: number): void
Records the outcome of a round in the team’s history.
"detonated": Won by spike detonation
"defused": Won by spike defusal
"kills": Won by eliminations
"timeout": Won because attackers ran out of time
"lost": Lost the round
"upcoming": Round hasn’t been played yet
The round number (1-indexed).
Player Queries
public hasTeamMemberByName(playerName: string): boolean
public hasTeamMemberBySearchName(playerSearchName: string): boolean
public hasTeamMemberById(playerId: string): boolean
public getPlayerCount(): number
public getFirstPlayerId(): string
public alivePlayers(): number
public getMoneyFor(playerId: string): number
setObservedPlayer
public setObservedPlayer(observedName: string): void
Updates all players’ isObserved flag based on the camera target.
findDuplicateAgents
public findDuplicateAgents(): void
Checks if any two players have the same agent selected. Sets hasDuplicateAgents flag, which affects assist attribution logic.
getSpentThisRound
public getSpentThisRound(): number
Calculates total money spent by all players in the current round.
setAuxDisconnected
public setAuxDisconnected(playerId: string): void
Marks a specific player’s auxiliary data as disconnected.
Supporting Types
RecordEntry
export interface RecordEntry {
type: RecordType;
wasAttack: boolean;
round: number;
}
The outcome type (see addRoundReason above).
Whether the team was attacking when this round was played.
RecordType
type RecordType = "detonated" | "defused" | "kills" | "timeout" | "lost" | "upcoming";
Example Usage
// Team is created during match initialization
const teamConfig: AuthTeam = {
name: "Sentinels",
tricode: "SEN",
url: "https://example.com/sentinels-logo.png",
attackStart: true
};
const team = new Team(teamConfig, false);
// Process roster data
team.receiveTeamSpecificData({
obsName: "Observer1",
groupCode: "ABC123",
type: DataTypes.ROSTER,
timestamp: Date.now(),
data: {
name: "TenZ",
tagline: "SEN",
playerId: "player-uuid-1",
startTeam: 0,
agentInternal: "Jett_PC_C",
position: 0,
locked: true,
rank: 28
}
});
// Update scoreboard
team.receiveTeamSpecificData({
obsName: "Observer1",
groupCode: "ABC123",
type: DataTypes.SCOREBOARD,
timestamp: Date.now(),
data: {
name: "TenZ",
tagline: "SEN",
playerId: "player-uuid-1",
startTeam: 0,
agentInternal: "Jett_PC_C",
isAlive: true,
initialArmor: 2,
scoreboardWeaponInternal: "operator",
currUltPoints: 7,
maxUltPoints: 7,
hasSpike: false,
money: 2700,
kills: 15,
deaths: 10,
assists: 3
}
});
// Record round outcome
team.addRoundReason("kills", 1);
// Switch sides at half
team.switchSides();
console.log(team.isAttacking); // false (was true)
console.log(team.getPlayerCount()); // 1
console.log(team.alivePlayers()); // 1
console.log(team.getSpentThisRound()); // Credits spent by all players
Roster Management
Show Player Addition Logic
When ROSTER data is received:
- Check if player already exists (by
playerId)
- If exists, update their data via
player.onRosterUpdate()
- If new and team has < 5 players:
- Create new
Player instance
- Optionally remove tricode from name
- Add to roster
- Increment
playerCount
- If team is full (5 players), log error
When processing killfeed events:
- Find attacker by name → extract detailed stats
- Find victim by name → mark as killed
- If no duplicate agents, attribute assists by agent match
- Falls back to estimating stats if scoreboard unavailable
Money spent is calculated by:
- Detecting first purchase (money decreases)
- Tracking subsequent money changes during buy phase
- Summing across all players for team total
- Resetting at start of next round