Skip to main content

Overview

The Player class represents a single player in a match, tracking their identity, agent selection, in-game stats, equipment, and state across rounds.

Player Class

export class Player {
  // Identity
  private name: string;
  private tagline: string;
  private riotId: string;
  private searchName: string;  // "Name #TAG"
  private fullName: string;    // "Name#TAG"
  private position: number;
  
  // Agent
  private agentInternal: string = "";
  private agentProper: string = "";
  private locked: boolean = false;
  
  // State
  private isAlive: boolean = true;
  private hasSpike: boolean = false;
  private isObserved: boolean = false;
  private health: number = 100;
  
  // Stats
  private kills: number = 0;
  private deaths: number = 0;
  private assists: number = 0;
  private kdRatio: number = 0;
  private killsThisRound: number = 0;
  private deathsThisRound: number = 0;
  
  // Ultimate
  private currUltPoints: number = 0;
  private maxUltPoints: number = 0;
  private ultReady: boolean = false;
  
  // Economy
  private money: number = 0;
  private moneySpent: number = 0;
  private spentMoneyThisRound: boolean = false;
  
  // Equipment
  private armorName: string;
  private highestWeapon: string;
  
  // Abilities (from auxiliary data)
  private abilities: AvailableAbilities;
  
  // Advanced Stats
  private teamKills: number = 0;
  private headshotKills: number = 0;
  private headshotRatio: number = 0;
  private killedPlayerNames: string[] = [];
  private killsByWeaponsAndAbilities: Record<string, number> = {};
  private killsOnEnemyPlayer: Record<string, number> = {};
  private killsOnTeammatePlayer: Record<string, number> = {};
  
  // Data Availability
  private scoreboardAvailable: boolean = false;
  private auxiliaryAvailable: AvailableAuxiliary;
  private iconNameSuffix: string = "";
}

Properties

Identity

name
string
Player’s in-game display name (without tagline).
tagline
string
Riot ID tagline (the part after #).
riotId
string
Unique player identifier (PUUID).
position
number
Player’s position in the team roster (0-4).

Agent

agentInternal
string
Internal agent identifier from game data (e.g., “Clay_PC_C”).
agentProper
string
Human-readable agent name (e.g., “Raze”).
locked
boolean
Whether the agent selection is locked.

Combat Stats

kills
number
default:"0"
Total kills in the match.
deaths
number
default:"0"
Total deaths in the match.
assists
number
default:"0"
Total assists in the match.
kdRatio
number
default:"0"
Calculated kill/death ratio (kills ÷ deaths).
killsThisRound
number
default:"0"
Kills in the current round (resets each round).
deathsThisRound
number
default:"0"
Deaths in the current round (resets each round).

State

isAlive
boolean
default:"true"
Whether the player is currently alive.
hasSpike
boolean
default:"false"
Whether the player is carrying the spike.
isObserved
boolean
default:"false"
Whether the observer camera is currently viewing this player.
health
number
default:"100"
Current health points (0-100). Only available with auxiliary client.

Ultimate

currUltPoints
number
default:"0"
Current ultimate points.
maxUltPoints
number
default:"0"
Maximum ultimate points required for this agent.
ultReady
boolean
default:"false"
Whether ultimate ability is ready to use (currUltPoints >= maxUltPoints).

Economy

money
number
default:"0"
Current credits.
moneySpent
number
default:"0"
Credits spent in the current round.

Equipment

armorName
string
Current armor type.
highestWeapon
string
Best weapon the player is currently holding (translated name).

Advanced Stats

headshotKills
number
default:"0"
Number of kills that were headshots.
headshotRatio
number
default:"0"
Percentage of kills that were headshots (headshotKills ÷ kills).
teamKills
number
default:"0"
Number of friendly fire kills.
killedPlayerNames
string[]
List of player names killed this round.
killsByWeaponsAndAbilities
Record<string, number>
Map of weapon/ability internal names to kill counts.

Constructor

constructor(data: IFormattedRoster)
Creates a new player from roster data.
data
IFormattedRoster
required
Initial roster information containing:
  • name: Player name
  • tagline: Riot ID tag
  • playerId: PUUID
  • agentInternal: Selected agent
  • position: Roster position
  • locked: Lock state

Core Methods

updateFromScoreboard

public updateFromScoreboard(data: IFormattedScoreboard): void
Updates player state from observer scoreboard data. This is the primary data source.
data
IFormattedScoreboard
required

updateFromAuxiliaryScoreboard

public updateFromAuxiliaryScoreboard(data: IFormattedScoreboard | IFormattedAuxScoreboardTeam): void
Fallback scoreboard update from auxiliary client. Only used if observer scoreboard is unavailable.

extractKillfeedInfo

public extractKillfeedInfo(data: IFormattedKillfeed): void
Processes killfeed events to extract detailed stats:
  • Weapon/ability kill tracking
  • Headshot detection
  • Teamkill recording
  • Victim tracking

updateAbilities

public updateAbilities(data: AvailableAbilities): void
Updates ability charges from auxiliary client.
data
AvailableAbilities
required
{
  grenade: number;   // Q ability charges
  ability1: number;  // E ability charges
  ability2: number;  // C ability charges
}

setHealth

public setHealth(health: number): void
Updates health from auxiliary client (0-100).

resetRoundSpecificValues

public resetRoundSpecificValues(isSideSwitch: boolean): void
Resets per-round stats at the start of each round:
  • Clears killsThisRound and deathsThisRound
  • Resets money spent tracking
  • Clears killed player names
  • Resets state flags
  • Sets money to 800 on side switches

Getters

public getName(): string
public getSearchName(): string  // "Name #TAG"
public getPlayerId(): string
public getAgentInternal(): string
public checkIsAlive(): boolean
public getMoney(): number
public getMoneySpent(): number
public getKillsThisRound(): number
public getDeathsThisRound(): number

Helper Classes

AvailableAbilities

export class AvailableAbilities {
  grenade: number = 0;   // Q ability
  ability1: number = 0;  // E ability
  ability2: number = 0;  // C ability
}

AvailableAuxiliary

export class AvailableAuxiliary {
  health: boolean = false;
  abilities: boolean = false;
  scoreboard: boolean = false;
}
Tracks which auxiliary data sources are connected for this player.

Agent-Specific Behavior

Example Usage

// Player is created from roster data
const rosterData: IFormattedRoster = {
  name: "PlayerOne",
  tagline: "NA1",
  playerId: "player-uuid-123",
  startTeam: 0,
  agentInternal: "Clay_PC_C",
  position: 0,
  locked: true,
  rank: 24
};

const player = new Player(rosterData);

// Update from scoreboard
player.updateFromScoreboard({
  name: "PlayerOne",
  tagline: "NA1",
  playerId: "player-uuid-123",
  startTeam: 0,
  agentInternal: "Clay_PC_C",
  isAlive: true,
  initialArmor: 2,
  scoreboardWeaponInternal: "vandal",
  currUltPoints: 6,
  maxUltPoints: 7,
  hasSpike: false,
  money: 3400,
  kills: 12,
  deaths: 8,
  assists: 5
});

// Process kill
player.extractKillfeedInfo({
  attacker: "PlayerOne",
  victim: "Enemy1",
  weaponKillfeedInternal: "vandal",
  headshotKill: true,
  assists: ["Teammate1"],
  isTeamkill: false
});

// Update abilities from aux client
player.updateAbilities({
  grenade: 1,
  ability1: 2,
  ability2: 1
});

console.log(player.getName()); // "PlayerOne"
console.log(player.getKillsThisRound()); // 1

Build docs developers (and LLMs) love