tods-competition-factory 2.2.40 → 2.2.41
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 +6 -6
- package/dist/tods-competition-factory.development.cjs.js +87 -33
- 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.41';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const SINGLES_MATCHUP = 'SINGLES';
|
|
@@ -32366,6 +32366,24 @@ function validateSetScore(set, matchUpFormat, isDecidingSet, allowIncomplete) {
|
|
|
32366
32366
|
const setFormat = isDecidingSet && parsed.finalSetFormat ? parsed.finalSetFormat : parsed.setFormat;
|
|
32367
32367
|
if (!setFormat)
|
|
32368
32368
|
return { isValid: true };
|
|
32369
|
+
if (setFormat.timed) {
|
|
32370
|
+
if (!allowIncomplete) {
|
|
32371
|
+
const side1Score = set.side1Score ?? 0;
|
|
32372
|
+
const side2Score = set.side2Score ?? 0;
|
|
32373
|
+
if (side1Score === 0 && side2Score === 0) {
|
|
32374
|
+
return { isValid: false, error: 'Timed set requires at least one side to have scored' };
|
|
32375
|
+
}
|
|
32376
|
+
if (setFormat.based === 'P') {
|
|
32377
|
+
if (side1Score === side2Score && side1Score > 0 && setFormat.tiebreakFormat) {
|
|
32378
|
+
const hasTiebreak = set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined;
|
|
32379
|
+
if (!hasTiebreak) {
|
|
32380
|
+
return { isValid: false, error: 'Tied timed set requires tiebreak' };
|
|
32381
|
+
}
|
|
32382
|
+
}
|
|
32383
|
+
}
|
|
32384
|
+
}
|
|
32385
|
+
return { isValid: true };
|
|
32386
|
+
}
|
|
32369
32387
|
const { setTo, tiebreakAt, tiebreakFormat, tiebreakSet } = setFormat;
|
|
32370
32388
|
const tiebreakSetTo = tiebreakSet?.tiebreakTo;
|
|
32371
32389
|
const isTiebreakOnlyFormat = !!tiebreakSetTo && !setTo;
|
|
@@ -47237,43 +47255,79 @@ function generateOutcomeFromScoreString(params) {
|
|
|
47237
47255
|
const isBracketNotation = scoreString?.trim().startsWith('[');
|
|
47238
47256
|
let inferredWinningSide = winningSide;
|
|
47239
47257
|
if (!inferredWinningSide && matchUpFormat && neutralParsedSets) {
|
|
47240
|
-
const
|
|
47241
|
-
|
|
47242
|
-
|
|
47243
|
-
|
|
47244
|
-
|
|
47245
|
-
|
|
47246
|
-
|
|
47247
|
-
|
|
47248
|
-
|
|
47249
|
-
|
|
47250
|
-
|
|
47258
|
+
const parsedFormat = parse(matchUpFormat);
|
|
47259
|
+
const isAggregateScoring = parsedFormat?.setFormat?.based === 'A' || parsedFormat?.finalSetFormat?.based === 'A';
|
|
47260
|
+
if (isAggregateScoring) {
|
|
47261
|
+
const aggregateTotals = neutralParsedSets.reduce((totals, set) => {
|
|
47262
|
+
if (set.side1Score !== undefined || set.side2Score !== undefined) {
|
|
47263
|
+
totals.side1 += set.side1Score ?? 0;
|
|
47264
|
+
totals.side2 += set.side2Score ?? 0;
|
|
47265
|
+
}
|
|
47266
|
+
return totals;
|
|
47267
|
+
}, { side1: 0, side2: 0 });
|
|
47268
|
+
if (aggregateTotals.side1 > aggregateTotals.side2)
|
|
47269
|
+
inferredWinningSide = 1;
|
|
47270
|
+
else if (aggregateTotals.side2 > aggregateTotals.side1)
|
|
47271
|
+
inferredWinningSide = 2;
|
|
47272
|
+
else {
|
|
47273
|
+
const tiebreakSet = neutralParsedSets.find((set) => set.side1TiebreakScore !== undefined || set.side2TiebreakScore !== undefined);
|
|
47274
|
+
if (tiebreakSet)
|
|
47275
|
+
inferredWinningSide = tiebreakSet.winningSide;
|
|
47276
|
+
}
|
|
47277
|
+
}
|
|
47278
|
+
else {
|
|
47279
|
+
const setsWon = { side1: 0, side2: 0 };
|
|
47280
|
+
neutralParsedSets.forEach((set) => {
|
|
47281
|
+
if (set.winningSide === 1)
|
|
47282
|
+
setsWon.side1++;
|
|
47283
|
+
else if (set.winningSide === 2)
|
|
47284
|
+
setsWon.side2++;
|
|
47285
|
+
});
|
|
47286
|
+
if (setsWon.side1 > setsWon.side2)
|
|
47287
|
+
inferredWinningSide = 1;
|
|
47288
|
+
else if (setsWon.side2 > setsWon.side1)
|
|
47289
|
+
inferredWinningSide = 2;
|
|
47290
|
+
}
|
|
47251
47291
|
}
|
|
47252
47292
|
const score = {};
|
|
47253
|
-
const
|
|
47254
|
-
|
|
47255
|
-
|
|
47256
|
-
|
|
47257
|
-
|
|
47258
|
-
|
|
47259
|
-
|
|
47260
|
-
|
|
47261
|
-
|
|
47262
|
-
|
|
47263
|
-
|
|
47264
|
-
|
|
47265
|
-
|
|
47266
|
-
|
|
47267
|
-
|
|
47268
|
-
else if (inferredWinningSide === 2) {
|
|
47269
|
-
score.scoreStringSide1 = losingScoreString;
|
|
47270
|
-
score.scoreStringSide2 = winningScoreString;
|
|
47293
|
+
const parsedFormat = parse(matchUpFormat);
|
|
47294
|
+
const isAggregateScoring = parsedFormat?.setFormat?.based === 'A' || parsedFormat?.finalSetFormat?.based === 'A';
|
|
47295
|
+
if (isBracketNotation || isAggregateScoring) {
|
|
47296
|
+
score.sets = parseScoreString({ scoreString, matchUpFormat });
|
|
47297
|
+
score.scoreStringSide1 = generateScoreString({
|
|
47298
|
+
sets: score.sets,
|
|
47299
|
+
matchUpFormat,
|
|
47300
|
+
setTBlast,
|
|
47301
|
+
});
|
|
47302
|
+
score.scoreStringSide2 = generateScoreString({
|
|
47303
|
+
sets: score.sets,
|
|
47304
|
+
reversed: true,
|
|
47305
|
+
matchUpFormat,
|
|
47306
|
+
setTBlast,
|
|
47307
|
+
});
|
|
47271
47308
|
}
|
|
47272
47309
|
else {
|
|
47273
|
-
|
|
47274
|
-
|
|
47310
|
+
const winningScoreString = generateScoreString({
|
|
47311
|
+
sets: neutralParsedSets,
|
|
47312
|
+
matchUpFormat,
|
|
47313
|
+
setTBlast,
|
|
47314
|
+
});
|
|
47315
|
+
const losingScoreString = generateScoreString({
|
|
47316
|
+
sets: neutralParsedSets,
|
|
47317
|
+
reversed: true,
|
|
47318
|
+
matchUpFormat,
|
|
47319
|
+
setTBlast,
|
|
47320
|
+
});
|
|
47321
|
+
if (inferredWinningSide === 2) {
|
|
47322
|
+
score.scoreStringSide1 = losingScoreString;
|
|
47323
|
+
score.scoreStringSide2 = winningScoreString;
|
|
47324
|
+
}
|
|
47325
|
+
else {
|
|
47326
|
+
score.scoreStringSide1 = winningScoreString;
|
|
47327
|
+
score.scoreStringSide2 = losingScoreString;
|
|
47328
|
+
}
|
|
47329
|
+
score.sets = parseScoreString({ scoreString: score.scoreStringSide1, matchUpFormat });
|
|
47275
47330
|
}
|
|
47276
|
-
score.sets = parseScoreString({ scoreString: score.scoreStringSide1, matchUpFormat });
|
|
47277
47331
|
return definedAttributes({
|
|
47278
47332
|
outcome: {
|
|
47279
47333
|
matchUpStatus,
|