1- import { Round , parseActivityCode } from '@wca/helpers' ;
1+ import {
2+ ParticipationResultCondition ,
3+ ParticipationRuleset ,
4+ ParticipationSource ,
5+ ReservedPlaces ,
6+ Round ,
7+ parseActivityCode ,
8+ } from '@wca/helpers' ;
29
3- type LegacyAdvancementCondition = {
4- type : 'ranking' | 'percent' | 'attemptResult' ;
5- level : number ;
6- } ;
7-
8- export type ResultCondition =
9- | {
10- type : 'ranking' | 'percent' ;
11- value : number ;
12- }
13- | {
14- type : 'resultAchieved' ;
15- scope : 'single' | 'average' ;
16- value : number | null ;
17- } ;
10+ type LegacyAdvancementCondition = NonNullable < Round [ 'advancementCondition' ] > ;
1811
19- export type ParticipationSource =
20- | {
21- type : 'registrations' ;
22- }
23- | {
24- type : 'round' ;
25- roundId : string ;
26- resultCondition : ResultCondition ;
27- }
28- | {
29- type : 'linkedRounds' ;
30- roundIds : string [ ] ;
31- resultCondition : ResultCondition ;
32- } ;
33-
34- export type ReservedPlaces = {
35- nationalities : string [ ] ;
36- count ?: number ;
37- reservations ?: number ;
38- } ;
39-
40- export type ParticipationRuleset = {
41- participationSource : ParticipationSource ;
42- reservedPlaces ?: ReservedPlaces | null ;
43- } ;
12+ export type ResultCondition = ParticipationResultCondition ;
4413
4514export interface RoundAdvancementCondition {
4615 sourceType : ParticipationSource [ 'type' ] ;
@@ -49,19 +18,16 @@ export interface RoundAdvancementCondition {
4918 reservedPlaces ?: ReservedPlaces | null ;
5019}
5120
52- export type CompatibleRound = Round & {
53- advancementCondition ?: LegacyAdvancementCondition | null ;
54- participationRuleset ?: ParticipationRuleset | null ;
55- } ;
21+ export type CompatibleRound = Round ;
5622
5723const averagedFormats = new Set ( [ 'a' , 'm' , '5' , 'h' ] ) ;
5824
59- const getRoundResultType = ( round : Pick < CompatibleRound , 'format' > ) : 'single' | 'average' =>
25+ const getRoundResultType = ( round : Pick < Round , 'format' > ) : 'single' | 'average' =>
6026 averagedFormats . has ( round . format ) ? 'average' : 'single' ;
6127
6228const getLegacyResultCondition = (
6329 advancementCondition : LegacyAdvancementCondition ,
64- sourceRound ?: CompatibleRound ,
30+ sourceRound ?: Round ,
6531) : ResultCondition => {
6632 switch ( advancementCondition . type ) {
6733 case 'ranking' :
@@ -83,10 +49,7 @@ const getLegacyResultCondition = (
8349 }
8450} ;
8551
86- const getPreviousRound = (
87- eventRounds : CompatibleRound [ ] ,
88- round : CompatibleRound ,
89- ) : CompatibleRound | undefined => {
52+ const getPreviousRound = ( eventRounds : Round [ ] , round : Round ) : Round | undefined => {
9053 const { eventId, roundNumber } = parseActivityCode ( round . id ) ;
9154
9255 if ( ! roundNumber || roundNumber <= 1 ) {
@@ -97,8 +60,8 @@ const getPreviousRound = (
9760} ;
9861
9962export const getRoundParticipationRuleset = (
100- eventRounds : CompatibleRound [ ] ,
101- round : CompatibleRound ,
63+ eventRounds : Round [ ] ,
64+ round : Round ,
10265) : ParticipationRuleset | null => {
10366 if ( round . participationRuleset ) {
10467 return round . participationRuleset ;
@@ -123,14 +86,14 @@ export const getRoundParticipationRuleset = (
12386} ;
12487
12588const getRoundParticipationSource = (
126- eventRounds : CompatibleRound [ ] ,
127- round : CompatibleRound ,
89+ eventRounds : Round [ ] ,
90+ round : Round ,
12891) : ParticipationSource | null =>
12992 getRoundParticipationRuleset ( eventRounds , round ) ?. participationSource ?? null ;
13093
13194export const getAdvancementConditionForRound = (
132- eventRounds : CompatibleRound [ ] ,
133- round : CompatibleRound ,
95+ eventRounds : Round [ ] ,
96+ round : Round ,
13497) : RoundAdvancementCondition | null => {
13598 if ( round . advancementCondition ) {
13699 return {
0 commit comments