tods-competition-factory 1.6.19 → 1.6.21
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/forge/generate.mjs +161 -87
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +1 -1
- package/dist/forge/query.mjs +33 -36
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +132 -40
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +149 -126
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +149 -132
- 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/package.json +1 -1
package/dist/forge/query.d.ts
CHANGED
|
@@ -2035,7 +2035,7 @@ type GetRoundMatchUpsArgs = {
|
|
|
2035
2035
|
interpolate?: boolean;
|
|
2036
2036
|
};
|
|
2037
2037
|
type RoundMatchUpsResult = {
|
|
2038
|
-
|
|
2038
|
+
roundsNotPowerOf2?: boolean;
|
|
2039
2039
|
roundMatchUps?: HydratedMatchUp[];
|
|
2040
2040
|
hasNoRoundPositions?: boolean;
|
|
2041
2041
|
roundProfile?: RoundProfile;
|
package/dist/forge/query.mjs
CHANGED
|
@@ -4015,15 +4015,15 @@ function getRoundMatchUps({
|
|
|
4015
4015
|
roundIndex += 1;
|
|
4016
4016
|
}
|
|
4017
4017
|
});
|
|
4018
|
-
const
|
|
4018
|
+
const roundsNotPowerOf2 = !!Object.values(roundProfile).find(
|
|
4019
4019
|
({ matchUpsCount }) => !isPowerOf2(matchUpsCount)
|
|
4020
4020
|
);
|
|
4021
4021
|
const hasNoRoundPositions = matchUps.some(
|
|
4022
4022
|
(matchUp) => !matchUp.roundPosition
|
|
4023
4023
|
);
|
|
4024
4024
|
return {
|
|
4025
|
-
isNotEliminationStructure,
|
|
4026
4025
|
hasNoRoundPositions,
|
|
4026
|
+
roundsNotPowerOf2,
|
|
4027
4027
|
maxMatchUpsCount,
|
|
4028
4028
|
roundMatchUps,
|
|
4029
4029
|
roundNumbers,
|
|
@@ -6722,31 +6722,28 @@ function filterMatchUps(params) {
|
|
|
6722
6722
|
}
|
|
6723
6723
|
|
|
6724
6724
|
function isLucky({
|
|
6725
|
-
|
|
6725
|
+
roundsNotPowerOf2,
|
|
6726
6726
|
drawDefinition,
|
|
6727
|
-
|
|
6728
|
-
|
|
6727
|
+
structure,
|
|
6728
|
+
matchUps
|
|
6729
6729
|
}) {
|
|
6730
6730
|
if (!structure)
|
|
6731
6731
|
return false;
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
}
|
|
6737
|
-
const hasFirstRoundDrawPositions = !!roundMatchUps?.[1]?.find(
|
|
6738
|
-
({ drawPositions }) => drawPositions
|
|
6739
|
-
);
|
|
6740
|
-
const noSecondRoundDrawPositions = !roundMatchUps?.[2]?.find(
|
|
6741
|
-
({ drawPositions }) => drawPositions
|
|
6742
|
-
);
|
|
6743
|
-
return isNotEliminationStructure && !structure?.structures && hasFirstRoundDrawPositions && noSecondRoundDrawPositions && !(drawDefinition?.drawType && drawDefinition.drawType !== LUCKY_DRAW);
|
|
6732
|
+
matchUps = matchUps ?? structure.matchUps ?? [];
|
|
6733
|
+
roundsNotPowerOf2 = roundsNotPowerOf2 ?? getRoundMatchUps({ matchUps }).roundsNotPowerOf2;
|
|
6734
|
+
const hasDrawPositions = !!structure.positionAssignments?.find(({ drawPosition }) => drawPosition) || !!matchUps?.find(({ drawPositions }) => drawPositions?.length);
|
|
6735
|
+
return (!drawDefinition?.drawType || drawDefinition.drawType !== LUCKY_DRAW) && !structure?.structures && roundsNotPowerOf2 && hasDrawPositions;
|
|
6744
6736
|
}
|
|
6745
6737
|
|
|
6746
6738
|
function isAdHoc({ drawDefinition, structure }) {
|
|
6747
6739
|
if (!structure)
|
|
6748
6740
|
return false;
|
|
6749
|
-
|
|
6741
|
+
const matchUps = structure.matchUps || structure.roundMatchUps && Object.values(structure.roundMatchUps).flat();
|
|
6742
|
+
const hasRoundPosition = matchUps?.find((matchUp) => matchUp?.roundPosition);
|
|
6743
|
+
const hasDrawPosition = matchUps?.find(
|
|
6744
|
+
(matchUp) => matchUp?.drawPositions?.length
|
|
6745
|
+
);
|
|
6746
|
+
return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
6750
6747
|
}
|
|
6751
6748
|
|
|
6752
6749
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
@@ -6781,14 +6778,10 @@ function getRoundContextProfile({
|
|
|
6781
6778
|
structure,
|
|
6782
6779
|
matchUps
|
|
6783
6780
|
}) {
|
|
6784
|
-
const {
|
|
6781
|
+
const { roundProfile, roundMatchUps } = getRoundMatchUps({ matchUps });
|
|
6785
6782
|
const { structureAbbreviation, stage } = structure;
|
|
6786
6783
|
const isAdHocStructure = isAdHoc({ structure });
|
|
6787
|
-
const isLuckyStructure = isLucky({
|
|
6788
|
-
isNotEliminationStructure,
|
|
6789
|
-
roundMatchUps,
|
|
6790
|
-
structure
|
|
6791
|
-
});
|
|
6784
|
+
const isLuckyStructure = isLucky({ structure });
|
|
6792
6785
|
const isRoundRobin = structure.structures;
|
|
6793
6786
|
const roundNamingProfile = {};
|
|
6794
6787
|
const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
|
|
@@ -7023,8 +7016,8 @@ function getAllStructureMatchUps({
|
|
|
7023
7016
|
matchUpsMap,
|
|
7024
7017
|
structureId
|
|
7025
7018
|
}).drawPositionsRanges : void 0;
|
|
7026
|
-
matchUps = matchUps.map(
|
|
7027
|
-
|
|
7019
|
+
matchUps = matchUps.map((matchUp) => {
|
|
7020
|
+
return addMatchUpContext({
|
|
7028
7021
|
scheduleVisibilityFilters,
|
|
7029
7022
|
sourceDrawPositionRanges,
|
|
7030
7023
|
drawPositionsRanges,
|
|
@@ -7035,8 +7028,8 @@ function getAllStructureMatchUps({
|
|
|
7035
7028
|
roundProfile,
|
|
7036
7029
|
matchUp,
|
|
7037
7030
|
event
|
|
7038
|
-
})
|
|
7039
|
-
);
|
|
7031
|
+
});
|
|
7032
|
+
});
|
|
7040
7033
|
const matchUpTies = matchUps?.filter(
|
|
7041
7034
|
(matchUp) => Array.isArray(matchUp.tieMatchUps)
|
|
7042
7035
|
);
|
|
@@ -11483,7 +11476,7 @@ function getValidSeedBlocks({
|
|
|
11483
11476
|
let validSeedBlocks = [];
|
|
11484
11477
|
if (!structure)
|
|
11485
11478
|
return { error: MISSING_STRUCTURE };
|
|
11486
|
-
const { roundMatchUps } = getAllStructureMatchUps({
|
|
11479
|
+
const { matchUps, roundMatchUps } = getAllStructureMatchUps({
|
|
11487
11480
|
matchUpFilters: { roundNumbers: [1] },
|
|
11488
11481
|
provisionalPositioning,
|
|
11489
11482
|
structure
|
|
@@ -11516,12 +11509,16 @@ function getValidSeedBlocks({
|
|
|
11516
11509
|
const { stage, structureType, roundLimit } = structure;
|
|
11517
11510
|
const isContainer = structureType === CONTAINER;
|
|
11518
11511
|
const isFeedIn = !isContainer && uniqueDrawPositionsByRound?.length;
|
|
11519
|
-
const isLucky = firstRoundDrawPositions?.length && !isPowerOf2(baseDrawSize);
|
|
11520
11512
|
const qualifyingBlocks = !isContainer && stage === QUALIFYING && roundLimit;
|
|
11521
11513
|
const fedSeedBlockPositions = seedRangeDrawPositionBlocks.flat(Infinity);
|
|
11522
11514
|
const fedSeedNumberOffset = isFeedIn ? fedSeedBlockPositions?.length : 0;
|
|
11523
11515
|
const countLimit = allPositions ? positionsCount : seedsCount;
|
|
11524
|
-
const
|
|
11516
|
+
const isLuckyStructure = isLucky({
|
|
11517
|
+
drawDefinition,
|
|
11518
|
+
structure,
|
|
11519
|
+
matchUps
|
|
11520
|
+
});
|
|
11521
|
+
const firstRoundSeedsCount = isLuckyStructure ? 0 : !isFeedIn && countLimit || countLimit && fedSeedBlockPositions.length < countLimit && countLimit - fedSeedBlockPositions.length || 0;
|
|
11525
11522
|
if (qualifyingBlocks) {
|
|
11526
11523
|
const seedingBlocksCount = structure?.matchUps ? structure.matchUps.filter(
|
|
11527
11524
|
({ roundNumber }) => roundNumber === structure.roundLimit
|
|
@@ -11557,14 +11554,14 @@ function getValidSeedBlocks({
|
|
|
11557
11554
|
validSeedBlocks = seedRangeDrawPositionBlocks.map((block) => {
|
|
11558
11555
|
return { seedNumbers: block, drawPositions: block };
|
|
11559
11556
|
});
|
|
11560
|
-
} else if (
|
|
11557
|
+
} else if (isLuckyStructure) {
|
|
11561
11558
|
const blocks = chunkArray(firstRoundDrawPositions, 2).map((block, i) => ({
|
|
11562
11559
|
drawPositions: [block[0]],
|
|
11563
11560
|
seedNumbers: [i + 1]
|
|
11564
11561
|
}));
|
|
11565
11562
|
blocks.forEach((block) => validSeedBlocks.push(block));
|
|
11566
11563
|
}
|
|
11567
|
-
if (!isContainer && !
|
|
11564
|
+
if (!isContainer && !isLuckyStructure && !qualifyingBlocks) {
|
|
11568
11565
|
const { blocks } = constructPower2Blocks({
|
|
11569
11566
|
drawPositionOffset: firstRoundDrawPositionOffset,
|
|
11570
11567
|
seedNumberOffset: fedSeedNumberOffset,
|
|
@@ -11583,7 +11580,7 @@ function getValidSeedBlocks({
|
|
|
11583
11580
|
},
|
|
11584
11581
|
true
|
|
11585
11582
|
);
|
|
11586
|
-
if (!
|
|
11583
|
+
if (!isLuckyStructure && !isFeedIn && !isContainer && !validSeedPositions) {
|
|
11587
11584
|
return {
|
|
11588
11585
|
error: INVALID_SEED_POSITION,
|
|
11589
11586
|
validSeedBlocks: [],
|
|
@@ -11592,10 +11589,10 @@ function getValidSeedBlocks({
|
|
|
11592
11589
|
};
|
|
11593
11590
|
}
|
|
11594
11591
|
return {
|
|
11592
|
+
isLuckyStructure,
|
|
11595
11593
|
validSeedBlocks,
|
|
11596
11594
|
isContainer,
|
|
11597
|
-
isFeedIn
|
|
11598
|
-
isLucky
|
|
11595
|
+
isFeedIn
|
|
11599
11596
|
};
|
|
11600
11597
|
}
|
|
11601
11598
|
function getContainerBlocks({ seedingProfile, structure }) {
|