tods-competition-factory 1.6.18 → 1.6.20
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 +158 -83
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +1 -1
- package/dist/forge/query.mjs +30 -32
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +129 -36
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +140 -122
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +143 -131
- 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,29 @@ 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 hasRoundPosition = structure?.matchUps?.find(
|
|
6742
|
+
(matchUp) => matchUp?.roundPosition
|
|
6743
|
+
);
|
|
6744
|
+
const hasDrawPosition = structure?.matchUps?.find(
|
|
6745
|
+
(matchUp) => matchUp?.drawPositions?.length
|
|
6746
|
+
);
|
|
6747
|
+
return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
|
|
6750
6748
|
}
|
|
6751
6749
|
|
|
6752
6750
|
const POLICY_ROUND_NAMING_DEFAULT = {
|
|
@@ -6781,14 +6779,10 @@ function getRoundContextProfile({
|
|
|
6781
6779
|
structure,
|
|
6782
6780
|
matchUps
|
|
6783
6781
|
}) {
|
|
6784
|
-
const {
|
|
6782
|
+
const { roundProfile, roundMatchUps } = getRoundMatchUps({ matchUps });
|
|
6785
6783
|
const { structureAbbreviation, stage } = structure;
|
|
6786
6784
|
const isAdHocStructure = isAdHoc({ structure });
|
|
6787
|
-
const isLuckyStructure = isLucky({
|
|
6788
|
-
isNotEliminationStructure,
|
|
6789
|
-
roundMatchUps,
|
|
6790
|
-
structure
|
|
6791
|
-
});
|
|
6785
|
+
const isLuckyStructure = isLucky({ structure });
|
|
6792
6786
|
const isRoundRobin = structure.structures;
|
|
6793
6787
|
const roundNamingProfile = {};
|
|
6794
6788
|
const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
|
|
@@ -11483,7 +11477,7 @@ function getValidSeedBlocks({
|
|
|
11483
11477
|
let validSeedBlocks = [];
|
|
11484
11478
|
if (!structure)
|
|
11485
11479
|
return { error: MISSING_STRUCTURE };
|
|
11486
|
-
const { roundMatchUps } = getAllStructureMatchUps({
|
|
11480
|
+
const { matchUps, roundMatchUps } = getAllStructureMatchUps({
|
|
11487
11481
|
matchUpFilters: { roundNumbers: [1] },
|
|
11488
11482
|
provisionalPositioning,
|
|
11489
11483
|
structure
|
|
@@ -11516,12 +11510,16 @@ function getValidSeedBlocks({
|
|
|
11516
11510
|
const { stage, structureType, roundLimit } = structure;
|
|
11517
11511
|
const isContainer = structureType === CONTAINER;
|
|
11518
11512
|
const isFeedIn = !isContainer && uniqueDrawPositionsByRound?.length;
|
|
11519
|
-
const isLucky = firstRoundDrawPositions?.length && !isPowerOf2(baseDrawSize);
|
|
11520
11513
|
const qualifyingBlocks = !isContainer && stage === QUALIFYING && roundLimit;
|
|
11521
11514
|
const fedSeedBlockPositions = seedRangeDrawPositionBlocks.flat(Infinity);
|
|
11522
11515
|
const fedSeedNumberOffset = isFeedIn ? fedSeedBlockPositions?.length : 0;
|
|
11523
11516
|
const countLimit = allPositions ? positionsCount : seedsCount;
|
|
11524
|
-
const
|
|
11517
|
+
const isLuckyStructure = isLucky({
|
|
11518
|
+
drawDefinition,
|
|
11519
|
+
structure,
|
|
11520
|
+
matchUps
|
|
11521
|
+
});
|
|
11522
|
+
const firstRoundSeedsCount = isLuckyStructure ? 0 : !isFeedIn && countLimit || countLimit && fedSeedBlockPositions.length < countLimit && countLimit - fedSeedBlockPositions.length || 0;
|
|
11525
11523
|
if (qualifyingBlocks) {
|
|
11526
11524
|
const seedingBlocksCount = structure?.matchUps ? structure.matchUps.filter(
|
|
11527
11525
|
({ roundNumber }) => roundNumber === structure.roundLimit
|
|
@@ -11557,14 +11555,14 @@ function getValidSeedBlocks({
|
|
|
11557
11555
|
validSeedBlocks = seedRangeDrawPositionBlocks.map((block) => {
|
|
11558
11556
|
return { seedNumbers: block, drawPositions: block };
|
|
11559
11557
|
});
|
|
11560
|
-
} else if (
|
|
11558
|
+
} else if (isLuckyStructure) {
|
|
11561
11559
|
const blocks = chunkArray(firstRoundDrawPositions, 2).map((block, i) => ({
|
|
11562
11560
|
drawPositions: [block[0]],
|
|
11563
11561
|
seedNumbers: [i + 1]
|
|
11564
11562
|
}));
|
|
11565
11563
|
blocks.forEach((block) => validSeedBlocks.push(block));
|
|
11566
11564
|
}
|
|
11567
|
-
if (!isContainer && !
|
|
11565
|
+
if (!isContainer && !isLuckyStructure && !qualifyingBlocks) {
|
|
11568
11566
|
const { blocks } = constructPower2Blocks({
|
|
11569
11567
|
drawPositionOffset: firstRoundDrawPositionOffset,
|
|
11570
11568
|
seedNumberOffset: fedSeedNumberOffset,
|
|
@@ -11583,7 +11581,7 @@ function getValidSeedBlocks({
|
|
|
11583
11581
|
},
|
|
11584
11582
|
true
|
|
11585
11583
|
);
|
|
11586
|
-
if (!
|
|
11584
|
+
if (!isLuckyStructure && !isFeedIn && !isContainer && !validSeedPositions) {
|
|
11587
11585
|
return {
|
|
11588
11586
|
error: INVALID_SEED_POSITION,
|
|
11589
11587
|
validSeedBlocks: [],
|
|
@@ -11592,10 +11590,10 @@ function getValidSeedBlocks({
|
|
|
11592
11590
|
};
|
|
11593
11591
|
}
|
|
11594
11592
|
return {
|
|
11593
|
+
isLuckyStructure,
|
|
11595
11594
|
validSeedBlocks,
|
|
11596
11595
|
isContainer,
|
|
11597
|
-
isFeedIn
|
|
11598
|
-
isLucky
|
|
11596
|
+
isFeedIn
|
|
11599
11597
|
};
|
|
11600
11598
|
}
|
|
11601
11599
|
function getContainerBlocks({ seedingProfile, structure }) {
|