sendou.ink/app/modules/brackets-model/input.ts
Kalle eae3d529e2
Bracket component rewrite (#1653)
* Remove old code

* Add prefetching

* Elim bracket initial

* Hide rounds with only byes

* Round hiding logic

* Align stuff

* Add TODO

* Adjustments

* Deadline

* Compactify button

* Simulations

* Round robin bracket initial

* eventId -> tournamentId

* seedByTeamId removed

* Couple more TODOs

* RR placements table

* Locking matches

* Extract TournamentStream component

* Bracket streams

* Remove extras for tournament-manager, misc

* Fix E2E tests

* Fix SKALOP_SYSTEM_MESSAGE_URL in env.example

* TODOs

* TODO moved to GitHub

* Handle team changing in match cache invalidation

* Fix streamer seeing undo last score button

* Show "Sub" badge on team roster page

* Show who didn't play yet on match teams preview

* Ranked/unranked badge

* Bracket hover show roster

* Add lock/unlock match test

* Fix score reporting
2024-02-11 10:49:12 +02:00

127 lines
3.5 KiB
TypeScript

/*------------------------------------------------------------|
* Contains everything which is given by the user as input.
*-----------------------------------------------------------*/
import type { Participant } from "./storage";
import type {
GrandFinalType,
RoundRobinMode,
SeedOrdering,
StageType,
} from "./unions";
/**
* A participant as it would be persisted in the storage, but with extra fields.
*/
export type CustomParticipant<ExtraFields = Record<string, unknown>> =
Participant & ExtraFields;
/**
* The seeding for a stage.
*
* Each element represents a participant, which can be:
* - A full object, with possibly extra fields.
* - Its name.
* - Its ID.
* - Or a BYE: `null`.
*/
export type Seeding = (CustomParticipant | string | number | null)[];
/**
* Used to create a stage.
*/
export interface InputStage {
/**
* ID of the parent tournament.
*
* Used to determine the `number` property of a stage related to a tournament.
*/
tournamentId: number;
/** Name of the stage. */
name: string;
/** Type of stage. */
type: StageType;
/** The number of the stage in its tournament. Is determined if not given. */
number?: number;
/** Contains participants or `null` for BYEs. */
seeding?: Seeding;
/** Contains optional settings specific to each stage type. */
settings?: StageSettings;
}
/**
* The possible settings for a stage.
*/
export interface StageSettings {
/**
* The number of participants.
*/
size?: number;
/**
* A list of ordering methods to apply to the seeding.
*
* - For a round-robin stage: 1 item required (**with** `"groups."` prefix).
* - Used to distribute in groups.
* - For a simple elimination stage, 1 item required (**without** `"groups."` prefix).
* - Used to distribute in round 1.
* - For a double elimination stage, 1 item required, 3+ items supported (**without** `"groups."` prefix).
* - Item 1 (required) - Used to distribute in WB round 1.
* - Item 2 - Used to distribute WB losers in LB round 1.
* - Items 3+ - Used to distribute WB losers in LB minor rounds (1 per round).
*/
seedOrdering?: SeedOrdering[];
/**
* Whether to balance BYEs in the seeding of an elimination stage.
*
* This prevents having BYE against BYE in matches.
*/
balanceByes?: boolean;
/**
* Number of groups in a round-robin stage.
*/
groupCount?: number;
/**
* The mode for the round-robin stage.
*
* - If `simple`, each participant plays each opponent once.
* - If `double`, each participant plays each opponent twice, once at home and once away.
*/
roundRobinMode?: RoundRobinMode;
/**
* A list of seeds per group for a round-robin stage to be manually ordered.
*
* Seed ordering is ignored if this property is given.
*/
manualOrdering?: number[][];
/**
* Optional final between semi-final losers.
*/
consolationFinal?: boolean;
/**
* Whether to skip the first round of the WB of a double elimination stage.
*/
skipFirstRound?: boolean;
/**
* Optional grand final between WB and LB winners.
*
* - If `none`, there is no grand final.
* - If `simple`, the final is a single match. The winner is the winner of the stage.
* - If `double`, if the WB winner wins, he's the winner of the stage. But if he loses, the final is reset and there is a very last match.
* It might be fairer since it gives the WB winner the right to lose once during the stage...
*/
grandFinal?: GrandFinalType;
}