tods-competition-factory 2.2.35 → 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 +2 -2
- package/dist/tods-competition-factory.development.cjs.js +47 -30
- 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
|
@@ -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';
|
|
@@ -32159,10 +32159,11 @@ function validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete) {
|
|
|
32159
32159
|
const { setTo, tiebreakAt, tiebreakFormat, tiebreakSet } = setFormat;
|
|
32160
32160
|
const tiebreakSetTo = tiebreakSet?.tiebreakTo;
|
|
32161
32161
|
const isTiebreakOnlyFormat = !!tiebreakSetTo && !setTo;
|
|
32162
|
-
const side1Score = set.side1Score || 0;
|
|
32163
|
-
const side2Score = set.side2Score || 0;
|
|
32164
32162
|
const side1TiebreakScore = set.side1TiebreakScore;
|
|
32165
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;
|
|
32166
32167
|
const winnerScore = Math.max(side1Score, side2Score);
|
|
32167
32168
|
const loserScore = Math.min(side1Score, side2Score);
|
|
32168
32169
|
const scoreDiff = winnerScore - loserScore;
|
|
@@ -32179,26 +32180,31 @@ function validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete) {
|
|
|
32179
32180
|
error: `Tiebreak-only set winner must reach at least ${tiebreakSetTo}, got ${winnerScore}`,
|
|
32180
32181
|
};
|
|
32181
32182
|
}
|
|
32182
|
-
if (
|
|
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) {
|
|
32183
32190
|
return {
|
|
32184
32191
|
isValid: false,
|
|
32185
|
-
error: `Tiebreak-only set
|
|
32192
|
+
error: `Tiebreak-only set at ${tiebreakSetTo}-${loserScore} requires playing past ${tiebreakSetTo}`,
|
|
32186
32193
|
};
|
|
32187
32194
|
}
|
|
32188
|
-
if (scoreDiff !== 2) {
|
|
32195
|
+
if (winnerScore > tiebreakSetTo && scoreDiff !== 2) {
|
|
32189
32196
|
return {
|
|
32190
32197
|
isValid: false,
|
|
32191
|
-
error: `Tiebreak-only set must be won by exactly 2 points, got ${winnerScore}-${loserScore}`,
|
|
32198
|
+
error: `Tiebreak-only set past ${tiebreakSetTo} must be won by exactly 2 points, got ${winnerScore}-${loserScore}`,
|
|
32192
32199
|
};
|
|
32193
32200
|
}
|
|
32194
32201
|
return { isValid: true };
|
|
32195
32202
|
}
|
|
32196
32203
|
const hasExplicitTiebreak = side1TiebreakScore !== undefined || side2TiebreakScore !== undefined;
|
|
32197
32204
|
const isImplicitTiebreak = setTo && winnerScore === setTo + 1 && loserScore === setTo;
|
|
32198
|
-
const
|
|
32199
|
-
const hasTiebreak = hasExplicitTiebreak || isImplicitTiebreak || isLikelyTiebreak;
|
|
32205
|
+
const hasTiebreak = hasExplicitTiebreak || isImplicitTiebreak;
|
|
32200
32206
|
if (hasTiebreak) {
|
|
32201
|
-
if (setTo
|
|
32207
|
+
if (setTo) {
|
|
32202
32208
|
if (winnerScore !== setTo + 1) {
|
|
32203
32209
|
return {
|
|
32204
32210
|
isValid: false,
|
|
@@ -32287,13 +32293,11 @@ function validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete) {
|
|
|
32287
32293
|
};
|
|
32288
32294
|
}
|
|
32289
32295
|
}
|
|
32290
|
-
else {
|
|
32291
|
-
|
|
32292
|
-
|
|
32293
|
-
|
|
32294
|
-
|
|
32295
|
-
};
|
|
32296
|
-
}
|
|
32296
|
+
else if (winnerScore > setTo + 10) {
|
|
32297
|
+
return {
|
|
32298
|
+
isValid: false,
|
|
32299
|
+
error: `Set score ${winnerScore}-${loserScore} exceeds reasonable limits`,
|
|
32300
|
+
};
|
|
32297
32301
|
}
|
|
32298
32302
|
}
|
|
32299
32303
|
return { isValid: true };
|
|
@@ -32304,12 +32308,14 @@ function validateMatchUpScore(sets, matchUpFormat, matchUpStatus) {
|
|
|
32304
32308
|
}
|
|
32305
32309
|
const bestOfMatch = matchUpFormat?.match(/SET(\d+)/)?.[1];
|
|
32306
32310
|
const bestOfSets = bestOfMatch ? Number.parseInt(bestOfMatch) : 3;
|
|
32307
|
-
const hasIncompleteSet = sets.some((set) => !set.winningSide);
|
|
32308
32311
|
const isIrregularEnding = [RETIRED$1, WALKOVER$2, DEFAULTED].includes(matchUpStatus || '');
|
|
32309
|
-
const allowIncomplete = isIrregularEnding || (!matchUpStatus && hasIncompleteSet);
|
|
32310
32312
|
for (let i = 0; i < sets.length; i++) {
|
|
32311
|
-
const
|
|
32312
|
-
const
|
|
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);
|
|
32313
32319
|
if (!setValidation.isValid) {
|
|
32314
32320
|
return {
|
|
32315
32321
|
isValid: false,
|
|
@@ -32498,15 +32504,15 @@ function getHighTiebreakValue(params) {
|
|
|
32498
32504
|
}
|
|
32499
32505
|
|
|
32500
32506
|
function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
32501
|
-
let
|
|
32507
|
+
let parsedFormat;
|
|
32508
|
+
let bestOfSets = 3;
|
|
32502
32509
|
if (matchUpFormat) {
|
|
32503
32510
|
try {
|
|
32504
|
-
|
|
32505
|
-
const
|
|
32506
|
-
|
|
32507
|
-
isTiebreakOnlyFormat = !!tiebreakSetTo && !regularSetTo;
|
|
32511
|
+
parsedFormat = parse(matchUpFormat);
|
|
32512
|
+
const bestOfMatch = matchUpFormat?.match(/SET(\d+)/)?.[1];
|
|
32513
|
+
bestOfSets = bestOfMatch ? Number.parseInt(bestOfMatch) : 3;
|
|
32508
32514
|
}
|
|
32509
|
-
catch (
|
|
32515
|
+
catch (_e) {
|
|
32510
32516
|
}
|
|
32511
32517
|
}
|
|
32512
32518
|
return scoreString
|
|
@@ -32519,6 +32525,16 @@ function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
|
32519
32525
|
const tiebreak = inParentheses.exec(set);
|
|
32520
32526
|
const bracketed = inBrackets.exec(set);
|
|
32521
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
|
+
}
|
|
32522
32538
|
let side1Score;
|
|
32523
32539
|
let side2Score;
|
|
32524
32540
|
let side1TiebreakScore;
|
|
@@ -32534,12 +32550,13 @@ function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
|
32534
32550
|
else {
|
|
32535
32551
|
side1TiebreakScore = bracketedScores[0];
|
|
32536
32552
|
side2TiebreakScore = bracketedScores[1];
|
|
32537
|
-
winningSide =
|
|
32553
|
+
winningSide =
|
|
32554
|
+
(side1TiebreakScore > side2TiebreakScore && 1) || (side1TiebreakScore < side2TiebreakScore && 2) || undefined;
|
|
32538
32555
|
}
|
|
32539
32556
|
}
|
|
32540
32557
|
else {
|
|
32541
32558
|
const setString = (tiebreak && set.replace(tiebreak[0], '')) || (bracketed && set.replace(bracketed[0], '')) || set;
|
|
32542
|
-
const setScores = setString.split('-').map((score) => parseInt(score));
|
|
32559
|
+
const setScores = setString.split('-').map((score) => Number.parseInt(score));
|
|
32543
32560
|
side1Score = setScores[0];
|
|
32544
32561
|
side2Score = setScores[1];
|
|
32545
32562
|
winningSide = (side1Score > side2Score && 1) || (side1Score < side2Score && 2) || undefined;
|
|
@@ -32555,7 +32572,7 @@ function parseScoreString({ tiebreakTo = 7, scoreString = '', matchUpFormat }) {
|
|
|
32555
32572
|
}
|
|
32556
32573
|
}
|
|
32557
32574
|
if (bracketed && !isTiebreakOnlySet) {
|
|
32558
|
-
const matchTiebreakScores = bracketed[1].split('-').map((score) => parseInt(score));
|
|
32575
|
+
const matchTiebreakScores = bracketed[1].split('-').map((score) => Number.parseInt(score));
|
|
32559
32576
|
side1TiebreakScore = matchTiebreakScores[0];
|
|
32560
32577
|
side2TiebreakScore = matchTiebreakScores[1];
|
|
32561
32578
|
}
|