tods-competition-factory 1.6.10 → 1.6.12
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 +225 -205
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +7 -4
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +84 -70
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +119 -100
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +168 -153
- 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 +3 -3
package/dist/forge/transform.mjs
CHANGED
|
@@ -2186,7 +2186,7 @@ function getParticipantResults({
|
|
|
2186
2186
|
const manualGamesOverride = tieFormat && matchUp._disableAutoCalc && tieFormat.collectionDefinitions.every(({ scoreValue }) => scoreValue);
|
|
2187
2187
|
const winningParticipantId = winningSide && getWinningSideId(matchUp);
|
|
2188
2188
|
const losingParticipantId = winningSide && getLosingSideId(matchUp);
|
|
2189
|
-
if (!winningParticipantId
|
|
2189
|
+
if (!winningParticipantId && !losingParticipantId) {
|
|
2190
2190
|
if (completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
2191
2191
|
const participantIdSide1 = getSideId(matchUp, 0);
|
|
2192
2192
|
const participantIdSide2 = getSideId(matchUp, 1);
|
|
@@ -2198,53 +2198,51 @@ function getParticipantResults({
|
|
|
2198
2198
|
checkInitializeParticipant(participantResults, participantIdSide2);
|
|
2199
2199
|
participantResults[participantIdSide2].matchUpsCancelled += 1;
|
|
2200
2200
|
}
|
|
2201
|
-
} else {
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
participantResults[tieLosingParticipantId].tieDoublesLost += 1;
|
|
2229
|
-
}
|
|
2201
|
+
} else if (tieMatchUps?.length) {
|
|
2202
|
+
perPlayer = 0;
|
|
2203
|
+
for (const tieMatchUp of tieMatchUps) {
|
|
2204
|
+
if (tieMatchUp.winningSide) {
|
|
2205
|
+
const tieWinningParticipantId = sides.find(
|
|
2206
|
+
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
2207
|
+
)?.participantId;
|
|
2208
|
+
const tieLosingParticipantId = sides.find(
|
|
2209
|
+
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
2210
|
+
)?.participantId;
|
|
2211
|
+
if (tieWinningParticipantId && tieLosingParticipantId) {
|
|
2212
|
+
checkInitializeParticipant(
|
|
2213
|
+
participantResults,
|
|
2214
|
+
tieWinningParticipantId
|
|
2215
|
+
);
|
|
2216
|
+
checkInitializeParticipant(
|
|
2217
|
+
participantResults,
|
|
2218
|
+
tieLosingParticipantId
|
|
2219
|
+
);
|
|
2220
|
+
participantResults[tieWinningParticipantId].tieMatchUpsWon += 1;
|
|
2221
|
+
participantResults[tieLosingParticipantId].tieMatchUpsLost += 1;
|
|
2222
|
+
if (tieMatchUp.matchUpType === SINGLES) {
|
|
2223
|
+
participantResults[tieWinningParticipantId].tieSinglesWon += 1;
|
|
2224
|
+
participantResults[tieLosingParticipantId].tieSinglesLost += 1;
|
|
2225
|
+
} else if (tieMatchUp.matchUpType === DOUBLES) {
|
|
2226
|
+
participantResults[tieWinningParticipantId].tieDoublesWon += 1;
|
|
2227
|
+
participantResults[tieLosingParticipantId].tieDoublesLost += 1;
|
|
2230
2228
|
}
|
|
2231
2229
|
}
|
|
2232
|
-
processScore({
|
|
2233
|
-
score: tieMatchUp.score,
|
|
2234
|
-
manualGamesOverride,
|
|
2235
|
-
participantResults,
|
|
2236
|
-
sides
|
|
2237
|
-
// use sides from the TEAM matchUp
|
|
2238
|
-
});
|
|
2239
2230
|
}
|
|
2240
|
-
} else {
|
|
2241
2231
|
processScore({
|
|
2232
|
+
score: tieMatchUp.score,
|
|
2242
2233
|
manualGamesOverride,
|
|
2243
2234
|
participantResults,
|
|
2244
|
-
score,
|
|
2245
2235
|
sides
|
|
2236
|
+
// use sides from the TEAM matchUp
|
|
2246
2237
|
});
|
|
2247
2238
|
}
|
|
2239
|
+
} else {
|
|
2240
|
+
processScore({
|
|
2241
|
+
manualGamesOverride,
|
|
2242
|
+
participantResults,
|
|
2243
|
+
score,
|
|
2244
|
+
sides
|
|
2245
|
+
});
|
|
2248
2246
|
}
|
|
2249
2247
|
} else {
|
|
2250
2248
|
checkInitializeParticipant(participantResults, winningParticipantId);
|
|
@@ -4563,7 +4561,7 @@ function structureSort(a, b, config) {
|
|
|
4563
4561
|
const completedStructure = (s) => s?.matchUps.every(
|
|
4564
4562
|
({ matchUpStatus }) => completedMatchUpStatuses.includes(matchUpStatus) ? 1 : -1
|
|
4565
4563
|
);
|
|
4566
|
-
return completed && completedStructure(a) - completedStructure(b) || aggregate && protocolSequence(a) - protocolSequence(b) || (a?.stage && orderProtocol[a.stage] || 0) - (b?.stage && orderProtocol[b.stage] || 0) || (getRoundTarget(a) || 0) - (getRoundTarget(b) || 0) || !finish && !aggregate && (b?.positionAssignments?.length
|
|
4564
|
+
return completed && completedStructure(a) - completedStructure(b) || aggregate && protocolSequence(a) - protocolSequence(b) || (a?.stage && orderProtocol[a.stage] || 0) - (b?.stage && orderProtocol[b.stage] || 0) || (getRoundTarget(a) || 0) - (getRoundTarget(b) || 0) || !finish && !aggregate && (b?.positionAssignments?.length ?? Infinity) - (a?.positionAssignments?.length ?? Infinity) || (a?.stageSequence ?? 0) - (b?.stageSequence ?? 0) || (getMinFinishingPositionRange(a) || 0) - (getMinFinishingPositionRange(b) || 0);
|
|
4567
4565
|
}
|
|
4568
4566
|
function getMinFinishingPositionRange(structure) {
|
|
4569
4567
|
return (structure?.matchUps || []).reduce((rangeSum, matchUp) => {
|
|
@@ -4653,6 +4651,7 @@ EntryStatusEnum.Withdrawn;
|
|
|
4653
4651
|
|
|
4654
4652
|
function getStageEntries({
|
|
4655
4653
|
provisionalPositioning,
|
|
4654
|
+
placementGroup,
|
|
4656
4655
|
drawDefinition,
|
|
4657
4656
|
stageSequence,
|
|
4658
4657
|
entryStatuses,
|
|
@@ -4682,7 +4681,9 @@ function getStageEntries({
|
|
|
4682
4681
|
if (error) {
|
|
4683
4682
|
console.log("playoff entries error");
|
|
4684
4683
|
}
|
|
4685
|
-
return playoffEntries?.length ? playoffEntries : entries
|
|
4684
|
+
return (playoffEntries?.length ? playoffEntries : entries).filter(
|
|
4685
|
+
(entry) => !placementGroup || entry.placementGroup === placementGroup
|
|
4686
|
+
);
|
|
4686
4687
|
}
|
|
4687
4688
|
return entries;
|
|
4688
4689
|
}
|
|
@@ -11071,9 +11072,8 @@ function modifyMatchUpScore({
|
|
|
11071
11072
|
return { error: MATCHUP_NOT_FOUND };
|
|
11072
11073
|
({ matchUp, structure } = findResult);
|
|
11073
11074
|
}
|
|
11074
|
-
} else {
|
|
11075
|
-
|
|
11076
|
-
console.log("!!!!!");
|
|
11075
|
+
} else if (matchUp.matchUpId !== matchUpId) {
|
|
11076
|
+
console.log("!!!!!");
|
|
11077
11077
|
}
|
|
11078
11078
|
if (matchUpStatus && [WALKOVER$1, DOUBLE_WALKOVER].includes(matchUpStatus) || removeScore) {
|
|
11079
11079
|
Object.assign(matchUp, { ...toBePlayed });
|
|
@@ -11111,31 +11111,45 @@ function modifyMatchUpScore({
|
|
|
11111
11111
|
})?.appliedPolicies;
|
|
11112
11112
|
defaultedProcessCodes = appliedPolicies?.[POLICY_TYPE_SCORING]?.processCodes?.incompleteAssignmentsOnDefault;
|
|
11113
11113
|
}
|
|
11114
|
-
if (
|
|
11115
|
-
|
|
11116
|
-
const
|
|
11117
|
-
|
|
11118
|
-
|
|
11119
|
-
|
|
11120
|
-
|
|
11121
|
-
|
|
11122
|
-
|
|
11123
|
-
|
|
11124
|
-
|
|
11125
|
-
|
|
11126
|
-
|
|
11127
|
-
|
|
11128
|
-
|
|
11129
|
-
|
|
11130
|
-
|
|
11131
|
-
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
|
|
11137
|
-
|
|
11138
|
-
|
|
11114
|
+
if (!matchUp.collectionId) {
|
|
11115
|
+
const isRoundRobin = structure?.structureType === CONTAINER;
|
|
11116
|
+
const isAdHocStructure = isAdHoc({ drawDefinition, structure });
|
|
11117
|
+
if (isLucky({ drawDefinition, structure }) || isAdHocStructure || isRoundRobin) {
|
|
11118
|
+
const updateTally = (structure2) => {
|
|
11119
|
+
matchUpFormat = isDualMatchUp ? "SET1-S:T100" : matchUpFormat ?? matchUp.matchUpFormat ?? structure2?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
|
|
11120
|
+
const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
|
|
11121
|
+
const { matchUps } = getAllStructureMatchUps({
|
|
11122
|
+
afterRecoveryTimes: false,
|
|
11123
|
+
inContext: true,
|
|
11124
|
+
matchUpFilters,
|
|
11125
|
+
structure: structure2,
|
|
11126
|
+
event
|
|
11127
|
+
});
|
|
11128
|
+
if (isAdHocStructure) {
|
|
11129
|
+
structure2.positionAssignments = unique(
|
|
11130
|
+
matchUps.flatMap(
|
|
11131
|
+
(matchUp2) => (matchUp2.sides ?? []).map((side) => side.participantId)
|
|
11132
|
+
).filter(Boolean)
|
|
11133
|
+
).map((participantId) => ({ participantId }));
|
|
11134
|
+
}
|
|
11135
|
+
return updateAssignmentParticipantResults({
|
|
11136
|
+
positionAssignments: structure2.positionAssignments,
|
|
11137
|
+
tournamentRecord,
|
|
11138
|
+
drawDefinition,
|
|
11139
|
+
matchUpFormat,
|
|
11140
|
+
matchUps,
|
|
11141
|
+
event
|
|
11142
|
+
});
|
|
11143
|
+
};
|
|
11144
|
+
const itemStructure = isRoundRobin && structure.structures.find((itemStructure2) => {
|
|
11145
|
+
return itemStructure2?.matchUps.find(
|
|
11146
|
+
(matchUp2) => matchUp2.matchUpId === matchUpId
|
|
11147
|
+
);
|
|
11148
|
+
});
|
|
11149
|
+
const result = updateTally(itemStructure || structure);
|
|
11150
|
+
if (result.error)
|
|
11151
|
+
return decorateResult({ result, stack });
|
|
11152
|
+
}
|
|
11139
11153
|
}
|
|
11140
11154
|
if (notes) {
|
|
11141
11155
|
const result = addNotes({ element: matchUp, notes });
|
|
@@ -13094,7 +13108,7 @@ function getValidSeedBlocks({
|
|
|
13094
13108
|
});
|
|
13095
13109
|
const { positionAssignments } = structureAssignedDrawPositions({ structure });
|
|
13096
13110
|
const positionsCount = positionAssignments?.length;
|
|
13097
|
-
const seedsCount = seedAssignments?.length
|
|
13111
|
+
const seedsCount = seedAssignments?.length ?? 0;
|
|
13098
13112
|
let allDrawPositions = [];
|
|
13099
13113
|
const roundNumbers = Object.keys(roundMatchUps).map((n) => parseInt(n)).sort((a, b) => a - b);
|
|
13100
13114
|
const uniqueDrawPositionsByRound = roundNumbers.map((roundNumber) => {
|