tods-competition-factory 0.69.0 → 0.69.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tods-competition-factory.development.cjs.js +600 -386
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.69.
|
|
252
|
+
return '0.69.4';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
|
|
@@ -7325,12 +7325,14 @@ var collectionDefinitions = [
|
|
|
7325
7325
|
}
|
|
7326
7326
|
];
|
|
7327
7327
|
var tieFormatName = "Doubles Shuffle";
|
|
7328
|
+
var unrestrictedSelections = true;
|
|
7328
7329
|
var winCriteria = {
|
|
7329
7330
|
aggregateValue: true
|
|
7330
7331
|
};
|
|
7331
7332
|
var TEAM_AGGREGATION_TIE_FORMAT = {
|
|
7332
7333
|
collectionDefinitions: collectionDefinitions,
|
|
7333
7334
|
tieFormatName: tieFormatName,
|
|
7335
|
+
unrestrictedSelections: unrestrictedSelections,
|
|
7334
7336
|
winCriteria: winCriteria
|
|
7335
7337
|
};
|
|
7336
7338
|
|
|
@@ -7401,6 +7403,7 @@ const SINGLE_ELIMINATION = 'SINGLE_ELIMINATION';
|
|
|
7401
7403
|
const DOUBLE_ELIMINATION = 'DOUBLE_ELIMINATION';
|
|
7402
7404
|
const FIRST_MATCH_LOSER_CONSOLATION = 'FIRST_MATCH_LOSER_CONSOLATION';
|
|
7403
7405
|
const FIRST_ROUND_LOSER_CONSOLATION = 'FIRST_ROUND_LOSER_CONSOLATION';
|
|
7406
|
+
const LUCKY_DRAW = 'LUCKY_DRAW';
|
|
7404
7407
|
const CURTIS = 'CURTIS_CONSOLATION';
|
|
7405
7408
|
const FICSF = 'FEED_IN_CHAMPIONSHIP_TO_SF';
|
|
7406
7409
|
const FEED_IN_CHAMPIONSHIP_TO_SF = 'FEED_IN_CHAMPIONSHIP_TO_SF';
|
|
@@ -7471,8 +7474,8 @@ const OLYMPIC_ATTRIBUTES = {
|
|
|
7471
7474
|
|
|
7472
7475
|
const WIN_RATIO = 'WIN_RATIO';
|
|
7473
7476
|
const ROUND_OUTCOME = 'ROUND_OUTCOME';
|
|
7474
|
-
const MULTI_STRUCTURE_DRAWS = [
|
|
7475
|
-
const generatedDrawTypes = [AD_HOC, COMPASS, CURTIS, DOUBLE_ELIMINATION, FEED_IN_CHAMPIONSHIP_TO_QF, FEED_IN_CHAMPIONSHIP_TO_R16, FEED_IN_CHAMPIONSHIP_TO_SF, FEED_IN_CHAMPIONSHIP, FEED_IN$1, FIRST_MATCH_LOSER_CONSOLATION, FIRST_ROUND_LOSER_CONSOLATION, MODIFIED_FEED_IN_CHAMPIONSHIP, OLYMPIC, PLAY_OFF, ROUND_ROBIN, ROUND_ROBIN_WITH_PLAYOFF, SINGLE_ELIMINATION];
|
|
7477
|
+
const MULTI_STRUCTURE_DRAWS = [COMPASS, CURTIS, FEED_IN_CHAMPIONSHIP_TO_QF, FEED_IN_CHAMPIONSHIP_TO_R16, FEED_IN_CHAMPIONSHIP_TO_SF, FEED_IN_CHAMPIONSHIP, FICQF, FICR16, FICSF, FIRST_MATCH_LOSER_CONSOLATION, FIRST_ROUND_LOSER_CONSOLATION, LUCKY_DRAW, MODIFIED_FEED_IN_CHAMPIONSHIP, OLYMPIC, PLAY_OFF, ROUND_ROBIN_WITH_PLAYOFF];
|
|
7478
|
+
const generatedDrawTypes = [AD_HOC, COMPASS, CURTIS, DOUBLE_ELIMINATION, FEED_IN_CHAMPIONSHIP_TO_QF, FEED_IN_CHAMPIONSHIP_TO_R16, FEED_IN_CHAMPIONSHIP_TO_SF, FEED_IN_CHAMPIONSHIP, FEED_IN$1, FIRST_MATCH_LOSER_CONSOLATION, FIRST_ROUND_LOSER_CONSOLATION, LUCKY_DRAW, MODIFIED_FEED_IN_CHAMPIONSHIP, OLYMPIC, PLAY_OFF, ROUND_ROBIN, ROUND_ROBIN_WITH_PLAYOFF, SINGLE_ELIMINATION];
|
|
7476
7479
|
const drawDefinitionConstants = {
|
|
7477
7480
|
MAIN,
|
|
7478
7481
|
QUALIFYING,
|
|
@@ -9326,11 +9329,11 @@ function getTeamLineUp({
|
|
|
9326
9329
|
|
|
9327
9330
|
const extractor = object => attr => object[attr];
|
|
9328
9331
|
|
|
9329
|
-
const getMatchUpIds = (o = []) => o.map(getMatchUpId
|
|
9332
|
+
const getMatchUpIds = (o = []) => o.map(getMatchUpId).filter(Boolean);
|
|
9330
9333
|
const getParticipantIds = (o = []) => o.map(getParticipantId).filter(Boolean);
|
|
9331
9334
|
const getParticipantId = (o = {}) => extractor(o)('participantId');
|
|
9332
9335
|
const getDrawPosition = (o = {}) => extractor(o)('drawPosition');
|
|
9333
|
-
const getMatchUpId
|
|
9336
|
+
const getMatchUpId = (o = {}) => extractor(o)('matchUpId');
|
|
9334
9337
|
|
|
9335
9338
|
function getDrawPositionCollectionAssignment({
|
|
9336
9339
|
tournamentParticipants,
|
|
@@ -9537,7 +9540,11 @@ function getRoundMatchUps$1({
|
|
|
9537
9540
|
roundIndex += 1;
|
|
9538
9541
|
}
|
|
9539
9542
|
});
|
|
9543
|
+
const hasOddMatchUpsCount = Object.values(roundProfile).find(({
|
|
9544
|
+
matchUpsCount
|
|
9545
|
+
}) => !isPowerOf2(matchUpsCount));
|
|
9540
9546
|
return {
|
|
9547
|
+
hasOddMatchUpsCount,
|
|
9541
9548
|
maxMatchUpsCount,
|
|
9542
9549
|
roundMatchUps,
|
|
9543
9550
|
roundNumbers,
|
|
@@ -10687,6 +10694,28 @@ function getOrderedDrawPositions({
|
|
|
10687
10694
|
};
|
|
10688
10695
|
}
|
|
10689
10696
|
|
|
10697
|
+
function isLucky({
|
|
10698
|
+
drawDefinition,
|
|
10699
|
+
structure
|
|
10700
|
+
}) {
|
|
10701
|
+
var _roundMatchUps$, _roundMatchUps$2;
|
|
10702
|
+
|
|
10703
|
+
if (!structure) return false;
|
|
10704
|
+
const {
|
|
10705
|
+
hasOddMatchUpsCount,
|
|
10706
|
+
roundMatchUps
|
|
10707
|
+
} = getRoundMatchUps$1({
|
|
10708
|
+
matchUps: structure.matchUps || []
|
|
10709
|
+
});
|
|
10710
|
+
const hasFirstRoundDrawPositions = !!(roundMatchUps !== null && roundMatchUps !== void 0 && (_roundMatchUps$ = roundMatchUps[1]) !== null && _roundMatchUps$ !== void 0 && _roundMatchUps$.find(({
|
|
10711
|
+
drawPositions
|
|
10712
|
+
}) => drawPositions));
|
|
10713
|
+
const noSecondRoundDrawPositions = !(roundMatchUps !== null && roundMatchUps !== void 0 && (_roundMatchUps$2 = roundMatchUps[2]) !== null && _roundMatchUps$2 !== void 0 && _roundMatchUps$2.find(({
|
|
10714
|
+
drawPositions
|
|
10715
|
+
}) => drawPositions));
|
|
10716
|
+
return hasOddMatchUpsCount && !(structure !== null && structure !== void 0 && structure.structures) && hasFirstRoundDrawPositions && noSecondRoundDrawPositions && !(drawDefinition !== null && drawDefinition !== void 0 && drawDefinition.drawType && drawDefinition.drawType !== LUCKY_DRAW);
|
|
10717
|
+
}
|
|
10718
|
+
|
|
10690
10719
|
function isAdHoc({
|
|
10691
10720
|
drawDefinition,
|
|
10692
10721
|
structure
|
|
@@ -10707,6 +10736,9 @@ function getRoundContextProfile({
|
|
|
10707
10736
|
const isAdHocStructure = isAdHoc({
|
|
10708
10737
|
structure
|
|
10709
10738
|
});
|
|
10739
|
+
const isLuckyStructure = isLucky({
|
|
10740
|
+
structure
|
|
10741
|
+
});
|
|
10710
10742
|
const {
|
|
10711
10743
|
roundProfile
|
|
10712
10744
|
} = getRoundMatchUps$1({
|
|
@@ -10724,12 +10756,14 @@ function getRoundContextProfile({
|
|
|
10724
10756
|
const stageConstants = roundNamingPolicy === null || roundNamingPolicy === void 0 ? void 0 : roundNamingPolicy.stageConstants;
|
|
10725
10757
|
const stageConstant = stageConstants && stageConstants[stage] || stageInitial;
|
|
10726
10758
|
|
|
10727
|
-
if (isRoundRobin || isAdHocStructure) {
|
|
10759
|
+
if (isRoundRobin || isAdHocStructure || isLuckyStructure) {
|
|
10728
10760
|
Object.assign(roundNamingProfile, ...Object.keys(roundProfile).map(key => {
|
|
10729
|
-
const
|
|
10761
|
+
const roundName = `Round ${key}`;
|
|
10762
|
+
const abbreviatedRoundName = `R${key}`;
|
|
10730
10763
|
return {
|
|
10731
10764
|
[key]: {
|
|
10732
|
-
roundName
|
|
10765
|
+
roundName,
|
|
10766
|
+
abbreviatedRoundName
|
|
10733
10767
|
}
|
|
10734
10768
|
};
|
|
10735
10769
|
}));
|
|
@@ -11414,9 +11448,7 @@ function getAllStructureMatchUps({
|
|
|
11414
11448
|
const collectionDefinitions = tieFormat === null || tieFormat === void 0 ? void 0 : tieFormat.collectionDefinitions;
|
|
11415
11449
|
const collectionDefinition = matchUp.collectionId && (collectionDefinitions === null || collectionDefinitions === void 0 ? void 0 : collectionDefinitions.find(definition => definition.collectionId === matchUp.collectionId));
|
|
11416
11450
|
const matchUpFormat = matchUp.matchUpFormat || matchUp.collectionId ? collectionDefinition && collectionDefinition.matchUpFormat : structure.matchUpFormat || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) || (event === null || event === void 0 ? void 0 : event.matchUpFormat);
|
|
11417
|
-
const matchUpType = matchUp.matchUpType || (collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) || structure.matchUpType || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType) || (event === null || event === void 0 ? void 0 : event.eventType) !== TEAM$2 && (event === null || event === void 0 ? void 0 : event.eventType);
|
|
11418
|
-
// console.log({ matchUpType, event });
|
|
11419
|
-
|
|
11451
|
+
const matchUpType = matchUp.matchUpType || (collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) || structure.matchUpType || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType) || (event === null || event === void 0 ? void 0 : event.eventType) !== TEAM$2 && (event === null || event === void 0 ? void 0 : event.eventType);
|
|
11420
11452
|
const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
|
|
11421
11453
|
const {
|
|
11422
11454
|
schedule,
|
|
@@ -11458,8 +11490,8 @@ function getAllStructureMatchUps({
|
|
|
11458
11490
|
const onlyDefined = obj => definedAttributes(obj, undefined, true);
|
|
11459
11491
|
|
|
11460
11492
|
const matchUpWithContext = Object.assign({}, onlyDefined(context), onlyDefined({
|
|
11461
|
-
matchUpFormat: matchUp.matchUpType
|
|
11462
|
-
tieFormat: matchUp.matchUpType
|
|
11493
|
+
matchUpFormat: matchUp.matchUpType === TEAM$2 ? undefined : matchUpFormat,
|
|
11494
|
+
tieFormat: matchUp.matchUpType !== TEAM$2 ? undefined : tieFormat,
|
|
11463
11495
|
endDate: matchUp.endDate || endDate,
|
|
11464
11496
|
abbreviatedRoundName,
|
|
11465
11497
|
drawPositionsRange,
|
|
@@ -12015,10 +12047,10 @@ function addMatchUpScheduleItems$2({
|
|
|
12015
12047
|
|
|
12016
12048
|
if (scheduledDate !== undefined) {
|
|
12017
12049
|
const result = addMatchUpScheduledDate$2({
|
|
12050
|
+
disableNotice: true,
|
|
12018
12051
|
drawDefinition,
|
|
12019
|
-
matchUpId,
|
|
12020
12052
|
scheduledDate,
|
|
12021
|
-
|
|
12053
|
+
matchUpId
|
|
12022
12054
|
});
|
|
12023
12055
|
if (result !== null && result !== void 0 && result.error) return {
|
|
12024
12056
|
error: result.error,
|
|
@@ -12028,10 +12060,10 @@ function addMatchUpScheduleItems$2({
|
|
|
12028
12060
|
|
|
12029
12061
|
if (scheduledTime !== undefined) {
|
|
12030
12062
|
const result = addMatchUpScheduledTime$2({
|
|
12063
|
+
disableNotice: true,
|
|
12031
12064
|
drawDefinition,
|
|
12032
|
-
matchUpId,
|
|
12033
12065
|
scheduledTime,
|
|
12034
|
-
|
|
12066
|
+
matchUpId
|
|
12035
12067
|
});
|
|
12036
12068
|
if (result !== null && result !== void 0 && result.error) return {
|
|
12037
12069
|
error: result.error,
|
|
@@ -12146,9 +12178,9 @@ function addMatchUpScheduleItems$2({
|
|
|
12146
12178
|
}
|
|
12147
12179
|
function addMatchUpScheduledDate$2({
|
|
12148
12180
|
drawDefinition,
|
|
12149
|
-
matchUpId,
|
|
12150
12181
|
disableNotice,
|
|
12151
|
-
scheduledDate
|
|
12182
|
+
scheduledDate,
|
|
12183
|
+
matchUpId
|
|
12152
12184
|
}) {
|
|
12153
12185
|
if (!matchUpId) return {
|
|
12154
12186
|
error: MISSING_MATCHUP_ID
|
|
@@ -12165,18 +12197,18 @@ function addMatchUpScheduledDate$2({
|
|
|
12165
12197
|
itemValue: scheduledDate
|
|
12166
12198
|
};
|
|
12167
12199
|
return addMatchUpTimeItem({
|
|
12200
|
+
duplicateValues: false,
|
|
12168
12201
|
drawDefinition,
|
|
12169
|
-
matchUpId,
|
|
12170
|
-
timeItem,
|
|
12171
12202
|
disableNotice,
|
|
12172
|
-
|
|
12203
|
+
matchUpId,
|
|
12204
|
+
timeItem
|
|
12173
12205
|
});
|
|
12174
12206
|
}
|
|
12175
12207
|
function addMatchUpScheduledTime$2({
|
|
12176
12208
|
drawDefinition,
|
|
12177
|
-
matchUpId,
|
|
12178
12209
|
disableNotice,
|
|
12179
|
-
scheduledTime
|
|
12210
|
+
scheduledTime,
|
|
12211
|
+
matchUpId
|
|
12180
12212
|
}) {
|
|
12181
12213
|
if (!matchUpId) return {
|
|
12182
12214
|
error: MISSING_MATCHUP_ID
|
|
@@ -12192,19 +12224,19 @@ function addMatchUpScheduledTime$2({
|
|
|
12192
12224
|
itemValue
|
|
12193
12225
|
};
|
|
12194
12226
|
return addMatchUpTimeItem({
|
|
12227
|
+
duplicateValues: false,
|
|
12195
12228
|
drawDefinition,
|
|
12196
|
-
matchUpId,
|
|
12197
|
-
timeItem,
|
|
12198
12229
|
disableNotice,
|
|
12199
|
-
|
|
12230
|
+
matchUpId,
|
|
12231
|
+
timeItem
|
|
12200
12232
|
});
|
|
12201
12233
|
}
|
|
12202
12234
|
function addMatchUpOfficial$2({
|
|
12203
12235
|
drawDefinition,
|
|
12204
|
-
matchUpId,
|
|
12205
12236
|
disableNotice,
|
|
12206
12237
|
participantId,
|
|
12207
|
-
officialType
|
|
12238
|
+
officialType,
|
|
12239
|
+
matchUpId
|
|
12208
12240
|
}) {
|
|
12209
12241
|
if (!matchUpId) return {
|
|
12210
12242
|
error: MISSING_MATCHUP_ID
|
|
@@ -12216,11 +12248,11 @@ function addMatchUpOfficial$2({
|
|
|
12216
12248
|
itemValue: participantId
|
|
12217
12249
|
};
|
|
12218
12250
|
return addMatchUpTimeItem({
|
|
12251
|
+
duplicateValues: false,
|
|
12219
12252
|
drawDefinition,
|
|
12220
|
-
matchUpId,
|
|
12221
|
-
timeItem,
|
|
12222
12253
|
disableNotice,
|
|
12223
|
-
|
|
12254
|
+
matchUpId,
|
|
12255
|
+
timeItem
|
|
12224
12256
|
});
|
|
12225
12257
|
}
|
|
12226
12258
|
function addMatchUpStartTime$2({
|
|
@@ -12257,11 +12289,11 @@ function addMatchUpStartTime$2({
|
|
|
12257
12289
|
itemValue: startTime
|
|
12258
12290
|
};
|
|
12259
12291
|
return addMatchUpTimeItem({
|
|
12292
|
+
duplicateValues: false,
|
|
12260
12293
|
drawDefinition,
|
|
12261
|
-
matchUpId,
|
|
12262
|
-
timeItem,
|
|
12263
12294
|
disableNotice,
|
|
12264
|
-
|
|
12295
|
+
matchUpId,
|
|
12296
|
+
timeItem
|
|
12265
12297
|
});
|
|
12266
12298
|
} else {
|
|
12267
12299
|
return {
|
|
@@ -12303,11 +12335,11 @@ function addMatchUpEndTime$2({
|
|
|
12303
12335
|
itemValue: endTime
|
|
12304
12336
|
};
|
|
12305
12337
|
return addMatchUpTimeItem({
|
|
12338
|
+
duplicateValues: false,
|
|
12306
12339
|
drawDefinition,
|
|
12307
|
-
matchUpId,
|
|
12308
|
-
timeItem,
|
|
12309
12340
|
disableNotice,
|
|
12310
|
-
|
|
12341
|
+
matchUpId,
|
|
12342
|
+
timeItem
|
|
12311
12343
|
});
|
|
12312
12344
|
} else {
|
|
12313
12345
|
return {
|
|
@@ -12360,11 +12392,11 @@ function addMatchUpStopTime$2({
|
|
|
12360
12392
|
itemValue: stopTime
|
|
12361
12393
|
};
|
|
12362
12394
|
return addMatchUpTimeItem({
|
|
12395
|
+
duplicateValues: true,
|
|
12363
12396
|
drawDefinition,
|
|
12364
|
-
matchUpId,
|
|
12365
|
-
timeItem,
|
|
12366
12397
|
disableNotice,
|
|
12367
|
-
|
|
12398
|
+
matchUpId,
|
|
12399
|
+
timeItem
|
|
12368
12400
|
});
|
|
12369
12401
|
} else {
|
|
12370
12402
|
return {
|
|
@@ -12417,11 +12449,11 @@ function addMatchUpResumeTime$2({
|
|
|
12417
12449
|
itemValue: resumeTime
|
|
12418
12450
|
};
|
|
12419
12451
|
return addMatchUpTimeItem({
|
|
12452
|
+
duplicateValues: true,
|
|
12420
12453
|
drawDefinition,
|
|
12421
|
-
matchUpId,
|
|
12422
|
-
timeItem,
|
|
12423
12454
|
disableNotice,
|
|
12424
|
-
|
|
12455
|
+
matchUpId,
|
|
12456
|
+
timeItem
|
|
12425
12457
|
});
|
|
12426
12458
|
} else {
|
|
12427
12459
|
return {
|
|
@@ -14004,7 +14036,7 @@ function bulkScheduleMatchUps({
|
|
|
14004
14036
|
const {
|
|
14005
14037
|
tournamentId
|
|
14006
14038
|
} = tournamentRecord;
|
|
14007
|
-
const matchUpIds = matchUpContextIds.filter(contextIds => contextIds.tournamentId === tournamentId).map(getMatchUpId
|
|
14039
|
+
const matchUpIds = matchUpContextIds.filter(contextIds => contextIds.tournamentId === tournamentId).map(getMatchUpId);
|
|
14008
14040
|
|
|
14009
14041
|
if (matchUpIds !== null && matchUpIds !== void 0 && matchUpIds.length) {
|
|
14010
14042
|
const result = bulkScheduleMatchUps$1({
|
|
@@ -15683,12 +15715,12 @@ function drawPositionRemovals({
|
|
|
15683
15715
|
}
|
|
15684
15716
|
|
|
15685
15717
|
function removeSubsequentRoundsParticipant({
|
|
15686
|
-
|
|
15687
|
-
structureId,
|
|
15688
|
-
roundNumber,
|
|
15718
|
+
inContextDrawMatchUps,
|
|
15689
15719
|
targetDrawPosition,
|
|
15720
|
+
drawDefinition,
|
|
15690
15721
|
matchUpsMap,
|
|
15691
|
-
|
|
15722
|
+
roundNumber,
|
|
15723
|
+
structureId
|
|
15692
15724
|
}) {
|
|
15693
15725
|
var _matchUpsMap;
|
|
15694
15726
|
|
|
@@ -15718,24 +15750,24 @@ function removeSubsequentRoundsParticipant({
|
|
|
15718
15750
|
structureId
|
|
15719
15751
|
});
|
|
15720
15752
|
relevantMatchUps === null || relevantMatchUps === void 0 ? void 0 : relevantMatchUps.forEach(matchUp => removeDrawPosition({
|
|
15721
|
-
targetMatchUp: matchUp,
|
|
15722
15753
|
drawPosition: targetDrawPosition,
|
|
15754
|
+
targetMatchUp: matchUp,
|
|
15755
|
+
inContextDrawMatchUps,
|
|
15723
15756
|
positionAssignments,
|
|
15724
15757
|
drawDefinition,
|
|
15725
|
-
structure,
|
|
15726
15758
|
matchUpsMap,
|
|
15727
|
-
|
|
15759
|
+
structure
|
|
15728
15760
|
}));
|
|
15729
15761
|
}
|
|
15730
15762
|
|
|
15731
15763
|
function removeDrawPosition({
|
|
15764
|
+
inContextDrawMatchUps,
|
|
15732
15765
|
positionAssignments,
|
|
15766
|
+
drawDefinition,
|
|
15733
15767
|
targetMatchUp,
|
|
15734
15768
|
drawPosition,
|
|
15735
|
-
|
|
15736
|
-
structure
|
|
15737
|
-
inContextDrawMatchUps,
|
|
15738
|
-
matchUpsMap
|
|
15769
|
+
matchUpsMap,
|
|
15770
|
+
structure
|
|
15739
15771
|
}) {
|
|
15740
15772
|
matchUpsMap = matchUpsMap || getMatchUpsMap({
|
|
15741
15773
|
drawDefinition
|
|
@@ -16665,9 +16697,6 @@ function removeDirectedLoser({
|
|
|
16665
16697
|
|
|
16666
16698
|
if (targetSide) {
|
|
16667
16699
|
delete targetSide.lineUp;
|
|
16668
|
-
console.log('remove loser lineUp', {
|
|
16669
|
-
targetSide
|
|
16670
|
-
});
|
|
16671
16700
|
modifyMatchUpNotice({
|
|
16672
16701
|
drawDefinition,
|
|
16673
16702
|
matchUp: targetMatchUp
|
|
@@ -19838,13 +19867,6 @@ function setMatchUpStatus$2(params) {
|
|
|
19838
19867
|
return {
|
|
19839
19868
|
error: INVALID_MATCHUP_STATUS
|
|
19840
19869
|
};
|
|
19841
|
-
}
|
|
19842
|
-
|
|
19843
|
-
if (score) {
|
|
19844
|
-
const result = validateScore({
|
|
19845
|
-
score
|
|
19846
|
-
});
|
|
19847
|
-
if (result.error) return result;
|
|
19848
19870
|
} // Get map of all drawMatchUps and inContextDrawMatchUPs ---------------------
|
|
19849
19871
|
|
|
19850
19872
|
|
|
@@ -19872,6 +19894,16 @@ function setMatchUpStatus$2(params) {
|
|
|
19872
19894
|
})); // Find target matchUp ------------------------------------------------------
|
|
19873
19895
|
|
|
19874
19896
|
const matchUp = matchUpsMap.drawMatchUps.find(matchUp => matchUp.matchUpId === matchUpId);
|
|
19897
|
+
|
|
19898
|
+
if (score) {
|
|
19899
|
+
const result = validateScore({
|
|
19900
|
+
score,
|
|
19901
|
+
matchUp,
|
|
19902
|
+
winningSide
|
|
19903
|
+
});
|
|
19904
|
+
if (result.error) return result;
|
|
19905
|
+
}
|
|
19906
|
+
|
|
19875
19907
|
const inContextMatchUp = inContextDrawMatchUps.find(matchUp => matchUp.matchUpId === matchUpId);
|
|
19876
19908
|
if (!matchUp || !inContextDrawMatchUps) return {
|
|
19877
19909
|
error: MATCHUP_NOT_FOUND
|
|
@@ -24542,7 +24574,7 @@ function getScheduledRoundsDetails({
|
|
|
24542
24574
|
const matchUpIds = roundMatchUps.filter(({
|
|
24543
24575
|
matchUpStatus
|
|
24544
24576
|
}) => // don't attempt to scheduled completed matchUpstatuses
|
|
24545
|
-
!completedMatchUpStatuses.includes(matchUpStatus) && matchUpStatus !== BYE).map(getMatchUpId
|
|
24577
|
+
!completedMatchUpStatuses.includes(matchUpStatus) && matchUpStatus !== BYE).map(getMatchUpId);
|
|
24546
24578
|
matchUpIds.forEach(matchUpId => {
|
|
24547
24579
|
minutesMap[matchUpId] = {
|
|
24548
24580
|
typeChangeRecoveryMinutes,
|
|
@@ -24731,7 +24763,7 @@ function calculateScheduleTimes({
|
|
|
24731
24763
|
} = getScheduleTimes(timingParameters); // if a single venue specified, or only one venue available, return venueId
|
|
24732
24764
|
|
|
24733
24765
|
const venueId = (venueIds === null || venueIds === void 0 ? void 0 : venueIds.length) === 1 ? venueIds[0] : (venues === null || venues === void 0 ? void 0 : venues.length) === 1 ? venues[0].venueId : undefined;
|
|
24734
|
-
const dateScheduledMatchUpIds = relevantMatchUps.map(getMatchUpId
|
|
24766
|
+
const dateScheduledMatchUpIds = relevantMatchUps.map(getMatchUpId);
|
|
24735
24767
|
return {
|
|
24736
24768
|
venueId,
|
|
24737
24769
|
scheduleTimes,
|
|
@@ -25573,7 +25605,7 @@ function clearScheduledMatchUps$1({
|
|
|
25573
25605
|
const relevantMatchUpIds = matchUps.filter(matchUp => !ignoreMatchUpStatuses.includes(matchUp.matchUpStatus) && hasSchedule({
|
|
25574
25606
|
schedule: matchUp.schedule,
|
|
25575
25607
|
scheduleAttributes
|
|
25576
|
-
}) && (!(venueIds !== null && venueIds !== void 0 && venueIds.length) || venueIds.includes(matchUp.schedule.venueId))).map(getMatchUpId
|
|
25608
|
+
}) && (!(venueIds !== null && venueIds !== void 0 && venueIds.length) || venueIds.includes(matchUp.schedule.venueId))).map(getMatchUpId);
|
|
25577
25609
|
const clearedScheduleValues = {
|
|
25578
25610
|
venueId: '',
|
|
25579
25611
|
scheduledDate: '',
|
|
@@ -25874,7 +25906,7 @@ function generateScheduleTimes({
|
|
|
25874
25906
|
} = getScheduleTimes(timingParameters); // if a single venue specified, or only one venue available, return venueId
|
|
25875
25907
|
|
|
25876
25908
|
const venueId = (venueIds === null || venueIds === void 0 ? void 0 : venueIds.length) === 1 ? venueIds[0] : (venues === null || venues === void 0 ? void 0 : venues.length) === 1 ? venues[0].venueId : undefined;
|
|
25877
|
-
const dateScheduledMatchUpIds = dateScheduledMatchUps.map(getMatchUpId
|
|
25909
|
+
const dateScheduledMatchUpIds = dateScheduledMatchUps.map(getMatchUpId);
|
|
25878
25910
|
return {
|
|
25879
25911
|
venueId,
|
|
25880
25912
|
scheduleTimes,
|
|
@@ -26366,7 +26398,7 @@ function jinnScheduler({
|
|
|
26366
26398
|
});
|
|
26367
26399
|
}
|
|
26368
26400
|
});
|
|
26369
|
-
noTimeMatchUpIds[scheduleDate] = venueScheduledRoundDetails[venueId].matchUpsToSchedule.map(getMatchUpId
|
|
26401
|
+
noTimeMatchUpIds[scheduleDate] = venueScheduledRoundDetails[venueId].matchUpsToSchedule.map(getMatchUpId);
|
|
26370
26402
|
scheduleTimesRemaining[scheduleDate][venueId] = venueScheduledRoundDetails[venueId].scheduleTimes.sort((a, b) => timeStringMinutes(a.scheduleTime) - timeStringMinutes(b.scheduleTime));
|
|
26371
26403
|
}
|
|
26372
26404
|
} // returns the original form of the dateStrings, before extractDate()
|
|
@@ -31080,123 +31112,70 @@ const structureTemplate = ({
|
|
|
31080
31112
|
return structure;
|
|
31081
31113
|
};
|
|
31082
31114
|
|
|
31083
|
-
function treeMatchUps({
|
|
31084
|
-
qualifyingRoundNumber,
|
|
31085
|
-
// round at which participants qualify
|
|
31086
|
-
finishingPositionOffset,
|
|
31087
|
-
qualifyingPositions,
|
|
31088
|
-
// number of positions which qualify
|
|
31089
|
-
matchUpType,
|
|
31090
|
-
roundLimit,
|
|
31091
|
-
idPrefix,
|
|
31092
|
-
drawSize,
|
|
31093
|
-
isMock,
|
|
31094
|
-
uuids
|
|
31095
|
-
}) {
|
|
31096
|
-
if (isNaN(drawSize) || !isPowerOf2(drawSize) || drawSize < 2) {
|
|
31097
|
-
return {
|
|
31098
|
-
matchUps: [],
|
|
31099
|
-
roundsCount: 0
|
|
31100
|
-
};
|
|
31101
|
-
}
|
|
31102
|
-
|
|
31103
|
-
const nodes = generateRange(1, parseInt(drawSize) + 1).map(drawPosition => ({
|
|
31104
|
-
drawPosition
|
|
31105
|
-
}));
|
|
31106
|
-
let roundNodes;
|
|
31107
|
-
let matchUps = [];
|
|
31108
|
-
let roundNumber = 1;
|
|
31109
|
-
({
|
|
31110
|
-
roundNodes,
|
|
31111
|
-
matchUps
|
|
31112
|
-
} = buildRound({
|
|
31113
|
-
roundNumber,
|
|
31114
|
-
matchUpType,
|
|
31115
|
-
idPrefix,
|
|
31116
|
-
matchUps,
|
|
31117
|
-
isMock,
|
|
31118
|
-
nodes,
|
|
31119
|
-
uuids
|
|
31120
|
-
}));
|
|
31121
|
-
roundNumber++;
|
|
31122
|
-
roundLimit = roundLimit || qualifyingRoundNumber;
|
|
31123
|
-
|
|
31124
|
-
while (roundNodes.length > 1) {
|
|
31125
|
-
if (qualifyingPositions && roundNodes.length === qualifyingPositions) roundLimit = roundNumber - 1;
|
|
31126
|
-
({
|
|
31127
|
-
roundNodes,
|
|
31128
|
-
matchUps
|
|
31129
|
-
} = buildRound({
|
|
31130
|
-
nodes: roundNodes,
|
|
31131
|
-
roundNumber,
|
|
31132
|
-
matchUpType,
|
|
31133
|
-
idPrefix,
|
|
31134
|
-
matchUps,
|
|
31135
|
-
isMock,
|
|
31136
|
-
uuids
|
|
31137
|
-
}));
|
|
31138
|
-
roundNumber++;
|
|
31139
|
-
}
|
|
31140
|
-
|
|
31141
|
-
const roundsCount = roundNumber - 1;
|
|
31142
|
-
matchUps = addFinishingRounds({
|
|
31143
|
-
finishingPositionOffset,
|
|
31144
|
-
roundsCount,
|
|
31145
|
-
roundLimit,
|
|
31146
|
-
matchUps
|
|
31147
|
-
});
|
|
31148
|
-
|
|
31149
|
-
if (roundLimit) {
|
|
31150
|
-
matchUps = matchUps.filter(matchUp => matchUp.roundNumber <= roundLimit);
|
|
31151
|
-
}
|
|
31152
|
-
|
|
31153
|
-
return {
|
|
31154
|
-
matchUps,
|
|
31155
|
-
roundsCount,
|
|
31156
|
-
roundLimit
|
|
31157
|
-
};
|
|
31158
|
-
}
|
|
31159
|
-
|
|
31160
31115
|
function addFinishingRounds({
|
|
31161
31116
|
finishingPositionOffset = 0,
|
|
31162
31117
|
positionsFed,
|
|
31163
31118
|
roundsCount,
|
|
31164
31119
|
roundLimit,
|
|
31165
31120
|
matchUps,
|
|
31121
|
+
lucky,
|
|
31166
31122
|
fmlc
|
|
31167
31123
|
}) {
|
|
31168
|
-
|
|
31169
|
-
|
|
31170
|
-
|
|
31171
|
-
|
|
31172
|
-
|
|
31124
|
+
const {
|
|
31125
|
+
roundProfile,
|
|
31126
|
+
roundNumbers
|
|
31127
|
+
} = getRoundMatchUps$1({
|
|
31128
|
+
matchUps
|
|
31129
|
+
}); // array of # of matchUps (value) for eaach round (index)
|
|
31173
31130
|
|
|
31174
|
-
const
|
|
31131
|
+
const roundMatchUpsCountArray = Object.values(roundProfile).map(({
|
|
31132
|
+
matchUpsCount
|
|
31133
|
+
}) => matchUpsCount); // returns a range for array of possible finishing drawPositions
|
|
31175
31134
|
|
|
31176
31135
|
const finishingRange = drawPositions => [Math.min(...drawPositions), Math.max(...drawPositions)]; // for qualifying, offset the final round so that qualifyinground is finishingRound
|
|
31177
31136
|
|
|
31178
31137
|
|
|
31179
31138
|
const finishingRoundOffset = roundLimit ? roundsCount - roundLimit : 0;
|
|
31180
|
-
|
|
31181
|
-
|
|
31139
|
+
const roundFinishingData = Object.assign({}, ...roundNumbers.map(roundNumber => {
|
|
31140
|
+
const finishingRound = roundsCount + 1 - roundNumber - finishingRoundOffset;
|
|
31141
|
+
const matchUpsCount = roundProfile[roundNumber].matchUpsCount;
|
|
31142
|
+
const finishingData = {
|
|
31143
|
+
finishingRound
|
|
31144
|
+
};
|
|
31145
|
+
const upcomingMatchUps = roundMatchUpsCountArray.slice(roundNumber - 1).reduce((a, b) => a + b, 0); // in the case of FMLC the finishingPositionRange in consolation is not modified after first fed round
|
|
31182
31146
|
|
|
31183
|
-
const fmlcException = fmlc &&
|
|
31147
|
+
const fmlcException = fmlc && roundNumber !== 1;
|
|
31184
31148
|
const rangeOffset = 1 + finishingPositionOffset + (fmlcException ? positionsFed : 0);
|
|
31185
|
-
const currentMatchUps = roundMatchCounts[matchUp.roundNumber];
|
|
31186
|
-
const upcomingMatchUps = roundMatchCountArray.slice(matchUp.roundNumber - 1).reduce((a, b) => a + b, 0);
|
|
31187
31149
|
const finalPosition = 1;
|
|
31188
|
-
const
|
|
31189
|
-
const slicer = upcomingMatchUps + finalPosition -
|
|
31190
|
-
const loser = finishingRange(
|
|
31191
|
-
const winner = finishingRange(
|
|
31192
|
-
|
|
31150
|
+
const positionRange = generateRange(rangeOffset, lucky ? rangeOffset + matchUpsCount * 2 : upcomingMatchUps + rangeOffset + finalPosition);
|
|
31151
|
+
const slicer = upcomingMatchUps + finalPosition - matchUpsCount;
|
|
31152
|
+
const loser = finishingRange(positionRange.slice(slicer));
|
|
31153
|
+
const winner = finishingRange(positionRange.slice(0, slicer));
|
|
31154
|
+
finishingData.finishingPositionRange = {
|
|
31193
31155
|
loser,
|
|
31194
31156
|
winner
|
|
31195
31157
|
};
|
|
31158
|
+
return {
|
|
31159
|
+
[roundNumber]: finishingData
|
|
31160
|
+
};
|
|
31161
|
+
}));
|
|
31162
|
+
matchUps.forEach(matchUp => {
|
|
31163
|
+
const roundData = roundFinishingData[matchUp.roundNumber];
|
|
31164
|
+
matchUp.finishingRound = roundData.finishingRound;
|
|
31165
|
+
matchUp.finishingPositionRange = roundData.finishingPositionRange;
|
|
31196
31166
|
});
|
|
31197
31167
|
return matchUps;
|
|
31198
31168
|
}
|
|
31199
31169
|
|
|
31170
|
+
function generateMatchUpId({
|
|
31171
|
+
idPrefix,
|
|
31172
|
+
roundNumber,
|
|
31173
|
+
roundPosition,
|
|
31174
|
+
uuids
|
|
31175
|
+
}) {
|
|
31176
|
+
return idPrefix ? `${idPrefix}-${roundNumber}-${roundPosition}` : (uuids === null || uuids === void 0 ? void 0 : uuids.pop()) || UUID();
|
|
31177
|
+
}
|
|
31178
|
+
|
|
31200
31179
|
function buildRound({
|
|
31201
31180
|
includeMatchUpType,
|
|
31202
31181
|
matchUpType,
|
|
@@ -31218,7 +31197,7 @@ function buildRound({
|
|
|
31218
31197
|
const child2 = nodes[index + 1];
|
|
31219
31198
|
if (matchRoundNumber) child1.roundNumber = matchRoundNumber;
|
|
31220
31199
|
if (child2 && matchRoundNumber) child2.roundNumber = matchRoundNumber;
|
|
31221
|
-
const matchUpId =
|
|
31200
|
+
const matchUpId = generateMatchUpId({
|
|
31222
31201
|
roundPosition,
|
|
31223
31202
|
roundNumber,
|
|
31224
31203
|
idPrefix,
|
|
@@ -31244,8 +31223,8 @@ function buildRound({
|
|
|
31244
31223
|
if (includeMatchUpType) matchUp.matchUpType = matchUpType;
|
|
31245
31224
|
if (isMock) matchUp.isMock = true;
|
|
31246
31225
|
matchUps.push(matchUp);
|
|
31247
|
-
index += 2;
|
|
31248
31226
|
roundPosition++;
|
|
31227
|
+
index += 2;
|
|
31249
31228
|
}
|
|
31250
31229
|
|
|
31251
31230
|
return {
|
|
@@ -31254,247 +31233,103 @@ function buildRound({
|
|
|
31254
31233
|
};
|
|
31255
31234
|
}
|
|
31256
31235
|
|
|
31257
|
-
function
|
|
31258
|
-
|
|
31259
|
-
|
|
31260
|
-
const rounds = Math.ceil(Math.log(drawSize) / Math.log(2));
|
|
31261
|
-
const range = generateRange(0, rounds).reverse();
|
|
31262
|
-
return range.map(r => Math.pow(2, r));
|
|
31263
|
-
}
|
|
31264
|
-
|
|
31265
|
-
function feedInMatchUps({
|
|
31266
|
-
linkFedFinishingRoundNumbers = [],
|
|
31267
|
-
linkFedRoundNumbers = [],
|
|
31236
|
+
function treeMatchUps({
|
|
31237
|
+
qualifyingRoundNumber,
|
|
31238
|
+
// round at which participants qualify
|
|
31268
31239
|
finishingPositionOffset,
|
|
31269
|
-
|
|
31270
|
-
|
|
31271
|
-
skipRounds = 0,
|
|
31272
|
-
feedsFromFinal,
|
|
31273
|
-
isConsolation,
|
|
31274
|
-
baseDrawSize,
|
|
31240
|
+
qualifyingPositions,
|
|
31241
|
+
// number of positions which qualify
|
|
31275
31242
|
matchUpType,
|
|
31243
|
+
roundLimit,
|
|
31276
31244
|
idPrefix,
|
|
31277
31245
|
drawSize,
|
|
31278
31246
|
isMock,
|
|
31279
|
-
uuids
|
|
31280
|
-
fmlc
|
|
31247
|
+
uuids
|
|
31281
31248
|
}) {
|
|
31282
|
-
|
|
31283
|
-
|
|
31284
|
-
|
|
31285
|
-
|
|
31286
|
-
|
|
31287
|
-
});
|
|
31288
|
-
const baseRoundsCount = baseDrawRounds.length;
|
|
31289
|
-
let positionsFed = 0;
|
|
31290
|
-
|
|
31291
|
-
if (feedRoundsProfile.length) {
|
|
31292
|
-
positionsFed = feedRoundsProfile.reduce((a, b) => a + b, 0);
|
|
31293
|
-
} else if (drawSize) {
|
|
31294
|
-
// having a drawSize defined trumps other configuration options
|
|
31295
|
-
let positionsToFeed = drawSize - baseDrawSize;
|
|
31296
|
-
feedRoundsProfile = baseDrawRounds.filter(feedSize => {
|
|
31297
|
-
if (feedSize <= positionsToFeed) {
|
|
31298
|
-
positionsToFeed -= feedSize;
|
|
31299
|
-
return true;
|
|
31300
|
-
}
|
|
31301
|
-
|
|
31302
|
-
return false;
|
|
31303
|
-
});
|
|
31304
|
-
positionsFed = feedRoundsProfile.reduce((a, b) => a + b, 0);
|
|
31305
|
-
feedRounds = feedRoundsProfile.length;
|
|
31306
|
-
} else {
|
|
31307
|
-
// if skipRounds is set higher than baseRoundsCount then there are no feedRounds
|
|
31308
|
-
if (skipRounds >= baseRoundsCount) feedRounds = 0; // if feedsFromFinal is defined, calculate number of feed rounds from Final Match
|
|
31309
|
-
// e.g. feedsFromFinal is 1 for Semifinal, 2 for QuarterFinals, 3 for Round of 16
|
|
31310
|
-
|
|
31311
|
-
if (feedsFromFinal) {
|
|
31312
|
-
feedRounds = baseRoundsCount - feedsFromFinal;
|
|
31313
|
-
skipRounds = 0;
|
|
31314
|
-
} // Given the above, feedsFromFinal trumps skipRounds
|
|
31315
|
-
// and skipRounds >= baseRoundsCount negates feedRounds
|
|
31316
|
-
|
|
31317
|
-
|
|
31318
|
-
feedRoundsProfile = baseDrawRounds.filter((feedSize, i) => {
|
|
31319
|
-
if (feedsFromFinal && !feedRounds) return 0;
|
|
31320
|
-
if (feedRounds && i >= skipRounds + feedRounds) return 0;
|
|
31321
|
-
if (i < skipRounds) return 0;
|
|
31322
|
-
return feedSize;
|
|
31323
|
-
});
|
|
31324
|
-
positionsFed = feedRoundsProfile.reduce((a, b) => a + b, 0);
|
|
31325
|
-
drawSize = baseDrawSize + positionsFed;
|
|
31326
|
-
feedRounds = feedRoundsProfile.length;
|
|
31249
|
+
if (isNaN(drawSize) || !isPowerOf2(drawSize) || drawSize < 2) {
|
|
31250
|
+
return {
|
|
31251
|
+
matchUps: [],
|
|
31252
|
+
roundsCount: 0
|
|
31253
|
+
};
|
|
31327
31254
|
}
|
|
31328
31255
|
|
|
31329
|
-
const
|
|
31330
|
-
|
|
31331
|
-
|
|
31332
|
-
|
|
31333
|
-
|
|
31334
|
-
|
|
31335
|
-
|
|
31336
|
-
|
|
31337
|
-
|
|
31338
|
-
|
|
31339
|
-
|
|
31340
|
-
|
|
31341
|
-
|
|
31342
|
-
|
|
31343
|
-
|
|
31344
|
-
|
|
31345
|
-
|
|
31346
|
-
|
|
31347
|
-
|
|
31348
|
-
|
|
31349
|
-
const firstRoundDrawPositions = generateRange(0, baseDrawSize).map((x, i) => ({
|
|
31350
|
-
drawPosition: i + 1 + positionsFed
|
|
31351
|
-
})); // initial nodes fed into buildRound
|
|
31352
|
-
|
|
31353
|
-
let nodes = firstRoundDrawPositions; // drawPosition within structure; offset used for feedRounds
|
|
31256
|
+
const nodes = generateRange(1, parseInt(drawSize) + 1).map(drawPosition => ({
|
|
31257
|
+
drawPosition
|
|
31258
|
+
}));
|
|
31259
|
+
let roundNodes;
|
|
31260
|
+
let matchUps = [];
|
|
31261
|
+
let roundNumber = 1;
|
|
31262
|
+
({
|
|
31263
|
+
roundNodes,
|
|
31264
|
+
matchUps
|
|
31265
|
+
} = buildRound({
|
|
31266
|
+
roundNumber,
|
|
31267
|
+
matchUpType,
|
|
31268
|
+
idPrefix,
|
|
31269
|
+
matchUps,
|
|
31270
|
+
isMock,
|
|
31271
|
+
nodes,
|
|
31272
|
+
uuids
|
|
31273
|
+
}));
|
|
31274
|
+
roundNumber++;
|
|
31275
|
+
roundLimit = roundLimit || qualifyingRoundNumber;
|
|
31354
31276
|
|
|
31355
|
-
|
|
31277
|
+
while (roundNodes.length > 1) {
|
|
31278
|
+
if (qualifyingPositions && roundNodes.length === qualifyingPositions) {
|
|
31279
|
+
roundLimit = roundNumber - 1;
|
|
31280
|
+
}
|
|
31356
31281
|
|
|
31357
|
-
for (const baseDrawRound of baseDrawRounds) {
|
|
31358
31282
|
({
|
|
31359
31283
|
roundNodes,
|
|
31360
31284
|
matchUps
|
|
31361
31285
|
} = buildRound({
|
|
31286
|
+
nodes: roundNodes,
|
|
31362
31287
|
roundNumber,
|
|
31363
31288
|
matchUpType,
|
|
31364
31289
|
idPrefix,
|
|
31365
31290
|
matchUps,
|
|
31366
31291
|
isMock,
|
|
31367
|
-
nodes,
|
|
31368
31292
|
uuids
|
|
31369
31293
|
}));
|
|
31370
31294
|
roundNumber++;
|
|
31371
|
-
|
|
31372
|
-
if (feedRoundsProfile.includes(baseDrawRound)) {
|
|
31373
|
-
const roundIterations = instanceCount(feedRoundsProfile)[baseDrawRound];
|
|
31374
|
-
const iterationRange = generateRange(0, roundIterations);
|
|
31375
|
-
const finishingRoundNumber = roundsCount + 1 - roundNumber;
|
|
31376
|
-
const isLinkFedRound = linkFedFinishingRoundNumbers.includes(finishingRoundNumber) || linkFedRoundNumbers.includes(roundNumber);
|
|
31377
|
-
|
|
31378
|
-
for (const roundIteration of iterationRange) {
|
|
31379
|
-
const iterationDrawPosition = !isLinkFedRound && drawPosition || undefined;
|
|
31380
|
-
({
|
|
31381
|
-
roundNodes,
|
|
31382
|
-
matchUps,
|
|
31383
|
-
drawPosition
|
|
31384
|
-
} = buildFeedRound({
|
|
31385
|
-
drawPosition: iterationDrawPosition,
|
|
31386
|
-
nodes: roundNodes,
|
|
31387
|
-
roundIteration,
|
|
31388
|
-
// meaningless; avoids eslint value never used
|
|
31389
|
-
roundNumber,
|
|
31390
|
-
matchUpType,
|
|
31391
|
-
idPrefix,
|
|
31392
|
-
matchUps,
|
|
31393
|
-
uuids,
|
|
31394
|
-
fed
|
|
31395
|
-
}));
|
|
31396
|
-
roundNumber++;
|
|
31397
|
-
fed += 1;
|
|
31398
|
-
}
|
|
31399
|
-
}
|
|
31400
|
-
|
|
31401
|
-
nodes = roundNodes;
|
|
31402
31295
|
}
|
|
31403
31296
|
|
|
31404
|
-
|
|
31405
|
-
// ... by the number of drawPositions which will be fed into the consolation draw
|
|
31406
|
-
// final drawPositions will be played off twice up until the final feed round
|
|
31407
|
-
|
|
31408
|
-
const consolationFinish = baseDrawSize - positionsFed;
|
|
31409
|
-
const modifiedFinishingPositionOffset = isConsolation ? consolationFinish : finishingPositionOffset;
|
|
31297
|
+
const roundsCount = roundNumber - 1;
|
|
31410
31298
|
matchUps = addFinishingRounds({
|
|
31411
|
-
finishingPositionOffset
|
|
31412
|
-
positionsFed,
|
|
31299
|
+
finishingPositionOffset,
|
|
31413
31300
|
roundsCount,
|
|
31414
|
-
|
|
31415
|
-
|
|
31301
|
+
roundLimit,
|
|
31302
|
+
matchUps
|
|
31416
31303
|
});
|
|
31417
|
-
const draw = roundNodes && roundNodes.length ? roundNodes[0] : roundNodes;
|
|
31418
|
-
|
|
31419
|
-
if (draw) {
|
|
31420
|
-
draw.roundNumber = roundNumber - 1;
|
|
31421
|
-
draw.matchUps = matchUps;
|
|
31422
|
-
}
|
|
31423
|
-
|
|
31424
|
-
return {
|
|
31425
|
-
draw,
|
|
31426
|
-
matchUps,
|
|
31427
|
-
roundsCount
|
|
31428
|
-
};
|
|
31429
|
-
|
|
31430
|
-
function getBaseDrawSize(drawSize) {
|
|
31431
|
-
const nearestP2 = nearestPowerOf2(drawSize);
|
|
31432
|
-
return nearestP2 > drawSize ? nearestP2 / 2 : nearestP2;
|
|
31433
|
-
}
|
|
31434
|
-
}
|
|
31435
|
-
|
|
31436
|
-
function buildFeedRound({
|
|
31437
|
-
includeMatchUpType,
|
|
31438
|
-
drawPosition,
|
|
31439
|
-
matchUpType,
|
|
31440
|
-
roundNumber,
|
|
31441
|
-
idPrefix,
|
|
31442
|
-
matchUps,
|
|
31443
|
-
uuids,
|
|
31444
|
-
nodes,
|
|
31445
|
-
fed
|
|
31446
|
-
}) {
|
|
31447
|
-
const feedRoundMatchUpsCount = nodes.length;
|
|
31448
|
-
const initialGroupDrawPosition = drawPosition ? drawPosition - feedRoundMatchUpsCount : undefined;
|
|
31449
|
-
const drawPositionGroup = generateRange(0, feedRoundMatchUpsCount).map(value => initialGroupDrawPosition ? initialGroupDrawPosition + value : undefined);
|
|
31450
|
-
const roundNodes = [];
|
|
31451
|
-
|
|
31452
|
-
for (let nodeIndex = 0; nodeIndex < feedRoundMatchUpsCount; nodeIndex++) {
|
|
31453
|
-
const feedDrawPosition = drawPositionGroup.shift();
|
|
31454
|
-
const feedArm = {
|
|
31455
|
-
feed: true,
|
|
31456
|
-
fed: fed + 1,
|
|
31457
|
-
drawPosition: feedDrawPosition
|
|
31458
|
-
};
|
|
31459
|
-
const position = nodes[nodeIndex];
|
|
31460
|
-
position.roundNumber = roundNumber - 1;
|
|
31461
|
-
const matchUpId = getMatchUpId({
|
|
31462
|
-
roundPosition: position.roundPosition,
|
|
31463
|
-
roundNumber,
|
|
31464
|
-
idPrefix,
|
|
31465
|
-
uuids
|
|
31466
|
-
});
|
|
31467
|
-
const newMatchUp = {
|
|
31468
|
-
roundNumber,
|
|
31469
|
-
matchUpId,
|
|
31470
|
-
roundPosition: position.roundPosition,
|
|
31471
|
-
drawPositions: [undefined, feedDrawPosition]
|
|
31472
|
-
}; // matchUpType is derived for inContext matchUps from structure or drawDefinition
|
|
31473
31304
|
|
|
31474
|
-
|
|
31475
|
-
matchUps.
|
|
31476
|
-
const roundNode = {
|
|
31477
|
-
children: [position, feedArm]
|
|
31478
|
-
};
|
|
31479
|
-
roundNodes.push(roundNode);
|
|
31305
|
+
if (roundLimit) {
|
|
31306
|
+
matchUps = matchUps.filter(matchUp => matchUp.roundNumber <= roundLimit);
|
|
31480
31307
|
}
|
|
31481
31308
|
|
|
31482
|
-
const nextDrawPosition = drawPosition ? drawPosition - feedRoundMatchUpsCount : undefined;
|
|
31483
31309
|
return {
|
|
31484
|
-
roundNodes,
|
|
31485
31310
|
matchUps,
|
|
31486
|
-
|
|
31311
|
+
roundsCount,
|
|
31312
|
+
roundLimit
|
|
31487
31313
|
};
|
|
31488
31314
|
}
|
|
31489
|
-
|
|
31490
|
-
function
|
|
31491
|
-
|
|
31492
|
-
|
|
31493
|
-
|
|
31494
|
-
|
|
31495
|
-
|
|
31496
|
-
|
|
31315
|
+
/*
|
|
31316
|
+
export function feedDrawSize({ opponentCount }) {
|
|
31317
|
+
const baseRanges = generateRange(0, 10).map((i) => {
|
|
31318
|
+
const positionsBase = Math.pow(2, i);
|
|
31319
|
+
const feedPositions = positionsBase - 1;
|
|
31320
|
+
const maxByes = positionsBase / 2 - 1;
|
|
31321
|
+
const maxPositions = positionsBase + feedPositions;
|
|
31322
|
+
const positionRange = { positionsBase, maxPositions, maxByes };
|
|
31323
|
+
return positionRange;
|
|
31324
|
+
});
|
|
31325
|
+
const positionsBase = baseRanges.reduce((p, c) => {
|
|
31326
|
+
return opponentCount >= c.positionsBase && opponentCount <= c.maxPositions
|
|
31327
|
+
? c
|
|
31328
|
+
: p;
|
|
31329
|
+
}, undefined);
|
|
31330
|
+
return positionsBase;
|
|
31497
31331
|
}
|
|
31332
|
+
*/
|
|
31498
31333
|
|
|
31499
31334
|
function generateVoluntaryConsolationStructure$1({
|
|
31500
31335
|
structureName = VOLUNTARY_CONSOLATION,
|
|
@@ -32576,6 +32411,239 @@ function generateTieMatchUps({
|
|
|
32576
32411
|
};
|
|
32577
32412
|
}
|
|
32578
32413
|
|
|
32414
|
+
function buildFeedRound({
|
|
32415
|
+
includeMatchUpType,
|
|
32416
|
+
drawPosition,
|
|
32417
|
+
matchUpType,
|
|
32418
|
+
roundNumber,
|
|
32419
|
+
idPrefix,
|
|
32420
|
+
matchUps,
|
|
32421
|
+
uuids,
|
|
32422
|
+
nodes,
|
|
32423
|
+
fed
|
|
32424
|
+
}) {
|
|
32425
|
+
const feedRoundMatchUpsCount = nodes.length;
|
|
32426
|
+
const initialGroupDrawPosition = drawPosition ? drawPosition - feedRoundMatchUpsCount : undefined;
|
|
32427
|
+
const drawPositionGroup = generateRange(0, feedRoundMatchUpsCount).map(value => initialGroupDrawPosition ? initialGroupDrawPosition + value : undefined);
|
|
32428
|
+
const roundNodes = [];
|
|
32429
|
+
|
|
32430
|
+
for (let nodeIndex = 0; nodeIndex < feedRoundMatchUpsCount; nodeIndex++) {
|
|
32431
|
+
const feedDrawPosition = drawPositionGroup.shift();
|
|
32432
|
+
const feedArm = {
|
|
32433
|
+
feed: true,
|
|
32434
|
+
fed: fed + 1,
|
|
32435
|
+
drawPosition: feedDrawPosition
|
|
32436
|
+
};
|
|
32437
|
+
const position = nodes[nodeIndex];
|
|
32438
|
+
position.roundNumber = roundNumber - 1;
|
|
32439
|
+
const matchUpId = generateMatchUpId({
|
|
32440
|
+
roundPosition: position.roundPosition,
|
|
32441
|
+
roundNumber,
|
|
32442
|
+
idPrefix,
|
|
32443
|
+
uuids
|
|
32444
|
+
});
|
|
32445
|
+
const newMatchUp = {
|
|
32446
|
+
roundNumber,
|
|
32447
|
+
matchUpId,
|
|
32448
|
+
roundPosition: position.roundPosition,
|
|
32449
|
+
drawPositions: [undefined, feedDrawPosition]
|
|
32450
|
+
}; // matchUpType is derived for inContext matchUps from structure or drawDefinition
|
|
32451
|
+
|
|
32452
|
+
if (includeMatchUpType) newMatchUp.matchUpType = matchUpType;
|
|
32453
|
+
matchUps.push(newMatchUp);
|
|
32454
|
+
const roundNode = {
|
|
32455
|
+
children: [position, feedArm]
|
|
32456
|
+
};
|
|
32457
|
+
roundNodes.push(roundNode);
|
|
32458
|
+
}
|
|
32459
|
+
|
|
32460
|
+
const nextDrawPosition = drawPosition ? drawPosition - feedRoundMatchUpsCount : undefined;
|
|
32461
|
+
return {
|
|
32462
|
+
roundNodes,
|
|
32463
|
+
matchUps,
|
|
32464
|
+
drawPosition: nextDrawPosition
|
|
32465
|
+
};
|
|
32466
|
+
}
|
|
32467
|
+
|
|
32468
|
+
function feedInMatchUps({
|
|
32469
|
+
linkFedFinishingRoundNumbers = [],
|
|
32470
|
+
linkFedRoundNumbers = [],
|
|
32471
|
+
finishingPositionOffset,
|
|
32472
|
+
feedRoundsProfile = [],
|
|
32473
|
+
feedRounds = 0,
|
|
32474
|
+
skipRounds = 0,
|
|
32475
|
+
feedsFromFinal,
|
|
32476
|
+
isConsolation,
|
|
32477
|
+
baseDrawSize,
|
|
32478
|
+
matchUpType,
|
|
32479
|
+
idPrefix,
|
|
32480
|
+
drawSize,
|
|
32481
|
+
isMock,
|
|
32482
|
+
uuids,
|
|
32483
|
+
fmlc
|
|
32484
|
+
}) {
|
|
32485
|
+
// calculate the number of rounds and the number of matchUps in each round
|
|
32486
|
+
// for normal elimination structure
|
|
32487
|
+
baseDrawSize = baseDrawSize || getBaseDrawSize(drawSize);
|
|
32488
|
+
const baseDrawRounds = roundMatchCounts({
|
|
32489
|
+
drawSize: baseDrawSize
|
|
32490
|
+
});
|
|
32491
|
+
const baseRoundsCount = baseDrawRounds.length;
|
|
32492
|
+
let positionsFed = 0;
|
|
32493
|
+
|
|
32494
|
+
if (feedRoundsProfile.length) {
|
|
32495
|
+
positionsFed = feedRoundsProfile.reduce((a, b) => a + b, 0);
|
|
32496
|
+
} else if (drawSize) {
|
|
32497
|
+
// having a drawSize defined trumps other configuration options
|
|
32498
|
+
let positionsToFeed = drawSize - baseDrawSize;
|
|
32499
|
+
feedRoundsProfile = baseDrawRounds.filter(feedSize => {
|
|
32500
|
+
if (feedSize <= positionsToFeed) {
|
|
32501
|
+
positionsToFeed -= feedSize;
|
|
32502
|
+
return true;
|
|
32503
|
+
}
|
|
32504
|
+
|
|
32505
|
+
return false;
|
|
32506
|
+
});
|
|
32507
|
+
positionsFed = feedRoundsProfile.reduce((a, b) => a + b, 0);
|
|
32508
|
+
feedRounds = feedRoundsProfile.length;
|
|
32509
|
+
} else {
|
|
32510
|
+
// if skipRounds is set higher than baseRoundsCount then there are no feedRounds
|
|
32511
|
+
if (skipRounds >= baseRoundsCount) feedRounds = 0; // if feedsFromFinal is defined, calculate number of feed rounds from Final Match
|
|
32512
|
+
// e.g. feedsFromFinal is 1 for Semifinal, 2 for QuarterFinals, 3 for Round of 16
|
|
32513
|
+
|
|
32514
|
+
if (feedsFromFinal) {
|
|
32515
|
+
feedRounds = baseRoundsCount - feedsFromFinal;
|
|
32516
|
+
skipRounds = 0;
|
|
32517
|
+
} // Given the above, feedsFromFinal trumps skipRounds
|
|
32518
|
+
// and skipRounds >= baseRoundsCount negates feedRounds
|
|
32519
|
+
|
|
32520
|
+
|
|
32521
|
+
feedRoundsProfile = baseDrawRounds.filter((feedSize, i) => {
|
|
32522
|
+
if (feedsFromFinal && !feedRounds) return 0;
|
|
32523
|
+
if (feedRounds && i >= skipRounds + feedRounds) return 0;
|
|
32524
|
+
if (i < skipRounds) return 0;
|
|
32525
|
+
return feedSize;
|
|
32526
|
+
});
|
|
32527
|
+
positionsFed = feedRoundsProfile.reduce((a, b) => a + b, 0);
|
|
32528
|
+
drawSize = baseDrawSize + positionsFed;
|
|
32529
|
+
feedRounds = feedRoundsProfile.length;
|
|
32530
|
+
}
|
|
32531
|
+
|
|
32532
|
+
const allRounds = [...baseDrawRounds, ...feedRoundsProfile].sort((a, b) => b - a);
|
|
32533
|
+
const roundsCount = allRounds.length; // rounds which have linkFed participants can be specified two ways:
|
|
32534
|
+
// linkFedRoundNumbers[] and linkFedFinishingRoundNumbers[]
|
|
32535
|
+
// the difference being which end of the draw structure === 1
|
|
32536
|
+
|
|
32537
|
+
const linkFedRoundNumbersIndices = [...linkFedRoundNumbers.map(n => n - 1), ...linkFedFinishingRoundNumbers.map(n => roundsCount - n)]; // positionsFedByLinks can be determined by summing the values in allRounds
|
|
32538
|
+
// which are found at linkFedRoundNumbersIndices
|
|
32539
|
+
|
|
32540
|
+
const positionsFedByLinks = linkFedRoundNumbersIndices.map(i => allRounds[i]).reduce((a, b) => a + b, 0);
|
|
32541
|
+
positionsFed = positionsFed - positionsFedByLinks; // initialize round creation variables
|
|
32542
|
+
|
|
32543
|
+
let fed = 0; // keep track of even/odd feed rounds
|
|
32544
|
+
|
|
32545
|
+
let matchUps = []; // accumulate matchUps
|
|
32546
|
+
|
|
32547
|
+
let roundNodes; // an array of nodes
|
|
32548
|
+
|
|
32549
|
+
let roundNumber = 1; // initial roundNumber
|
|
32550
|
+
// firstRoundDrawPositions are generated and assigned drawPositions
|
|
32551
|
+
|
|
32552
|
+
const firstRoundDrawPositions = generateRange(0, baseDrawSize).map((x, i) => ({
|
|
32553
|
+
drawPosition: i + 1 + positionsFed
|
|
32554
|
+
})); // initial nodes fed into buildRound
|
|
32555
|
+
|
|
32556
|
+
let nodes = firstRoundDrawPositions; // drawPosition within structure; offset used for feedRounds
|
|
32557
|
+
|
|
32558
|
+
let drawPosition = positionsFed + 1;
|
|
32559
|
+
|
|
32560
|
+
for (const baseDrawRound of baseDrawRounds) {
|
|
32561
|
+
({
|
|
32562
|
+
roundNodes,
|
|
32563
|
+
matchUps
|
|
32564
|
+
} = buildRound({
|
|
32565
|
+
roundNumber,
|
|
32566
|
+
matchUpType,
|
|
32567
|
+
idPrefix,
|
|
32568
|
+
matchUps,
|
|
32569
|
+
isMock,
|
|
32570
|
+
nodes,
|
|
32571
|
+
uuids
|
|
32572
|
+
}));
|
|
32573
|
+
roundNumber++;
|
|
32574
|
+
|
|
32575
|
+
if (feedRoundsProfile.includes(baseDrawRound)) {
|
|
32576
|
+
const roundIterations = instanceCount(feedRoundsProfile)[baseDrawRound];
|
|
32577
|
+
const iterationRange = generateRange(0, roundIterations);
|
|
32578
|
+
const finishingRoundNumber = roundsCount + 1 - roundNumber;
|
|
32579
|
+
const isLinkFedRound = linkFedFinishingRoundNumbers.includes(finishingRoundNumber) || linkFedRoundNumbers.includes(roundNumber);
|
|
32580
|
+
|
|
32581
|
+
for (const roundIteration of iterationRange) {
|
|
32582
|
+
const iterationDrawPosition = !isLinkFedRound && drawPosition || undefined;
|
|
32583
|
+
({
|
|
32584
|
+
roundNodes,
|
|
32585
|
+
matchUps,
|
|
32586
|
+
drawPosition
|
|
32587
|
+
} = buildFeedRound({
|
|
32588
|
+
drawPosition: iterationDrawPosition,
|
|
32589
|
+
nodes: roundNodes,
|
|
32590
|
+
roundIteration,
|
|
32591
|
+
// meaningless; avoids eslint value never used
|
|
32592
|
+
roundNumber,
|
|
32593
|
+
matchUpType,
|
|
32594
|
+
idPrefix,
|
|
32595
|
+
matchUps,
|
|
32596
|
+
uuids,
|
|
32597
|
+
fed
|
|
32598
|
+
}));
|
|
32599
|
+
roundNumber++;
|
|
32600
|
+
fed += 1;
|
|
32601
|
+
}
|
|
32602
|
+
}
|
|
32603
|
+
|
|
32604
|
+
nodes = roundNodes;
|
|
32605
|
+
}
|
|
32606
|
+
|
|
32607
|
+
if (roundsCount !== roundNumber - 1) console.log('ERROR'); // if this is a feed-in consolation then finishing drawPositions must be offset ...
|
|
32608
|
+
// ... by the number of drawPositions which will be fed into the consolation draw
|
|
32609
|
+
// final drawPositions will be played off twice up until the final feed round
|
|
32610
|
+
|
|
32611
|
+
const consolationFinish = baseDrawSize - positionsFed;
|
|
32612
|
+
const modifiedFinishingPositionOffset = isConsolation ? consolationFinish : finishingPositionOffset;
|
|
32613
|
+
matchUps = addFinishingRounds({
|
|
32614
|
+
finishingPositionOffset: modifiedFinishingPositionOffset,
|
|
32615
|
+
positionsFed,
|
|
32616
|
+
roundsCount,
|
|
32617
|
+
matchUps,
|
|
32618
|
+
fmlc
|
|
32619
|
+
});
|
|
32620
|
+
const draw = roundNodes && roundNodes.length ? roundNodes[0] : roundNodes;
|
|
32621
|
+
|
|
32622
|
+
if (draw) {
|
|
32623
|
+
draw.roundNumber = roundNumber - 1;
|
|
32624
|
+
draw.matchUps = matchUps;
|
|
32625
|
+
}
|
|
32626
|
+
|
|
32627
|
+
return {
|
|
32628
|
+
draw,
|
|
32629
|
+
matchUps,
|
|
32630
|
+
roundsCount
|
|
32631
|
+
};
|
|
32632
|
+
|
|
32633
|
+
function getBaseDrawSize(drawSize) {
|
|
32634
|
+
const nearestP2 = nearestPowerOf2(drawSize);
|
|
32635
|
+
return nearestP2 > drawSize ? nearestP2 / 2 : nearestP2;
|
|
32636
|
+
}
|
|
32637
|
+
} // returns an array of the number of matchUps in each round of an elimination draw
|
|
32638
|
+
|
|
32639
|
+
function roundMatchCounts({
|
|
32640
|
+
drawSize
|
|
32641
|
+
}) {
|
|
32642
|
+
const rounds = Math.ceil(Math.log(drawSize) / Math.log(2));
|
|
32643
|
+
const range = generateRange(0, rounds).reverse();
|
|
32644
|
+
return range.map(r => Math.pow(2, r));
|
|
32645
|
+
}
|
|
32646
|
+
|
|
32579
32647
|
function playoff(params) {
|
|
32580
32648
|
const {
|
|
32581
32649
|
structure,
|
|
@@ -32875,7 +32943,7 @@ function addPlayoffStructures$1(params) {
|
|
|
32875
32943
|
});
|
|
32876
32944
|
const addedMatchUpIds = inContextDrawMatchUps.filter(({
|
|
32877
32945
|
structureId
|
|
32878
|
-
}) => newStructureIds.includes(structureId)).map(getMatchUpId
|
|
32946
|
+
}) => newStructureIds.includes(structureId)).map(getMatchUpId);
|
|
32879
32947
|
const addedMatchUps = matchUpsMap === null || matchUpsMap === void 0 ? void 0 : (_matchUpsMap$drawMatc = matchUpsMap.drawMatchUps) === null || _matchUpsMap$drawMatc === void 0 ? void 0 : _matchUpsMap$drawMatc.filter(({
|
|
32880
32948
|
matchUpId
|
|
32881
32949
|
}) => addedMatchUpIds.includes(matchUpId));
|
|
@@ -33642,6 +33710,120 @@ function feedInChampionship(params = {}) {
|
|
|
33642
33710
|
});
|
|
33643
33711
|
}
|
|
33644
33712
|
|
|
33713
|
+
function luckyDraw(params) {
|
|
33714
|
+
const {
|
|
33715
|
+
qualifyingRoundNumber,
|
|
33716
|
+
// round at which participants qualify
|
|
33717
|
+
finishingPositionOffset,
|
|
33718
|
+
qualifyingPositions,
|
|
33719
|
+
// number of positions which qualify
|
|
33720
|
+
matchUpType,
|
|
33721
|
+
idPrefix,
|
|
33722
|
+
drawSize,
|
|
33723
|
+
isMock,
|
|
33724
|
+
uuids
|
|
33725
|
+
} = params;
|
|
33726
|
+
|
|
33727
|
+
if (!isConvertableInteger(drawSize) || drawSize < 2) {
|
|
33728
|
+
return {
|
|
33729
|
+
matchUps: [],
|
|
33730
|
+
roundsCount: 0
|
|
33731
|
+
};
|
|
33732
|
+
}
|
|
33733
|
+
|
|
33734
|
+
if (isPowerOf2(drawSize)) return treeMatchUps(params);
|
|
33735
|
+
const roundProfiles = luckyRoundProfiles(drawSize);
|
|
33736
|
+
const firstRound = roundProfiles.shift();
|
|
33737
|
+
const nodes = generateRange(1, firstRound.participantsCount + 1).map(drawPosition => ({
|
|
33738
|
+
drawPosition
|
|
33739
|
+
}));
|
|
33740
|
+
let matchUps = [];
|
|
33741
|
+
let roundNumber = 1;
|
|
33742
|
+
({
|
|
33743
|
+
matchUps
|
|
33744
|
+
} = buildRound({
|
|
33745
|
+
roundNumber,
|
|
33746
|
+
matchUpType,
|
|
33747
|
+
idPrefix,
|
|
33748
|
+
matchUps,
|
|
33749
|
+
isMock,
|
|
33750
|
+
nodes,
|
|
33751
|
+
uuids
|
|
33752
|
+
}));
|
|
33753
|
+
roundNumber++;
|
|
33754
|
+
let roundLimit = params.roundLimit || qualifyingRoundNumber;
|
|
33755
|
+
|
|
33756
|
+
for (const roundProfile of roundProfiles) {
|
|
33757
|
+
const roundMatchUpsCount = roundProfile.participantsCount / 2;
|
|
33758
|
+
const roundPositionRange = generateRange(1, roundMatchUpsCount + 1);
|
|
33759
|
+
|
|
33760
|
+
if (qualifyingPositions && roundMatchUpsCount === qualifyingPositions) {
|
|
33761
|
+
roundLimit = roundNumber - 1;
|
|
33762
|
+
}
|
|
33763
|
+
|
|
33764
|
+
const roundMatchUps = roundPositionRange.map(roundPosition => {
|
|
33765
|
+
const matchUpId = generateMatchUpId({
|
|
33766
|
+
roundPosition: roundPosition,
|
|
33767
|
+
roundNumber,
|
|
33768
|
+
idPrefix,
|
|
33769
|
+
uuids
|
|
33770
|
+
});
|
|
33771
|
+
const newMatchUp = {
|
|
33772
|
+
roundPosition,
|
|
33773
|
+
roundNumber,
|
|
33774
|
+
matchUpId
|
|
33775
|
+
};
|
|
33776
|
+
return newMatchUp;
|
|
33777
|
+
});
|
|
33778
|
+
matchUps.push(...roundMatchUps);
|
|
33779
|
+
roundNumber++;
|
|
33780
|
+
}
|
|
33781
|
+
|
|
33782
|
+
const roundsCount = roundNumber - 1;
|
|
33783
|
+
matchUps = addFinishingRounds({
|
|
33784
|
+
finishingPositionOffset,
|
|
33785
|
+
lucky: true,
|
|
33786
|
+
roundsCount,
|
|
33787
|
+
roundLimit,
|
|
33788
|
+
matchUps
|
|
33789
|
+
});
|
|
33790
|
+
|
|
33791
|
+
if (roundLimit) {
|
|
33792
|
+
matchUps = matchUps.filter(matchUp => matchUp.roundNumber <= roundLimit);
|
|
33793
|
+
}
|
|
33794
|
+
|
|
33795
|
+
return {
|
|
33796
|
+
matchUps,
|
|
33797
|
+
roundsCount,
|
|
33798
|
+
roundLimit
|
|
33799
|
+
};
|
|
33800
|
+
}
|
|
33801
|
+
|
|
33802
|
+
function luckyRoundProfiles(drawSize) {
|
|
33803
|
+
const intDrawSize = parseInt(drawSize);
|
|
33804
|
+
let participantsCount = intDrawSize % 2 ? intDrawSize + 1 : intDrawSize;
|
|
33805
|
+
const preFeedRound = !!(Math.ceil(participantsCount / 2) % 2);
|
|
33806
|
+
const rounds = [{
|
|
33807
|
+
participantsCount,
|
|
33808
|
+
preFeedRound
|
|
33809
|
+
}];
|
|
33810
|
+
|
|
33811
|
+
while (participantsCount > 2) {
|
|
33812
|
+
const nextRound = Math.ceil(participantsCount / 2);
|
|
33813
|
+
const nextIsFinal = nextRound === 1;
|
|
33814
|
+
const feedRound = !!(!nextIsFinal && nextRound % 2);
|
|
33815
|
+
participantsCount = !nextIsFinal && feedRound ? nextRound + 1 : nextRound;
|
|
33816
|
+
const preFeedRound = !!(participantsCount !== 2 && Math.ceil(participantsCount / 2) % 2);
|
|
33817
|
+
rounds.push({
|
|
33818
|
+
participantsCount,
|
|
33819
|
+
preFeedRound,
|
|
33820
|
+
feedRound
|
|
33821
|
+
});
|
|
33822
|
+
}
|
|
33823
|
+
|
|
33824
|
+
return rounds;
|
|
33825
|
+
}
|
|
33826
|
+
|
|
33645
33827
|
function generateRoundRobin({
|
|
33646
33828
|
structureName = MAIN,
|
|
33647
33829
|
stageSequence = 1,
|
|
@@ -34069,7 +34251,7 @@ function generateDrawType(params = {}) {
|
|
|
34069
34251
|
}));
|
|
34070
34252
|
const validDoubleEliminationSize = isPowerOf2(drawSize * 2 / 3); // check that drawSize is a valid value
|
|
34071
34253
|
|
|
34072
|
-
const invalidDrawSize = drawSize < 2 || !staggeredEntry && ![FEED_IN$1, AD_HOC].includes(drawType) && (drawType === ROUND_ROBIN && drawSize < 3 || drawType === DOUBLE_ELIMINATION && !validDoubleEliminationSize || ![ROUND_ROBIN, DOUBLE_ELIMINATION, ROUND_ROBIN_WITH_PLAYOFF].includes(drawType) && !isPowerOf2(drawSize));
|
|
34254
|
+
const invalidDrawSize = drawSize < 2 || !staggeredEntry && ![FEED_IN$1, AD_HOC, LUCKY_DRAW].includes(drawType) && (drawType === ROUND_ROBIN && drawSize < 3 || drawType === DOUBLE_ELIMINATION && !validDoubleEliminationSize || ![ROUND_ROBIN, DOUBLE_ELIMINATION, ROUND_ROBIN_WITH_PLAYOFF].includes(drawType) && !isPowerOf2(drawSize));
|
|
34073
34255
|
|
|
34074
34256
|
if (invalidDrawSize) {
|
|
34075
34257
|
return {
|
|
@@ -34115,6 +34297,23 @@ function generateDrawType(params = {}) {
|
|
|
34115
34297
|
structures: [structure]
|
|
34116
34298
|
}, SUCCESS);
|
|
34117
34299
|
},
|
|
34300
|
+
[LUCKY_DRAW]: () => {
|
|
34301
|
+
const {
|
|
34302
|
+
matchUps
|
|
34303
|
+
} = luckyDraw(params);
|
|
34304
|
+
const structure = structureTemplate({
|
|
34305
|
+
structureName: structureName || MAIN,
|
|
34306
|
+
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
34307
|
+
stageSequence,
|
|
34308
|
+
matchUpType,
|
|
34309
|
+
stage: MAIN,
|
|
34310
|
+
matchUps
|
|
34311
|
+
});
|
|
34312
|
+
drawDefinition.structures.push(structure);
|
|
34313
|
+
return Object.assign({
|
|
34314
|
+
structures: [structure]
|
|
34315
|
+
}, SUCCESS);
|
|
34316
|
+
},
|
|
34118
34317
|
[SINGLE_ELIMINATION]: () => {
|
|
34119
34318
|
const {
|
|
34120
34319
|
matchUps
|
|
@@ -37077,8 +37276,8 @@ function setOrderOfFinish$1({
|
|
|
37077
37276
|
inContext: true,
|
|
37078
37277
|
drawDefinition
|
|
37079
37278
|
});
|
|
37080
|
-
const matchUpIds = completedMatchUps.map(getMatchUpId
|
|
37081
|
-
const targetMatchUpIds = finishingOrder.map(getMatchUpId
|
|
37279
|
+
const matchUpIds = completedMatchUps.map(getMatchUpId);
|
|
37280
|
+
const targetMatchUpIds = finishingOrder.map(getMatchUpId);
|
|
37082
37281
|
const {
|
|
37083
37282
|
matchUpTypes,
|
|
37084
37283
|
roundNumbers,
|
|
@@ -39358,8 +39557,8 @@ function setParticipantScaleItem({
|
|
|
39358
39557
|
};
|
|
39359
39558
|
}
|
|
39360
39559
|
function setParticipantScaleItems({
|
|
39361
|
-
|
|
39362
|
-
|
|
39560
|
+
scaleItemsWithParticipantIds = [],
|
|
39561
|
+
tournamentRecord
|
|
39363
39562
|
}) {
|
|
39364
39563
|
if (!tournamentRecord) return {
|
|
39365
39564
|
error: MISSING_TOURNAMENT_RECORD
|
|
@@ -40326,9 +40525,10 @@ function modifyIndividualParticipantIds({
|
|
|
40326
40525
|
*/
|
|
40327
40526
|
|
|
40328
40527
|
function generateTeamsFromParticipantAttribute({
|
|
40329
|
-
tournamentRecord,
|
|
40330
40528
|
participantAttribute,
|
|
40529
|
+
tournamentRecord,
|
|
40331
40530
|
personAttribute,
|
|
40531
|
+
teamNames,
|
|
40332
40532
|
accessor,
|
|
40333
40533
|
uuids
|
|
40334
40534
|
}) {
|
|
@@ -40340,6 +40540,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
40340
40540
|
participantType,
|
|
40341
40541
|
participantRole
|
|
40342
40542
|
}) => participantType === INDIVIDUAL$1 && participantRole === COMPETITOR);
|
|
40543
|
+
let teamIndex = 0;
|
|
40343
40544
|
|
|
40344
40545
|
for (const individualParticipant of individualParticipants) {
|
|
40345
40546
|
const {
|
|
@@ -40353,7 +40554,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
40353
40554
|
if (attributeValue) {
|
|
40354
40555
|
if (!Object.keys(teams).includes(attributeValue)) {
|
|
40355
40556
|
teams[attributeValue] = {
|
|
40356
|
-
participantName: attributeValue,
|
|
40557
|
+
participantName: (teamNames === null || teamNames === void 0 ? void 0 : teamNames[teamIndex]) || attributeValue,
|
|
40357
40558
|
participantId: (uuids === null || uuids === void 0 ? void 0 : uuids.pop()) || UUID(),
|
|
40358
40559
|
participantType: TEAM$1,
|
|
40359
40560
|
participantRole: COMPETITOR,
|
|
@@ -40367,6 +40568,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
40367
40568
|
element: teams[attributeValue],
|
|
40368
40569
|
extension
|
|
40369
40570
|
});
|
|
40571
|
+
teamIndex += 1;
|
|
40370
40572
|
}
|
|
40371
40573
|
|
|
40372
40574
|
teams[attributeValue].individualParticipantIds.push(individualParticipant.participantId);
|
|
@@ -40781,17 +40983,21 @@ function modifyParticipant({
|
|
|
40781
40983
|
});
|
|
40782
40984
|
const {
|
|
40783
40985
|
individualParticipantIds,
|
|
40986
|
+
participantOtherName,
|
|
40784
40987
|
participantName,
|
|
40785
40988
|
participantRole,
|
|
40786
40989
|
participantType,
|
|
40787
40990
|
onlineProfiles,
|
|
40788
40991
|
// TODO: validate onlineProfiles
|
|
40992
|
+
contacts,
|
|
40789
40993
|
person
|
|
40790
40994
|
} = participant;
|
|
40791
40995
|
const newValues = {}; // validate participant attributes
|
|
40792
40996
|
|
|
40997
|
+
if (contacts) newValues.contacts = contacts;
|
|
40793
40998
|
if (onlineProfiles) newValues.onlineProfiles = onlineProfiles;
|
|
40794
40999
|
if (participantName && typeof participantName === 'string') newValues.participantName = participantName;
|
|
41000
|
+
if (participantOtherName && typeof participantOtherName === 'string') newValues.participantOtherName = participantOtherName;
|
|
40795
41001
|
|
|
40796
41002
|
if (Array.isArray(individualParticipantIds)) {
|
|
40797
41003
|
const {
|
|
@@ -40834,7 +41040,7 @@ function modifyParticipant({
|
|
|
40834
41040
|
});
|
|
40835
41041
|
}
|
|
40836
41042
|
|
|
40837
|
-
Object.assign(existingParticipant, newValues);
|
|
41043
|
+
Object.assign(existingParticipant, definedAttributes(newValues));
|
|
40838
41044
|
|
|
40839
41045
|
if (groupingParticipantId) {
|
|
40840
41046
|
addIndividualParticipantIds({
|
|
@@ -44942,11 +45148,11 @@ function removeDelegatedOutcome(params) {
|
|
|
44942
45148
|
}
|
|
44943
45149
|
|
|
44944
45150
|
function generateSeedingScaleItems({
|
|
45151
|
+
scaleAttributes,
|
|
44945
45152
|
scaledEntries,
|
|
45153
|
+
stageEntries,
|
|
44946
45154
|
seedsCount,
|
|
44947
|
-
|
|
44948
|
-
scaleName,
|
|
44949
|
-
stageEntries
|
|
45155
|
+
scaleName
|
|
44950
45156
|
}) {
|
|
44951
45157
|
if (!scaleAttributes) return {
|
|
44952
45158
|
error: MISSING_VALUE
|
|
@@ -50268,7 +50474,7 @@ function completeDrawMatchUps({
|
|
|
50268
50474
|
});
|
|
50269
50475
|
const sortedMatchUpIds = matchUps.filter(({
|
|
50270
50476
|
winningSide
|
|
50271
|
-
}) => !winningSide).sort(matchUpSort).map(getMatchUpId
|
|
50477
|
+
}) => !winningSide).sort(matchUpSort).map(getMatchUpId);
|
|
50272
50478
|
|
|
50273
50479
|
for (const matchUpId of sortedMatchUpIds) {
|
|
50274
50480
|
if (!isNaN(completionGoal) && completedCount >= completionGoal) break;
|
|
@@ -51967,7 +52173,8 @@ function modifyTournamentRecord({
|
|
|
51967
52173
|
eventType
|
|
51968
52174
|
} = event;
|
|
51969
52175
|
const {
|
|
51970
|
-
drawProfiles
|
|
52176
|
+
drawProfiles,
|
|
52177
|
+
publish
|
|
51971
52178
|
} = eventProfile;
|
|
51972
52179
|
const eventParticipantType = eventType === SINGLES ? INDIVIDUAL : eventType === DOUBLES ? PAIR : eventType;
|
|
51973
52180
|
|
|
@@ -52028,6 +52235,13 @@ function modifyTournamentRecord({
|
|
|
52028
52235
|
if (result.error) return result;
|
|
52029
52236
|
drawIds.push(...result.drawIds);
|
|
52030
52237
|
}
|
|
52238
|
+
|
|
52239
|
+
if (publish) {
|
|
52240
|
+
publishEvent({
|
|
52241
|
+
tournamentRecord,
|
|
52242
|
+
event
|
|
52243
|
+
});
|
|
52244
|
+
}
|
|
52031
52245
|
}
|
|
52032
52246
|
}
|
|
52033
52247
|
}
|