165 lines
3.8 KiB
TypeScript
165 lines
3.8 KiB
TypeScript
import type { CompetitionFormat } from "./format.js";
|
|
import type { CompetitionGameView, GameSlotView } from "./game.js";
|
|
import type {
|
|
CommunityId,
|
|
CompetitionId,
|
|
MatchId,
|
|
SeriesId,
|
|
TeamId,
|
|
UserId,
|
|
} from "./ids.js";
|
|
import type {
|
|
IsoDateTime,
|
|
SeriesDefinition,
|
|
SeriesProjection,
|
|
SeriesSlot,
|
|
SeriesStageType,
|
|
} from "./series.js";
|
|
|
|
export type CompetitionPhase =
|
|
| "ready"
|
|
| "running"
|
|
| "completed"
|
|
| "cancelled";
|
|
export type PlayerPosition = "TOP" | "JGL" | "MID" | "ADC" | "SUP";
|
|
|
|
export interface CompetitionTeamMemberView {
|
|
userId: UserId;
|
|
displayName: string;
|
|
gameName?: string;
|
|
tagLine?: string;
|
|
profileIconId?: number;
|
|
assignedPosition?: PlayerPosition;
|
|
cost?: number;
|
|
}
|
|
|
|
export interface CompetitionTeamView {
|
|
teamId: TeamId;
|
|
displayOrder: number;
|
|
name: string;
|
|
captainUserId?: UserId;
|
|
members: CompetitionTeamMemberView[];
|
|
}
|
|
|
|
export interface RoundRobinStandingView {
|
|
rank: number;
|
|
teamId: TeamId;
|
|
seriesPlayed: number;
|
|
seriesWins: number;
|
|
seriesLosses: number;
|
|
seriesDraws: number;
|
|
gameWins: number;
|
|
gameLosses: number;
|
|
gameDiff: number;
|
|
}
|
|
|
|
export interface CompetitionPlacementView {
|
|
rank: number;
|
|
teamId: TeamId;
|
|
}
|
|
|
|
export type CompetitionOutcome =
|
|
| {
|
|
type: "paired-series";
|
|
completedSeriesIds: SeriesId[];
|
|
drawnSeriesIds: SeriesId[];
|
|
completedAt: IsoDateTime;
|
|
}
|
|
| {
|
|
type: "round-robin";
|
|
standings: RoundRobinStandingView[];
|
|
leaderTeamIds: TeamId[];
|
|
completedAt: IsoDateTime;
|
|
}
|
|
| {
|
|
type: "double-elimination";
|
|
placements: CompetitionPlacementView[];
|
|
championTeamId: TeamId;
|
|
completedAt: IsoDateTime;
|
|
};
|
|
|
|
export interface BracketRoundView {
|
|
stage: SeriesStageType;
|
|
roundNumber?: number;
|
|
displayOrder: number;
|
|
label: string;
|
|
seriesIds: SeriesId[];
|
|
}
|
|
|
|
export interface SeriesConnectorView {
|
|
from: {
|
|
seriesId: SeriesId;
|
|
select: "winner" | "loser" | "slot-a" | "slot-b";
|
|
};
|
|
to: {
|
|
seriesId: SeriesId;
|
|
slot: SeriesSlot;
|
|
};
|
|
}
|
|
|
|
interface CompetitionProjectionBase {
|
|
sourceRevision: number;
|
|
projectorVersion: number;
|
|
phase: CompetitionPhase;
|
|
series: SeriesProjection[];
|
|
games: CompetitionGameView[];
|
|
gameSlots: GameSlotView[];
|
|
rounds: BracketRoundView[];
|
|
connectors: SeriesConnectorView[];
|
|
}
|
|
|
|
export interface PairedSeriesCompetitionProjection
|
|
extends CompetitionProjectionBase {
|
|
formatType: "paired-series";
|
|
standings?: never;
|
|
placements?: never;
|
|
outcome?: Extract<CompetitionOutcome, { type: "paired-series" }>;
|
|
}
|
|
|
|
export interface RoundRobinCompetitionProjection
|
|
extends CompetitionProjectionBase {
|
|
formatType: "round-robin";
|
|
standings: RoundRobinStandingView[];
|
|
placements?: never;
|
|
outcome?: Extract<CompetitionOutcome, { type: "round-robin" }>;
|
|
}
|
|
|
|
export interface DoubleEliminationCompetitionProjection
|
|
extends CompetitionProjectionBase {
|
|
formatType: "double-elimination";
|
|
standings?: never;
|
|
placements: CompetitionPlacementView[];
|
|
outcome?: Extract<CompetitionOutcome, { type: "double-elimination" }>;
|
|
}
|
|
|
|
export type CompetitionProjection =
|
|
| PairedSeriesCompetitionProjection
|
|
| RoundRobinCompetitionProjection
|
|
| DoubleEliminationCompetitionProjection;
|
|
|
|
export interface CompetitionDefinitionView {
|
|
id: CompetitionId;
|
|
matchId: MatchId;
|
|
communityId: CommunityId;
|
|
schemaVersion: number;
|
|
revision: number;
|
|
phase: CompetitionPhase;
|
|
teams: CompetitionTeamView[];
|
|
format: CompetitionFormat;
|
|
seriesGraph: SeriesDefinition[];
|
|
}
|
|
|
|
export interface CompetitionDetailResponse {
|
|
id: CompetitionId;
|
|
matchId: MatchId;
|
|
communityId: CommunityId;
|
|
schemaVersion: number;
|
|
revision: number;
|
|
phase: CompetitionPhase;
|
|
teams: CompetitionTeamView[];
|
|
format: CompetitionFormat;
|
|
projection: CompetitionProjection;
|
|
createdAt: IsoDateTime;
|
|
updatedAt: IsoDateTime;
|
|
}
|