tods-competition-factory 2.2.34 → 2.2.36
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/index.mjs +8 -8
- package/dist/tods-competition-factory.d.ts +19 -1
- package/dist/tods-competition-factory.development.cjs.js +361 -77
- 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 +12 -12
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.2.
|
|
6
|
+
return '2.2.36';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SINGLES_MATCHUP = 'SINGLES';
|
|
@@ -2206,11 +2206,11 @@ function isValidMatchUpFormat({ matchUpFormat }) {
|
|
|
2206
2206
|
if (!isString(matchUpFormat) || matchUpFormat === '')
|
|
2207
2207
|
return false;
|
|
2208
2208
|
const parsedFormat = parse(matchUpFormat);
|
|
2209
|
-
const setParts =
|
|
2209
|
+
const setParts = /-S:([1-9])+\/TB(\d{1,2})@?([1-9]?)/.exec(matchUpFormat);
|
|
2210
2210
|
const setsTo = setParts?.[1];
|
|
2211
2211
|
const tiebreakTo = setParts?.[2];
|
|
2212
2212
|
const tiebreakAt = setParts?.[3];
|
|
2213
|
-
const finalSetParts =
|
|
2213
|
+
const finalSetParts = /-F:([1-9])+\/TB(\d{1,2})@?([1-9]?)/.exec(matchUpFormat);
|
|
2214
2214
|
const finalSetTo = finalSetParts?.[1];
|
|
2215
2215
|
const finalSetTiebreakTo = finalSetParts?.[2];
|
|
2216
2216
|
const finalTiebreakAt = finalSetParts?.[3];
|
|
@@ -10372,6 +10372,10 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
|
|
|
10372
10372
|
else if (setFormat?.tiebreakSet || setFormat?.timed) {
|
|
10373
10373
|
set.tiebreakSet = true;
|
|
10374
10374
|
}
|
|
10375
|
+
if (set.tiebreakSet && [1, 2].includes(set.winningSide)) {
|
|
10376
|
+
set.side1Score = set.winningSide === 1 ? 1 : 0;
|
|
10377
|
+
set.side2Score = set.winningSide === 2 ? 1 : 0;
|
|
10378
|
+
}
|
|
10375
10379
|
return set;
|
|
10376
10380
|
});
|
|
10377
10381
|
}
|
|
@@ -10442,11 +10446,11 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
|
|
|
10442
10446
|
participant.entryStage = entryStage;
|
|
10443
10447
|
}
|
|
10444
10448
|
}
|
|
10445
|
-
if (hydrateParticipants
|
|
10446
|
-
Object.assign(side, { participant });
|
|
10449
|
+
if (hydrateParticipants === false) {
|
|
10450
|
+
Object.assign(side, { participant: { entryStage, entryStatus } });
|
|
10447
10451
|
}
|
|
10448
10452
|
else {
|
|
10449
|
-
Object.assign(side, { participant
|
|
10453
|
+
Object.assign(side, { participant });
|
|
10450
10454
|
}
|
|
10451
10455
|
}
|
|
10452
10456
|
}
|
|
@@ -10554,7 +10558,7 @@ function addMatchUpContext({ scheduleVisibilityFilters, sourceDrawPositionRanges
|
|
|
10554
10558
|
});
|
|
10555
10559
|
});
|
|
10556
10560
|
}
|
|
10557
|
-
const hasParticipants = matchUpWithContext.sides
|
|
10561
|
+
const hasParticipants = matchUpWithContext.sides?.filter((side) => side?.participantId).length === 2;
|
|
10558
10562
|
const hasNoWinner = !matchUpWithContext.winningSide;
|
|
10559
10563
|
const readyToScore = scoringActive && hasParticipants && hasNoWinner;
|
|
10560
10564
|
Object.assign(matchUpWithContext, { readyToScore, hasContext: true });
|
|
@@ -12359,9 +12363,7 @@ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tourn
|
|
|
12359
12363
|
({ structureId } = structure);
|
|
12360
12364
|
const stack = 'assignDrawPositionBye';
|
|
12361
12365
|
pushGlobalLog({ method: stack, color: 'cyan', drawPosition });
|
|
12362
|
-
|
|
12363
|
-
matchUpsMap = getMatchUpsMap({ drawDefinition });
|
|
12364
|
-
}
|
|
12366
|
+
matchUpsMap ??= getMatchUpsMap({ drawDefinition });
|
|
12365
12367
|
const { positionAssignments } = getPositionAssignments$1({ structure });
|
|
12366
12368
|
const { activeDrawPositions } = getStructureDrawPositionProfiles({
|
|
12367
12369
|
drawDefinition,
|
|
@@ -12371,7 +12373,8 @@ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tourn
|
|
|
12371
12373
|
if (currentAssignment?.bye) {
|
|
12372
12374
|
return { ...SUCCESS };
|
|
12373
12375
|
}
|
|
12374
|
-
const hasPropagatedStatus = !!(loserMatchUp &&
|
|
12376
|
+
const hasPropagatedStatus = !!(loserMatchUp &&
|
|
12377
|
+
matchUpsMap.drawMatchUps.find((m) => m.loserMatchUpId === loserMatchUp?.matchUpId && isExit(m.matchUpStatus)));
|
|
12375
12378
|
const drawPositionIsActive = activeDrawPositions?.includes(drawPosition);
|
|
12376
12379
|
if (drawPositionIsActive && !hasPropagatedStatus) {
|
|
12377
12380
|
return { error: DRAW_POSITION_ACTIVE };
|
|
@@ -16727,9 +16730,9 @@ function assignMatchUpDrawPosition({ inContextDrawMatchUps, sourceMatchUpStatus,
|
|
|
16727
16730
|
inContextDrawMatchUps,
|
|
16728
16731
|
drawPosition,
|
|
16729
16732
|
matchUpId,
|
|
16730
|
-
}))
|
|
16731
|
-
|
|
16732
|
-
|
|
16733
|
+
})) ||
|
|
16734
|
+
(isPropagatedExit && matchUp.winningSide) ||
|
|
16735
|
+
undefined;
|
|
16733
16736
|
if (matchUp?.matchUpStatusCodes) {
|
|
16734
16737
|
updateMatchUpStatusCodes({
|
|
16735
16738
|
inContextDrawMatchUps,
|
|
@@ -22085,7 +22088,7 @@ function countGames({ matchUpFormat = FORMAT_STANDARD, winningSide: matchUpWinni
|
|
|
22085
22088
|
const based = parsedMatchUpFormat?.[whichFormat]?.based;
|
|
22086
22089
|
const isTiebreakSet = parsedMatchUpFormat?.[whichFormat].tiebreakSet;
|
|
22087
22090
|
const { side1Score, side2Score } = set;
|
|
22088
|
-
if (isGamesBased(based)) {
|
|
22091
|
+
if (isGamesBased(based) && !isTiebreakSet) {
|
|
22089
22092
|
gamesTally[0].push(ensureInt(side1Score || 0));
|
|
22090
22093
|
gamesTally[1].push(ensureInt(side2Score || 0));
|
|
22091
22094
|
}
|
|
@@ -22560,6 +22563,42 @@ function processOutcome$1({ winningParticipantId, losingParticipantId, participa
|
|
|
22560
22563
|
}
|
|
22561
22564
|
}
|
|
22562
22565
|
|
|
22566
|
+
function addExplanation(step, participants, readable, floatSort) {
|
|
22567
|
+
if (!step.groups)
|
|
22568
|
+
return;
|
|
22569
|
+
Object.keys(step.groups)
|
|
22570
|
+
.sort(floatSort)
|
|
22571
|
+
.forEach((key) => {
|
|
22572
|
+
const participantNames = step.groups[key].map((participantId) => participants[participantId]).join(', ');
|
|
22573
|
+
const explanation = `${key} ${step.attribute}: ${participantNames}`;
|
|
22574
|
+
readable.push(explanation);
|
|
22575
|
+
});
|
|
22576
|
+
}
|
|
22577
|
+
function processReportStep(step, i, participants, readable) {
|
|
22578
|
+
if (step.excludedDirectives?.length) {
|
|
22579
|
+
const attributes = step.excludedDirectives.map(({ attribute }) => attribute).join(', ');
|
|
22580
|
+
const note = `${attributes.length} directives were excluded due to participants limit}`;
|
|
22581
|
+
readable.push(note);
|
|
22582
|
+
const excluded = `Excluded: ${attributes}`;
|
|
22583
|
+
readable.push(excluded);
|
|
22584
|
+
}
|
|
22585
|
+
else {
|
|
22586
|
+
const floatSort = (a, b) => Number.parseFloat(step.reversed ? a : b) - Number.parseFloat(step.reversed ? b : a);
|
|
22587
|
+
const participantsCount = step.groups
|
|
22588
|
+
? Object.values(step.groups).flat(Infinity).length
|
|
22589
|
+
: (step.participantIds?.length ?? 0);
|
|
22590
|
+
const reversed = step.reversed ? ' in reverse order' : '';
|
|
22591
|
+
const action = step.groups ? 'grouped' : 'separated';
|
|
22592
|
+
const description = `Step ${i + 1}: ${participantsCount} particiants were ${action}${reversed} by ${step.attribute}`;
|
|
22593
|
+
readable.push(description);
|
|
22594
|
+
if (step.idsFilter) {
|
|
22595
|
+
const note = `${step.attribute} was calculated considering ONLY TIED PARTICIPANTS`;
|
|
22596
|
+
readable.push(note);
|
|
22597
|
+
}
|
|
22598
|
+
addExplanation(step, participants, readable, floatSort);
|
|
22599
|
+
}
|
|
22600
|
+
readable.push('----------------------');
|
|
22601
|
+
}
|
|
22563
22602
|
function getTallyReport({ matchUps, order, report }) {
|
|
22564
22603
|
const participants = {};
|
|
22565
22604
|
matchUps.forEach(({ sides }) => {
|
|
@@ -22572,41 +22611,7 @@ function getTallyReport({ matchUps, order, report }) {
|
|
|
22572
22611
|
const readable = [];
|
|
22573
22612
|
if (Array.isArray(report)) {
|
|
22574
22613
|
report.forEach((step, i) => {
|
|
22575
|
-
|
|
22576
|
-
const attributes = step.excludedDirectives.map(({ attribute }) => attribute).join(', ');
|
|
22577
|
-
const note = `${attributes.length} directives were excluded due to participants limit}`;
|
|
22578
|
-
readable.push(note);
|
|
22579
|
-
const excluded = `Excluded: ${attributes}`;
|
|
22580
|
-
readable.push(excluded);
|
|
22581
|
-
}
|
|
22582
|
-
else {
|
|
22583
|
-
const floatSort = (a, b) => parseFloat(step.reversed ? a : b) - parseFloat(step.reversed ? b : a);
|
|
22584
|
-
const participantsCount = step.groups
|
|
22585
|
-
? Object.values(step.groups).flat(Infinity).length
|
|
22586
|
-
: (step.participantIds?.length ?? 0);
|
|
22587
|
-
const getExplanation = (step) => {
|
|
22588
|
-
step.groups &&
|
|
22589
|
-
Object.keys(step.groups)
|
|
22590
|
-
.sort(floatSort)
|
|
22591
|
-
.forEach((key) => {
|
|
22592
|
-
const participantNames = step.groups[key]
|
|
22593
|
-
.map((participantId) => participants[participantId])
|
|
22594
|
-
.join(', ');
|
|
22595
|
-
const explanation = `${key} ${step.attribute}: ${participantNames}`;
|
|
22596
|
-
readable.push(explanation);
|
|
22597
|
-
});
|
|
22598
|
-
};
|
|
22599
|
-
const reversed = step.reversed ? ' in reverse order' : '';
|
|
22600
|
-
const action = step.groups ? 'grouped' : 'separated';
|
|
22601
|
-
const description = `Step ${i + 1}: ${participantsCount} particiants were ${action}${reversed} by ${step.attribute}`;
|
|
22602
|
-
readable.push(description);
|
|
22603
|
-
if (step.idsFilter) {
|
|
22604
|
-
const note = `${step.attribute} was calculated considering ONLY TIED PARTICIPANTS`;
|
|
22605
|
-
readable.push(note);
|
|
22606
|
-
}
|
|
22607
|
-
getExplanation(step);
|
|
22608
|
-
}
|
|
22609
|
-
readable.push('----------------------');
|
|
22614
|
+
processReportStep(step, i, participants, readable);
|
|
22610
22615
|
});
|
|
22611
22616
|
}
|
|
22612
22617
|
readable.push('Final Order:');
|
|
@@ -29082,7 +29087,10 @@ function generateScoreString(params) {
|
|
|
29082
29087
|
const t1 = side1TiebreakScore || (isNumeric(side1TiebreakScore) || (tbscores && autoComplete) ? 0 : '');
|
|
29083
29088
|
const t2 = side2TiebreakScore || (isNumeric(side2TiebreakScore) || (tbscores && autoComplete) ? 0 : '');
|
|
29084
29089
|
if (isTiebreakSet) {
|
|
29085
|
-
const
|
|
29090
|
+
const useGameScores = hasGameScores(currentSet) && !tbscores;
|
|
29091
|
+
const score1 = useGameScores ? side1Score : t1;
|
|
29092
|
+
const score2 = useGameScores ? side2Score : t2;
|
|
29093
|
+
const tiebreakScore = reverseScores ? [score2, score1] : [score1, score2];
|
|
29086
29094
|
return `[${tiebreakScore.join('-')}]`;
|
|
29087
29095
|
}
|
|
29088
29096
|
const lowTiebreakScore = tbscores ? Math.min(t1, t2) : '';
|
|
@@ -31902,6 +31910,29 @@ function handleRetired({ score, profile, applied }) {
|
|
|
31902
31910
|
}
|
|
31903
31911
|
return { score };
|
|
31904
31912
|
}
|
|
31913
|
+
function handleDefaulted({ score, profile, applied }) {
|
|
31914
|
+
score = score?.toString().toLowerCase();
|
|
31915
|
+
const re = /^(.*\d+.*)(def|defaulted)+[A-Za-z ]*$/;
|
|
31916
|
+
if (re.test(score)) {
|
|
31917
|
+
const [leading] = score.match(re).slice(1);
|
|
31918
|
+
applied.push('handleDefaulted');
|
|
31919
|
+
return { score: leading.trim(), matchUpStatus: 'defaulted', applied };
|
|
31920
|
+
}
|
|
31921
|
+
const providerDefaulted = profile?.matchUpStatuses?.defaulted;
|
|
31922
|
+
const additionalDefaulted = Array.isArray(providerDefaulted)
|
|
31923
|
+
? providerDefaulted
|
|
31924
|
+
: [providerDefaulted].filter(Boolean);
|
|
31925
|
+
const defaulted = ['dft', ...additionalDefaulted].find((def) => score?.endsWith(def));
|
|
31926
|
+
if (defaulted) {
|
|
31927
|
+
applied.push('handleDefaulted');
|
|
31928
|
+
return {
|
|
31929
|
+
matchUpStatus: 'defaulted',
|
|
31930
|
+
score: score?.replace(defaulted, '').trim(),
|
|
31931
|
+
applied,
|
|
31932
|
+
};
|
|
31933
|
+
}
|
|
31934
|
+
return { score };
|
|
31935
|
+
}
|
|
31905
31936
|
function removeDanglingBits({ score, attributes }) {
|
|
31906
31937
|
if (score.endsWith(' am') || score.endsWith(' pm'))
|
|
31907
31938
|
score = '';
|
|
@@ -32001,6 +32032,7 @@ const transforms = {
|
|
|
32001
32032
|
matchKnownPatterns: matchKnownPatterns,
|
|
32002
32033
|
removeDanglingBits: removeDanglingBits,
|
|
32003
32034
|
removeErroneous: removeErroneous,
|
|
32035
|
+
handleDefaulted: handleDefaulted,
|
|
32004
32036
|
handleWalkover: handleWalkover,
|
|
32005
32037
|
properTiebreak: properTiebreak,
|
|
32006
32038
|
handleNumeric: handleNumeric,
|
|
@@ -32019,6 +32051,7 @@ const processingOrder = [
|
|
|
32019
32051
|
'handleNumeric',
|
|
32020
32052
|
'handleWalkover',
|
|
32021
32053
|
'handleRetired',
|
|
32054
|
+
'handleDefaulted',
|
|
32022
32055
|
'replaceOh',
|
|
32023
32056
|
'stringScore',
|
|
32024
32057
|
'punctuationAdjustments',
|
|
@@ -32114,6 +32147,185 @@ var help = {
|
|
|
32114
32147
|
tidyScore: tidyScore
|
|
32115
32148
|
};
|
|
32116
32149
|
|
|
32150
|
+
function validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete) {
|
|
32151
|
+
if (!matchUpFormat)
|
|
32152
|
+
return { isValid: true };
|
|
32153
|
+
const parsed = parse(matchUpFormat);
|
|
32154
|
+
if (!parsed)
|
|
32155
|
+
return { isValid: true };
|
|
32156
|
+
const setFormat = isDecidingSet && parsed.finalSetFormat ? parsed.finalSetFormat : parsed.setFormat;
|
|
32157
|
+
if (!setFormat)
|
|
32158
|
+
return { isValid: true };
|
|
32159
|
+
const { setTo, tiebreakAt, tiebreakFormat, tiebreakSet } = setFormat;
|
|
32160
|
+
const tiebreakSetTo = tiebreakSet?.tiebreakTo;
|
|
32161
|
+
const isTiebreakOnlyFormat = !!tiebreakSetTo && !setTo;
|
|
32162
|
+
const side1TiebreakScore = set.side1TiebreakScore;
|
|
32163
|
+
const side2TiebreakScore = set.side2TiebreakScore;
|
|
32164
|
+
const hasTiebreakScores = side1TiebreakScore !== undefined && side2TiebreakScore !== undefined;
|
|
32165
|
+
const side1Score = isTiebreakOnlyFormat && hasTiebreakScores ? side1TiebreakScore : set.side1Score || set.side1 || 0;
|
|
32166
|
+
const side2Score = isTiebreakOnlyFormat && hasTiebreakScores ? side2TiebreakScore : set.side2Score || set.side2 || 0;
|
|
32167
|
+
const winnerScore = Math.max(side1Score, side2Score);
|
|
32168
|
+
const loserScore = Math.min(side1Score, side2Score);
|
|
32169
|
+
const scoreDiff = winnerScore - loserScore;
|
|
32170
|
+
if (isTiebreakOnlyFormat) {
|
|
32171
|
+
if (allowIncomplete) {
|
|
32172
|
+
return { isValid: true };
|
|
32173
|
+
}
|
|
32174
|
+
if (side1Score === 0 && side2Score === 0) {
|
|
32175
|
+
return { isValid: false, error: 'Tiebreak-only set requires both scores' };
|
|
32176
|
+
}
|
|
32177
|
+
if (winnerScore < tiebreakSetTo) {
|
|
32178
|
+
return {
|
|
32179
|
+
isValid: false,
|
|
32180
|
+
error: `Tiebreak-only set winner must reach at least ${tiebreakSetTo}, got ${winnerScore}`,
|
|
32181
|
+
};
|
|
32182
|
+
}
|
|
32183
|
+
if (scoreDiff < 2) {
|
|
32184
|
+
return {
|
|
32185
|
+
isValid: false,
|
|
32186
|
+
error: `Tiebreak-only set must be won by at least 2 points, got ${winnerScore}-${loserScore}`,
|
|
32187
|
+
};
|
|
32188
|
+
}
|
|
32189
|
+
if (winnerScore === tiebreakSetTo && loserScore > tiebreakSetTo - 2) {
|
|
32190
|
+
return {
|
|
32191
|
+
isValid: false,
|
|
32192
|
+
error: `Tiebreak-only set at ${tiebreakSetTo}-${loserScore} requires playing past ${tiebreakSetTo}`,
|
|
32193
|
+
};
|
|
32194
|
+
}
|
|
32195
|
+
if (winnerScore > tiebreakSetTo && scoreDiff !== 2) {
|
|
32196
|
+
return {
|
|
32197
|
+
isValid: false,
|
|
32198
|
+
error: `Tiebreak-only set past ${tiebreakSetTo} must be won by exactly 2 points, got ${winnerScore}-${loserScore}`,
|
|
32199
|
+
};
|
|
32200
|
+
}
|
|
32201
|
+
return { isValid: true };
|
|
32202
|
+
}
|
|
32203
|
+
const hasExplicitTiebreak = side1TiebreakScore !== undefined || side2TiebreakScore !== undefined;
|
|
32204
|
+
const isImplicitTiebreak = setTo && winnerScore === setTo + 1 && loserScore === setTo;
|
|
32205
|
+
const hasTiebreak = hasExplicitTiebreak || isImplicitTiebreak;
|
|
32206
|
+
if (hasTiebreak) {
|
|
32207
|
+
if (setTo) {
|
|
32208
|
+
if (winnerScore !== setTo + 1) {
|
|
32209
|
+
return {
|
|
32210
|
+
isValid: false,
|
|
32211
|
+
error: `Tiebreak set winner must have ${setTo + 1} games, got ${winnerScore}`,
|
|
32212
|
+
};
|
|
32213
|
+
}
|
|
32214
|
+
if (loserScore !== setTo) {
|
|
32215
|
+
return {
|
|
32216
|
+
isValid: false,
|
|
32217
|
+
error: `Tiebreak set loser must have ${setTo} games when tied, got ${loserScore}`,
|
|
32218
|
+
};
|
|
32219
|
+
}
|
|
32220
|
+
}
|
|
32221
|
+
if (hasExplicitTiebreak && tiebreakFormat) {
|
|
32222
|
+
const tbWinnerScore = Math.max(side1TiebreakScore || 0, side2TiebreakScore || 0);
|
|
32223
|
+
const tbLoserScore = Math.min(side1TiebreakScore || 0, side2TiebreakScore || 0);
|
|
32224
|
+
const tbDiff = tbWinnerScore - tbLoserScore;
|
|
32225
|
+
const tbTo = tiebreakFormat.tiebreakTo || 7;
|
|
32226
|
+
if (tbWinnerScore < tbTo) {
|
|
32227
|
+
return {
|
|
32228
|
+
isValid: false,
|
|
32229
|
+
error: `Tiebreak winner must reach ${tbTo} points, got ${tbWinnerScore}`,
|
|
32230
|
+
};
|
|
32231
|
+
}
|
|
32232
|
+
if (tbDiff < 2) {
|
|
32233
|
+
return {
|
|
32234
|
+
isValid: false,
|
|
32235
|
+
error: `Tiebreak must be won by 2 points, got ${tbWinnerScore}-${tbLoserScore}`,
|
|
32236
|
+
};
|
|
32237
|
+
}
|
|
32238
|
+
if (tbLoserScore >= tbTo - 1 && tbDiff > 2) {
|
|
32239
|
+
return {
|
|
32240
|
+
isValid: false,
|
|
32241
|
+
error: `Tiebreak score ${tbWinnerScore}-${tbLoserScore} is invalid`,
|
|
32242
|
+
};
|
|
32243
|
+
}
|
|
32244
|
+
}
|
|
32245
|
+
}
|
|
32246
|
+
else {
|
|
32247
|
+
if (setTo && tiebreakAt) {
|
|
32248
|
+
if (side1Score === setTo + 1 && side2Score < setTo - 1) {
|
|
32249
|
+
return {
|
|
32250
|
+
isValid: false,
|
|
32251
|
+
error: `With tiebreak format, if side 1 has ${setTo + 1} games, side 2 must be at least ${setTo - 1}, got ${side2Score}`,
|
|
32252
|
+
};
|
|
32253
|
+
}
|
|
32254
|
+
if (side2Score === setTo + 1 && side1Score < setTo - 1) {
|
|
32255
|
+
return {
|
|
32256
|
+
isValid: false,
|
|
32257
|
+
error: `With tiebreak format, if side 2 has ${setTo + 1} games, side 1 must be at least ${setTo - 1}, got ${side1Score}`,
|
|
32258
|
+
};
|
|
32259
|
+
}
|
|
32260
|
+
}
|
|
32261
|
+
if (allowIncomplete) {
|
|
32262
|
+
if (setTo && (winnerScore > setTo + 10 || loserScore > setTo + 10)) {
|
|
32263
|
+
return {
|
|
32264
|
+
isValid: false,
|
|
32265
|
+
error: `Set score ${winnerScore}-${loserScore} exceeds expected range for ${setTo}-game sets`,
|
|
32266
|
+
};
|
|
32267
|
+
}
|
|
32268
|
+
return { isValid: true };
|
|
32269
|
+
}
|
|
32270
|
+
if (setTo && winnerScore < setTo) {
|
|
32271
|
+
return {
|
|
32272
|
+
isValid: false,
|
|
32273
|
+
error: `Set winner must reach ${setTo} games, got ${winnerScore}`,
|
|
32274
|
+
};
|
|
32275
|
+
}
|
|
32276
|
+
if (scoreDiff < 2) {
|
|
32277
|
+
return {
|
|
32278
|
+
isValid: false,
|
|
32279
|
+
error: `Set must be won by at least 2 games, got ${winnerScore}-${loserScore}`,
|
|
32280
|
+
};
|
|
32281
|
+
}
|
|
32282
|
+
if (tiebreakAt) {
|
|
32283
|
+
if (loserScore >= tiebreakAt) {
|
|
32284
|
+
return {
|
|
32285
|
+
isValid: false,
|
|
32286
|
+
error: `When tied at ${tiebreakAt}-${tiebreakAt}, must play tiebreak. Use format like ${tiebreakAt + 1}-${tiebreakAt}(5)`,
|
|
32287
|
+
};
|
|
32288
|
+
}
|
|
32289
|
+
if (winnerScore > setTo + 1) {
|
|
32290
|
+
return {
|
|
32291
|
+
isValid: false,
|
|
32292
|
+
error: `With tiebreak format, set score cannot exceed ${setTo + 1}-${setTo - 1}. Got ${winnerScore}-${loserScore}`,
|
|
32293
|
+
};
|
|
32294
|
+
}
|
|
32295
|
+
}
|
|
32296
|
+
else if (winnerScore > setTo + 10) {
|
|
32297
|
+
return {
|
|
32298
|
+
isValid: false,
|
|
32299
|
+
error: `Set score ${winnerScore}-${loserScore} exceeds reasonable limits`,
|
|
32300
|
+
};
|
|
32301
|
+
}
|
|
32302
|
+
}
|
|
32303
|
+
return { isValid: true };
|
|
32304
|
+
}
|
|
32305
|
+
function validateMatchUpScore(sets, matchUpFormat, matchUpStatus) {
|
|
32306
|
+
if (!sets || sets.length === 0) {
|
|
32307
|
+
return { isValid: true };
|
|
32308
|
+
}
|
|
32309
|
+
const bestOfMatch = matchUpFormat?.match(/SET(\d+)/)?.[1];
|
|
32310
|
+
const bestOfSets = bestOfMatch ? Number.parseInt(bestOfMatch) : 3;
|
|
32311
|
+
const isIrregularEnding = [RETIRED$1, WALKOVER$2, DEFAULTED].includes(matchUpStatus || '');
|
|
32312
|
+
for (let i = 0; i < sets.length; i++) {
|
|
32313
|
+
const set = sets[i];
|
|
32314
|
+
const isDecidingSet = i + 1 === bestOfSets;
|
|
32315
|
+
const setHasWinner = set.winningSide !== undefined;
|
|
32316
|
+
const matchInProgress = matchUpStatus === undefined;
|
|
32317
|
+
const allowIncomplete = isIrregularEnding || (matchInProgress && !setHasWinner);
|
|
32318
|
+
const setValidation = validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete);
|
|
32319
|
+
if (!setValidation.isValid) {
|
|
32320
|
+
return {
|
|
32321
|
+
isValid: false,
|
|
32322
|
+
error: `Set ${i + 1}: ${setValidation.error}`,
|
|
32323
|
+
};
|
|
32324
|
+
}
|
|
32325
|
+
}
|
|
32326
|
+
return { isValid: true };
|
|
32327
|
+
}
|
|
32328
|
+
|
|
32117
32329
|
function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, winningSide, score, }) {
|
|
32118
32330
|
const sets = score?.sets ?? [];
|
|
32119
32331
|
const completedSets = sets?.filter((set) => set?.winningSide) || [];
|
|
@@ -32126,7 +32338,9 @@ function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, win
|
|
|
32126
32338
|
return counts;
|
|
32127
32339
|
}, [0, 0]);
|
|
32128
32340
|
const matchUpWinningSideIndex = winningSide ? winningSide - 1 : undefined;
|
|
32129
|
-
const matchUpLosingSideIndex = matchUpWinningSideIndex !== undefined
|
|
32341
|
+
const matchUpLosingSideIndex = matchUpWinningSideIndex !== undefined && [0, 1].includes(matchUpWinningSideIndex)
|
|
32342
|
+
? 1 - matchUpWinningSideIndex
|
|
32343
|
+
: undefined;
|
|
32130
32344
|
const winningSideSetsCount = matchUpWinningSideIndex !== undefined && setsWinCounts[matchUpWinningSideIndex];
|
|
32131
32345
|
const losingSideSetsCount = matchUpLosingSideIndex !== undefined && setsWinCounts[matchUpLosingSideIndex];
|
|
32132
32346
|
const matchUpScoringFormat = matchUpFormat ? parse(matchUpFormat) : undefined;
|
|
@@ -32289,32 +32503,80 @@ function getHighTiebreakValue(params) {
|
|
|
32289
32503
|
return tiebreakTo;
|
|
32290
32504
|
}
|
|
32291
32505
|
|
|
32292
|
-
function parseScoreString({ tiebreakTo = 7, scoreString = '' }) {
|
|
32506
|
+
function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
32507
|
+
let parsedFormat;
|
|
32508
|
+
let bestOfSets = 3;
|
|
32509
|
+
if (matchUpFormat) {
|
|
32510
|
+
try {
|
|
32511
|
+
parsedFormat = parse(matchUpFormat);
|
|
32512
|
+
const bestOfMatch = matchUpFormat?.match(/SET(\d+)/)?.[1];
|
|
32513
|
+
bestOfSets = bestOfMatch ? Number.parseInt(bestOfMatch) : 3;
|
|
32514
|
+
}
|
|
32515
|
+
catch (_e) {
|
|
32516
|
+
}
|
|
32517
|
+
}
|
|
32293
32518
|
return scoreString
|
|
32294
32519
|
?.split(' ')
|
|
32295
32520
|
.filter(Boolean)
|
|
32296
32521
|
.map((set, index) => parseSet({ set, setNumber: index + 1 }));
|
|
32297
32522
|
function parseSet({ set, setNumber }) {
|
|
32298
32523
|
const inParentheses = /\(([^)]+)\)/;
|
|
32299
|
-
const inBrackets = /\[([
|
|
32524
|
+
const inBrackets = /\[([^\]]+)\]/;
|
|
32300
32525
|
const tiebreak = inParentheses.exec(set);
|
|
32301
|
-
const
|
|
32302
|
-
const
|
|
32303
|
-
|
|
32304
|
-
|
|
32305
|
-
|
|
32306
|
-
|
|
32307
|
-
|
|
32308
|
-
|
|
32309
|
-
|
|
32310
|
-
|
|
32311
|
-
|
|
32312
|
-
|
|
32313
|
-
|
|
32314
|
-
|
|
32315
|
-
|
|
32316
|
-
|
|
32317
|
-
|
|
32526
|
+
const bracketed = inBrackets.exec(set);
|
|
32527
|
+
const isTiebreakOnlySet = set?.startsWith('[') && bracketed;
|
|
32528
|
+
let isTiebreakOnlyFormat = false;
|
|
32529
|
+
if (parsedFormat && isTiebreakOnlySet) {
|
|
32530
|
+
const isDecidingSet = setNumber === bestOfSets;
|
|
32531
|
+
const setFormat = isDecidingSet && parsedFormat.finalSetFormat ? parsedFormat.finalSetFormat : parsedFormat.setFormat;
|
|
32532
|
+
if (setFormat) {
|
|
32533
|
+
const tiebreakSetTo = setFormat.tiebreakSet?.tiebreakTo;
|
|
32534
|
+
const regularSetTo = setFormat.setTo;
|
|
32535
|
+
isTiebreakOnlyFormat = !!tiebreakSetTo && !regularSetTo;
|
|
32536
|
+
}
|
|
32537
|
+
}
|
|
32538
|
+
let side1Score;
|
|
32539
|
+
let side2Score;
|
|
32540
|
+
let side1TiebreakScore;
|
|
32541
|
+
let side2TiebreakScore;
|
|
32542
|
+
let winningSide;
|
|
32543
|
+
if (isTiebreakOnlySet) {
|
|
32544
|
+
const bracketedScores = bracketed[1].split('-').map((score) => parseInt(score));
|
|
32545
|
+
if (isTiebreakOnlyFormat) {
|
|
32546
|
+
side1Score = bracketedScores[0];
|
|
32547
|
+
side2Score = bracketedScores[1];
|
|
32548
|
+
winningSide = (side1Score > side2Score && 1) || (side1Score < side2Score && 2) || undefined;
|
|
32549
|
+
}
|
|
32550
|
+
else {
|
|
32551
|
+
side1TiebreakScore = bracketedScores[0];
|
|
32552
|
+
side2TiebreakScore = bracketedScores[1];
|
|
32553
|
+
winningSide =
|
|
32554
|
+
(side1TiebreakScore > side2TiebreakScore && 1) || (side1TiebreakScore < side2TiebreakScore && 2) || undefined;
|
|
32555
|
+
}
|
|
32556
|
+
}
|
|
32557
|
+
else {
|
|
32558
|
+
const setString = (tiebreak && set.replace(tiebreak[0], '')) || (bracketed && set.replace(bracketed[0], '')) || set;
|
|
32559
|
+
const setScores = setString.split('-').map((score) => Number.parseInt(score));
|
|
32560
|
+
side1Score = setScores[0];
|
|
32561
|
+
side2Score = setScores[1];
|
|
32562
|
+
winningSide = (side1Score > side2Score && 1) || (side1Score < side2Score && 2) || undefined;
|
|
32563
|
+
if (tiebreak) {
|
|
32564
|
+
const setTiebreakLowScore = tiebreak[1];
|
|
32565
|
+
const side1TiebreakPerspective = getTiebreakComplement({
|
|
32566
|
+
lowValue: setTiebreakLowScore,
|
|
32567
|
+
isSide1: winningSide === 2,
|
|
32568
|
+
tiebreakTo,
|
|
32569
|
+
});
|
|
32570
|
+
if (Array.isArray(side1TiebreakPerspective)) {
|
|
32571
|
+
[side1TiebreakScore, side2TiebreakScore] = side1TiebreakPerspective;
|
|
32572
|
+
}
|
|
32573
|
+
}
|
|
32574
|
+
if (bracketed && !isTiebreakOnlySet) {
|
|
32575
|
+
const matchTiebreakScores = bracketed[1].split('-').map((score) => Number.parseInt(score));
|
|
32576
|
+
side1TiebreakScore = matchTiebreakScores[0];
|
|
32577
|
+
side2TiebreakScore = matchTiebreakScores[1];
|
|
32578
|
+
}
|
|
32579
|
+
}
|
|
32318
32580
|
return {
|
|
32319
32581
|
side1Score,
|
|
32320
32582
|
side2Score,
|
|
@@ -32596,7 +32858,9 @@ var query$a = {
|
|
|
32596
32858
|
getTiebreakComplement: getTiebreakComplement,
|
|
32597
32859
|
isValidMatchUpFormat: isValidMatchUpFormat,
|
|
32598
32860
|
parseScoreString: parseScoreString,
|
|
32861
|
+
validateMatchUpScore: validateMatchUpScore,
|
|
32599
32862
|
validateScore: validateScore,
|
|
32863
|
+
validateSetScore: validateSetScore,
|
|
32600
32864
|
validateTieFormat: validateTieFormat
|
|
32601
32865
|
};
|
|
32602
32866
|
|
|
@@ -32631,7 +32895,9 @@ var scoreGovernor = {
|
|
|
32631
32895
|
tidyScore: tidyScore,
|
|
32632
32896
|
umo: umo,
|
|
32633
32897
|
undo: undo,
|
|
32898
|
+
validateMatchUpScore: validateMatchUpScore,
|
|
32634
32899
|
validateScore: validateScore,
|
|
32900
|
+
validateSetScore: validateSetScore,
|
|
32635
32901
|
validateTieFormat: validateTieFormat
|
|
32636
32902
|
};
|
|
32637
32903
|
|
|
@@ -45988,8 +46254,7 @@ function progressExitStatus({ sourceMatchUpStatusCodes, propagateExitStatus, sou
|
|
|
45988
46254
|
color: 'magenta',
|
|
45989
46255
|
method: stack,
|
|
45990
46256
|
});
|
|
45991
|
-
const carryOverMatchUpStatus = (isExit(sourceMatchUpStatus) &&
|
|
45992
|
-
|| WALKOVER$2;
|
|
46257
|
+
const carryOverMatchUpStatus = (isExit(sourceMatchUpStatus) && sourceMatchUpStatus !== RETIRED$1 && sourceMatchUpStatus) || WALKOVER$2;
|
|
45993
46258
|
const inContextMatchUps = getAllDrawMatchUps({
|
|
45994
46259
|
inContext: true,
|
|
45995
46260
|
drawDefinition,
|
|
@@ -46854,7 +47119,22 @@ function generateOutcomeFromScoreString(params) {
|
|
|
46854
47119
|
};
|
|
46855
47120
|
if (winningSide && ![1, 2, undefined].includes(winningSide))
|
|
46856
47121
|
return { error: INVALID_VALUES, winningSide };
|
|
46857
|
-
const neutralParsedSets = scoreString && parseScoreString({ scoreString });
|
|
47122
|
+
const neutralParsedSets = scoreString && parseScoreString({ scoreString, matchUpFormat });
|
|
47123
|
+
const isBracketNotation = scoreString?.trim().startsWith('[');
|
|
47124
|
+
let inferredWinningSide = winningSide;
|
|
47125
|
+
if (!inferredWinningSide && matchUpFormat && neutralParsedSets) {
|
|
47126
|
+
const setsWon = { side1: 0, side2: 0 };
|
|
47127
|
+
neutralParsedSets.forEach((set) => {
|
|
47128
|
+
if (set.winningSide === 1)
|
|
47129
|
+
setsWon.side1++;
|
|
47130
|
+
else if (set.winningSide === 2)
|
|
47131
|
+
setsWon.side2++;
|
|
47132
|
+
});
|
|
47133
|
+
if (setsWon.side1 > setsWon.side2)
|
|
47134
|
+
inferredWinningSide = 1;
|
|
47135
|
+
else if (setsWon.side2 > setsWon.side1)
|
|
47136
|
+
inferredWinningSide = 2;
|
|
47137
|
+
}
|
|
46858
47138
|
const score = {};
|
|
46859
47139
|
const winningScoreString = generateScoreString({
|
|
46860
47140
|
sets: neutralParsedSets,
|
|
@@ -46867,7 +47147,11 @@ function generateOutcomeFromScoreString(params) {
|
|
|
46867
47147
|
matchUpFormat,
|
|
46868
47148
|
setTBlast,
|
|
46869
47149
|
});
|
|
46870
|
-
if (
|
|
47150
|
+
if (isBracketNotation) {
|
|
47151
|
+
score.scoreStringSide1 = winningScoreString;
|
|
47152
|
+
score.scoreStringSide2 = losingScoreString;
|
|
47153
|
+
}
|
|
47154
|
+
else if (inferredWinningSide === 2) {
|
|
46871
47155
|
score.scoreStringSide1 = losingScoreString;
|
|
46872
47156
|
score.scoreStringSide2 = winningScoreString;
|
|
46873
47157
|
}
|
|
@@ -46875,11 +47159,11 @@ function generateOutcomeFromScoreString(params) {
|
|
|
46875
47159
|
score.scoreStringSide1 = winningScoreString;
|
|
46876
47160
|
score.scoreStringSide2 = losingScoreString;
|
|
46877
47161
|
}
|
|
46878
|
-
score.sets = parseScoreString({ scoreString: score.scoreStringSide1 });
|
|
47162
|
+
score.sets = parseScoreString({ scoreString: score.scoreStringSide1, matchUpFormat });
|
|
46879
47163
|
return definedAttributes({
|
|
46880
47164
|
outcome: {
|
|
46881
47165
|
matchUpStatus,
|
|
46882
|
-
winningSide,
|
|
47166
|
+
winningSide: inferredWinningSide,
|
|
46883
47167
|
score,
|
|
46884
47168
|
},
|
|
46885
47169
|
});
|