tods-competition-factory 0.232.0 → 0.233.0
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 +102 -6
- 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 +1 -1
|
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
function factoryVersion() {
|
|
252
|
-
return '0.
|
|
252
|
+
return '0.233.0';
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
function decorateResult({
|
|
@@ -10406,6 +10406,7 @@ function deleteMatchUpsNotice({
|
|
|
10406
10406
|
function modifyMatchUpNotice({
|
|
10407
10407
|
drawDefinition,
|
|
10408
10408
|
tournamentId,
|
|
10409
|
+
structureId,
|
|
10409
10410
|
eventId,
|
|
10410
10411
|
matchUp
|
|
10411
10412
|
}) {
|
|
@@ -10416,7 +10417,7 @@ function modifyMatchUpNotice({
|
|
|
10416
10417
|
};
|
|
10417
10418
|
}
|
|
10418
10419
|
|
|
10419
|
-
|
|
10420
|
+
structureId = structureId || matchUp.structureId;
|
|
10420
10421
|
modifyDrawNotice({
|
|
10421
10422
|
structureIds: [structureId],
|
|
10422
10423
|
drawDefinition,
|
|
@@ -14545,6 +14546,8 @@ function generateTieMatchUps({
|
|
|
14545
14546
|
}
|
|
14546
14547
|
function generateCollectionMatchUps({
|
|
14547
14548
|
collectionDefinition,
|
|
14549
|
+
matchUpsLimit,
|
|
14550
|
+
// internal use allows generation of missing matchUps on "reset"
|
|
14548
14551
|
isMock,
|
|
14549
14552
|
uuids
|
|
14550
14553
|
}) {
|
|
@@ -14553,7 +14556,7 @@ function generateCollectionMatchUps({
|
|
|
14553
14556
|
matchUpType,
|
|
14554
14557
|
collectionId
|
|
14555
14558
|
} = collectionDefinition || {};
|
|
14556
|
-
const matchUps = generateRange(0, matchUpCount || 0).map(index => {
|
|
14559
|
+
const matchUps = generateRange(0, matchUpsLimit || matchUpCount || 0).map(index => {
|
|
14557
14560
|
const collectionPosition = index + 1;
|
|
14558
14561
|
const matchUp = {
|
|
14559
14562
|
sides: [{
|
|
@@ -54589,13 +54592,17 @@ function resetScorecard(params) {
|
|
|
54589
54592
|
* remove the tieFormat from a TEAM matchUp if there is a tieFormat further up the hierarchy
|
|
54590
54593
|
* modify the matchUp's tieMatchUps to correspond to the tieFormat found further up the hierarchy
|
|
54591
54594
|
*
|
|
54592
|
-
* @param {
|
|
54595
|
+
* @param {string} matchUpId
|
|
54596
|
+
* @param {string} drawId
|
|
54593
54597
|
* @returns
|
|
54594
54598
|
*/
|
|
54595
54599
|
|
|
54596
54600
|
function resetTieFormat({
|
|
54597
54601
|
tournamentRecord,
|
|
54598
|
-
|
|
54602
|
+
drawDefinition,
|
|
54603
|
+
matchUpId,
|
|
54604
|
+
event,
|
|
54605
|
+
uuids
|
|
54599
54606
|
}) {
|
|
54600
54607
|
if (!tournamentRecord) return {
|
|
54601
54608
|
error: MISSING_TOURNAMENT_RECORD
|
|
@@ -54603,7 +54610,96 @@ function resetTieFormat({
|
|
|
54603
54610
|
if (typeof matchUpId !== 'string') return {
|
|
54604
54611
|
error: MISSING_MATCHUP_ID
|
|
54605
54612
|
};
|
|
54606
|
-
|
|
54613
|
+
let result = findMatchUp({
|
|
54614
|
+
tournamentRecord,
|
|
54615
|
+
matchUpId
|
|
54616
|
+
});
|
|
54617
|
+
if (result.error) return result;
|
|
54618
|
+
const {
|
|
54619
|
+
matchUp,
|
|
54620
|
+
structure
|
|
54621
|
+
} = result;
|
|
54622
|
+
if (!matchUp.tieMatchUps) return {
|
|
54623
|
+
error: INVALID_MATCHUP,
|
|
54624
|
+
info: 'Must be a TEAM matchUp'
|
|
54625
|
+
}; // if there is no tieFormat there is nothing to do
|
|
54626
|
+
|
|
54627
|
+
if (!matchUp.tieFormat) return { ...SUCCESS
|
|
54628
|
+
};
|
|
54629
|
+
const tieFormat = structure.tieFormat || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
54630
|
+
if (!tieFormat) return {
|
|
54631
|
+
error: NOT_FOUND,
|
|
54632
|
+
info: 'No inherited tieFormat'
|
|
54633
|
+
};
|
|
54634
|
+
const deletedMatchUpIds = [];
|
|
54635
|
+
const collectionIds = [];
|
|
54636
|
+
const newMatchUps = [];
|
|
54637
|
+
const tieMatchUps = [];
|
|
54638
|
+
|
|
54639
|
+
for (const collectionDefinition of tieFormat.collectionDefinitions) {
|
|
54640
|
+
// delete any matchUp.tieMatchUps that are not found in the ancestor tieFormat collectionDefinitions
|
|
54641
|
+
const {
|
|
54642
|
+
matchUpCount,
|
|
54643
|
+
collectionId
|
|
54644
|
+
} = collectionDefinition;
|
|
54645
|
+
collectionIds.push(collectionId);
|
|
54646
|
+
const existingCollectionMatchUps = (matchUp.tieMatchUps || []).filter(matchUp => matchUp.collectionId === collectionId);
|
|
54647
|
+
|
|
54648
|
+
if (existingCollectionMatchUps.length > matchUpCount) {
|
|
54649
|
+
// sort by matchUpStatus to prioritize active or completed matchUpsA
|
|
54650
|
+
existingCollectionMatchUps.sort((a, b) => (a.matchUpStatus === TO_BE_PLAYED ? 1 : 0) - (b.matchUpStatus === TO_BE_PLAYED ? 1 : 0));
|
|
54651
|
+
tieMatchUps.push(...existingCollectionMatchUps.slice(0, matchUpCount));
|
|
54652
|
+
deletedMatchUpIds.push(...existingCollectionMatchUps.slice(3).map(getMatchUpId));
|
|
54653
|
+
continue;
|
|
54654
|
+
} else {
|
|
54655
|
+
tieMatchUps.push(...existingCollectionMatchUps);
|
|
54656
|
+
|
|
54657
|
+
if (existingCollectionMatchUps.length < matchUpCount) {
|
|
54658
|
+
const matchUpsLimit = matchUpCount - existingCollectionMatchUps.length;
|
|
54659
|
+
const matchUps = generateCollectionMatchUps({
|
|
54660
|
+
collectionDefinition,
|
|
54661
|
+
matchUpsLimit,
|
|
54662
|
+
uuids
|
|
54663
|
+
});
|
|
54664
|
+
newMatchUps.push(...matchUps);
|
|
54665
|
+
}
|
|
54666
|
+
}
|
|
54667
|
+
}
|
|
54668
|
+
|
|
54669
|
+
for (const tieMatchUp of matchUp.tieMatchUps || []) {
|
|
54670
|
+
if (!collectionIds.includes(tieMatchUp.collectionId)) deletedMatchUpIds.push(tieMatchUp.matchUpId);
|
|
54671
|
+
}
|
|
54672
|
+
|
|
54673
|
+
if (newMatchUps.length) {
|
|
54674
|
+
tieMatchUps.push(...newMatchUps);
|
|
54675
|
+
addMatchUpsNotice({
|
|
54676
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
54677
|
+
eventId: event.eventId,
|
|
54678
|
+
matchUps: newMatchUps,
|
|
54679
|
+
drawDefinition
|
|
54680
|
+
});
|
|
54681
|
+
}
|
|
54682
|
+
|
|
54683
|
+
if (deletedMatchUpIds.length) {
|
|
54684
|
+
deleteMatchUpsNotice({
|
|
54685
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
54686
|
+
matchUpIds: deletedMatchUpIds,
|
|
54687
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
54688
|
+
drawDefinition
|
|
54689
|
+
});
|
|
54690
|
+
}
|
|
54691
|
+
|
|
54692
|
+
matchUp.tieMatchUps = tieMatchUps;
|
|
54693
|
+
modifyMatchUpNotice({
|
|
54694
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
54695
|
+
structureId: structure.structureId,
|
|
54696
|
+
eventId: event.eventId,
|
|
54697
|
+
drawDefinition,
|
|
54698
|
+
matchUp
|
|
54699
|
+
});
|
|
54700
|
+
return { ...SUCCESS,
|
|
54701
|
+
newMatchUps,
|
|
54702
|
+
deletedMatchUpIds
|
|
54607
54703
|
};
|
|
54608
54704
|
}
|
|
54609
54705
|
|