No overview comment at the top of the file.
- Imports
- Seasons
- Used by
- 2 loaders1 route
Types
interfaceSetScore
no JSDoc:16 export interface SetScore {
ownScore: number;
opponentScore: number;
}Only used inside the module
interfaceTournamentRun
no JSDoc:148 export interface TournamentRun {
/** 1 = X (best) … 9 = C. Null (no calculated tier) ranks below every tiered tournament. */
tier: number | null;
placement: number;
teamsCount: number;
/** Average end of season SP of the top 8 placers; null when none had a calculated skill. */
topEightAvgSp: number | null;
}Only used inside the module
Functions & values
functionlongestWinStreak
:22 Longest run of consecutive set wins; sets must be in chronological order.
export function longestWinStreak(sets: SetScore[]): number
Unit tests (4)
Win record in sets decided by one map (4-3 in SendouQ, 2-1/3-2 in tournaments).
export function clutchRecord(sets: SetScore[]): { won: number; total: number }Unit tests (2)
Best winrate stage across modes; stages under the maps-played threshold are excluded so a lucky 2-0 can't win.
export function bestStage(
stages: Partial<
Record<
StageId,
Partial<Record<ModeShort, { wins: number; losses: number }>>
>
>,
): { stageId: StageId; winratePercentage: number } | undefinedUnit tests (4)
functionmostPlayedStage
:83 Stage with the most maps played across modes, higher winrate breaking ties; undefined when no maps were played.
export function mostPlayedStage(
stages: Partial<
Record<
StageId,
Partial<Record<ModeShort, { wins: number; losses: number }>>
>
>,
): { stageId: StageId; winratePercentage: number } | undefinedUnit tests (3)
Mode with the most maps played across stages, with its share of all maps played; null when no maps were played.
export function topModeUsage(
stages: Partial<
Record<
StageId,
Partial<Record<ModeShort, { wins: number; losses: number }>>
>
>,
): { mode: ModeShort; usagePercentage: number } | nullUnit tests (2)
functionbestTournamentRun
:169 The best tournament run by {@link tournamentRunScore}.
export function bestTournamentRun<T extends TournamentRun>(
runs: T[],
): T | undefined
Unit tests (3)
functiontopWeaponUsages
:176 Most used weapons with their share of all reported weapon occurrences, most used first.
export function topWeaponUsages(
reportedWeapons: Array<{ weaponSplId: MainWeaponId; count: number }>,
): Array<{ weaponSplId: MainWeaponId; usagePercentage: number }>Unit tests (2)
functionisSeasonFinished
:192 Whether the season has ended.
export function isSeasonFinished(season: number, date = new Date())
functioncanExportSeasonSummary
:207 Only the profile owner can export, with a non-approximate skill for a finished season. Supporters can export any finished season, others only per {@link isSeasonExportableByAll}.
export function canExportSeasonSummary({
loggedInUser,
profileUserId,
season,
seasonsParticipatedIn,
hasCalculatedSkill,
date = new Date(),
}: {
loggedInUser?: { id: number; roles: Role[] };
profileUserId: number;
season: number;
seasonsParticipatedIn: number[];
hasCalculatedSkill: boolean;
date?: Date;
}): booleanUnit tests (9)
Unit tests not about one export (8)
Not shown, only used by tests: tournamentRunScore, isSeasonExportableByAll