tods-competition-factory 1.8.15 → 1.8.17
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.d.ts +1 -0
- package/dist/forge/generate.mjs +35 -25
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +1 -0
- package/dist/forge/query.mjs +1 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.d.ts +1 -0
- package/dist/forge/transform.mjs +35 -25
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +306 -31
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +463 -43
- 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 +4 -6
package/dist/forge/transform.mjs
CHANGED
|
@@ -2280,11 +2280,11 @@ function countSets({
|
|
|
2280
2280
|
score
|
|
2281
2281
|
}) {
|
|
2282
2282
|
const setsTally = [0, 0];
|
|
2283
|
-
const
|
|
2284
|
-
const matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
2283
|
+
const sets = score?.sets;
|
|
2284
|
+
const matchUpWinnerIndex = typeof matchUpWinningSide === "number" && matchUpWinningSide - 1;
|
|
2285
2285
|
const parsedMatchUpFormat = parse(matchUpFormat);
|
|
2286
2286
|
const setsToWin = getSetsToWin(parsedMatchUpFormat?.bestOf ?? 1);
|
|
2287
|
-
if (matchUpStatus === DEFAULTED && tallyPolicy?.setsCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.setsCreditForWalkovers) {
|
|
2287
|
+
if (typeof matchUpWinnerIndex === "number" && (matchUpStatus === DEFAULTED && tallyPolicy?.setsCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.setsCreditForWalkovers)) {
|
|
2288
2288
|
setsTally[matchUpWinnerIndex] = setsToWin;
|
|
2289
2289
|
} else {
|
|
2290
2290
|
for (const set of sets || []) {
|
|
@@ -2293,7 +2293,7 @@ function countSets({
|
|
|
2293
2293
|
setsTally[setWinningSide - 1] += 1;
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
2296
|
-
if (matchUpStatus === RETIRED) {
|
|
2296
|
+
if (typeof matchUpWinnerIndex === "number" && matchUpStatus === RETIRED) {
|
|
2297
2297
|
if (+setsTally[1 - matchUpWinnerIndex] === setsToWin)
|
|
2298
2298
|
setsTally[1 - matchUpWinnerIndex] -= 1;
|
|
2299
2299
|
if (tallyPolicy?.setsCreditForRetirements)
|
|
@@ -2311,13 +2311,13 @@ function countGames({
|
|
|
2311
2311
|
const { sets } = score || {};
|
|
2312
2312
|
if (!sets)
|
|
2313
2313
|
return [0, 0];
|
|
2314
|
-
const matchUpWinnerIndex = matchUpWinningSide - 1;
|
|
2314
|
+
const matchUpWinnerIndex = typeof matchUpWinningSide === "number" && matchUpWinningSide - 1;
|
|
2315
2315
|
const parsedMatchUpFormat = parse(matchUpFormat);
|
|
2316
2316
|
const bestOf = parsedMatchUpFormat?.bestOf ?? 1;
|
|
2317
2317
|
const setsToWin = getSetsToWin(bestOf);
|
|
2318
2318
|
const tiebreakAt = parsedMatchUpFormat?.setFormat?.tiebreakAt || 0;
|
|
2319
2319
|
const gamesTally = [[], []];
|
|
2320
|
-
if (matchUpStatus === DEFAULTED && tallyPolicy?.gamesCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.gamesCreditForWalkovers) {
|
|
2320
|
+
if (typeof matchUpWinnerIndex === "number" && (matchUpStatus === DEFAULTED && tallyPolicy?.gamesCreditForDefaults || matchUpStatus === WALKOVER$1 && tallyPolicy?.gamesCreditForWalkovers)) {
|
|
2321
2321
|
const gamesForSet = parsedMatchUpFormat?.setFormat?.setTo || 0;
|
|
2322
2322
|
const minimumGameWins = setsToWin * gamesForSet;
|
|
2323
2323
|
gamesTally[matchUpWinnerIndex].push(minimumGameWins);
|
|
@@ -2337,7 +2337,7 @@ function countGames({
|
|
|
2337
2337
|
}
|
|
2338
2338
|
});
|
|
2339
2339
|
}
|
|
2340
|
-
if (matchUpStatus === RETIRED) {
|
|
2340
|
+
if (matchUpStatus === RETIRED && typeof matchUpWinnerIndex === "number") {
|
|
2341
2341
|
const whichFormat = sets.length > setsToWin && parsedMatchUpFormat?.finalSetFormat ? "finalSetFormat" : "setFormat";
|
|
2342
2342
|
const format = parsedMatchUpFormat?.[whichFormat];
|
|
2343
2343
|
if (isGamesBased(format.based)) {
|
|
@@ -2377,10 +2377,14 @@ function countGames({
|
|
|
2377
2377
|
gamesTally[1].reduce((a, b) => a + b, 0)
|
|
2378
2378
|
];
|
|
2379
2379
|
}
|
|
2380
|
-
function countPoints({
|
|
2381
|
-
|
|
2380
|
+
function countPoints({
|
|
2381
|
+
matchUpFormat,
|
|
2382
|
+
score
|
|
2383
|
+
}) {
|
|
2384
|
+
const parsedMatchUpFormat = matchUpFormat ? parse(matchUpFormat) : void 0;
|
|
2382
2385
|
const bestOf = parsedMatchUpFormat?.bestOf ?? 1;
|
|
2383
2386
|
const setsToWin = getSetsToWin(bestOf);
|
|
2387
|
+
const tiebreaksTally = [0, 0];
|
|
2384
2388
|
const pointsTally = [0, 0];
|
|
2385
2389
|
score?.sets?.forEach((set, i) => {
|
|
2386
2390
|
const setNumber = set.setNumber || i + 1;
|
|
@@ -2397,9 +2401,11 @@ function countPoints({ matchUpFormat, score }) {
|
|
|
2397
2401
|
pointsTally[0] += ensureInt(set.side1TiebreakScore || 0);
|
|
2398
2402
|
if (set.side2TiebreakScore)
|
|
2399
2403
|
pointsTally[1] += ensureInt(set.side2TiebreakScore || 0);
|
|
2404
|
+
if ((set.side1TiebreakScore || set.side2TiebreakScore) && set.winningSide)
|
|
2405
|
+
tiebreaksTally[set.winningSide - 1] += 1;
|
|
2400
2406
|
}
|
|
2401
2407
|
});
|
|
2402
|
-
return pointsTally;
|
|
2408
|
+
return { pointsTally, tiebreaksTally };
|
|
2403
2409
|
}
|
|
2404
2410
|
function getSetsToWin(bestOfGames) {
|
|
2405
2411
|
return bestOfGames && Math.ceil(bestOfGames / 2) || 1;
|
|
@@ -2504,7 +2510,7 @@ function getParticipantResults({
|
|
|
2504
2510
|
const winningParticipantId = winningSide && getWinningSideId(matchUp);
|
|
2505
2511
|
const losingParticipantId = winningSide && getLosingSideId(matchUp);
|
|
2506
2512
|
if (!winningParticipantId && !losingParticipantId) {
|
|
2507
|
-
if (completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
2513
|
+
if (matchUpStatus && completedMatchUpStatuses.includes(matchUpStatus)) {
|
|
2508
2514
|
const participantIdSide1 = getSideId(matchUp, 0);
|
|
2509
2515
|
const participantIdSide2 = getSideId(matchUp, 1);
|
|
2510
2516
|
if (participantIdSide1) {
|
|
@@ -2519,10 +2525,10 @@ function getParticipantResults({
|
|
|
2519
2525
|
perPlayer = 0;
|
|
2520
2526
|
for (const tieMatchUp of tieMatchUps) {
|
|
2521
2527
|
if (tieMatchUp.winningSide) {
|
|
2522
|
-
const tieWinningParticipantId = sides
|
|
2528
|
+
const tieWinningParticipantId = sides?.find(
|
|
2523
2529
|
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
2524
2530
|
)?.participantId;
|
|
2525
|
-
const tieLosingParticipantId = sides
|
|
2531
|
+
const tieLosingParticipantId = sides?.find(
|
|
2526
2532
|
({ sideNumber }) => sideNumber === tieMatchUp.winningSide
|
|
2527
2533
|
)?.participantId;
|
|
2528
2534
|
if (tieWinningParticipantId && tieLosingParticipantId) {
|
|
@@ -2641,26 +2647,30 @@ function getParticipantResults({
|
|
|
2641
2647
|
}
|
|
2642
2648
|
}
|
|
2643
2649
|
if (manualGamesOverride) {
|
|
2644
|
-
const side1participantId = sides
|
|
2650
|
+
const side1participantId = sides?.find(
|
|
2645
2651
|
({ sideNumber }) => sideNumber === 1
|
|
2646
2652
|
)?.participantId;
|
|
2647
|
-
const side2participantId = sides
|
|
2653
|
+
const side2participantId = sides?.find(
|
|
2648
2654
|
({ sideNumber }) => sideNumber === 2
|
|
2649
2655
|
)?.participantId;
|
|
2650
2656
|
checkInitializeParticipant(participantResults, side1participantId);
|
|
2651
2657
|
checkInitializeParticipant(participantResults, side2participantId);
|
|
2652
|
-
const gamesWonSide1 = score
|
|
2653
|
-
(total, set) => total + set
|
|
2658
|
+
const gamesWonSide1 = score?.sets?.reduce(
|
|
2659
|
+
(total, set) => total + (set?.side1Score ?? 0),
|
|
2654
2660
|
0
|
|
2655
2661
|
);
|
|
2656
|
-
const gamesWonSide2 = score
|
|
2657
|
-
(total, set) => total + set.side2Score,
|
|
2662
|
+
const gamesWonSide2 = score?.sets?.reduce(
|
|
2663
|
+
(total, set) => total + (set.side2Score ?? 0),
|
|
2658
2664
|
0
|
|
2659
2665
|
);
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2666
|
+
if (side1participantId) {
|
|
2667
|
+
participantResults[side1participantId].gamesWon += gamesWonSide1;
|
|
2668
|
+
participantResults[side1participantId].gamesLost += gamesWonSide2;
|
|
2669
|
+
}
|
|
2670
|
+
if (side2participantId) {
|
|
2671
|
+
participantResults[side2participantId].gamesWon += gamesWonSide2;
|
|
2672
|
+
participantResults[side2participantId].gamesLost += gamesWonSide1;
|
|
2673
|
+
}
|
|
2664
2674
|
}
|
|
2665
2675
|
}
|
|
2666
2676
|
calculatePercentages({
|
|
@@ -2787,7 +2797,7 @@ function processMatchUp({
|
|
|
2787
2797
|
winningSide,
|
|
2788
2798
|
score
|
|
2789
2799
|
});
|
|
2790
|
-
const pointsTally = countPoints({ score, matchUpFormat });
|
|
2800
|
+
const { pointsTally } = countPoints({ score, matchUpFormat });
|
|
2791
2801
|
if (winningParticipantId) {
|
|
2792
2802
|
participantResults[winningParticipantId].setsWon += setsTally[winningSideIndex];
|
|
2793
2803
|
participantResults[winningParticipantId].setsLost += setsTally[losingSideIndex];
|
|
@@ -3553,8 +3563,8 @@ function findPolicy({
|
|
|
3553
3563
|
}
|
|
3554
3564
|
|
|
3555
3565
|
function getMatchUpCompetitiveProfile({
|
|
3556
|
-
profileBands,
|
|
3557
3566
|
tournamentRecord,
|
|
3567
|
+
profileBands,
|
|
3558
3568
|
matchUp
|
|
3559
3569
|
}) {
|
|
3560
3570
|
if (!matchUp)
|