tods-competition-factory 2.0.39 → 2.0.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 +5 -5
- package/dist/tods-competition-factory.d.ts +16 -2
- package/dist/tods-competition-factory.development.cjs.js +191 -196
- 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
|
@@ -8716,6 +8716,17 @@ declare function checkSetIsComplete({ ignoreTiebreak, matchUpScoringFormat, matc
|
|
|
8716
8716
|
info: string;
|
|
8717
8717
|
};
|
|
8718
8718
|
|
|
8719
|
+
type AnalyzeScoreArgs = {
|
|
8720
|
+
existingMatchUpStatus?: string;
|
|
8721
|
+
matchUpStatus?: string;
|
|
8722
|
+
matchUpFormat?: string;
|
|
8723
|
+
winningSide?: number;
|
|
8724
|
+
score: Score;
|
|
8725
|
+
};
|
|
8726
|
+
declare function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, winningSide, score, }: AnalyzeScoreArgs): {
|
|
8727
|
+
valid: boolean;
|
|
8728
|
+
};
|
|
8729
|
+
|
|
8719
8730
|
type ParseScoreArgs = {
|
|
8720
8731
|
scoreString: string;
|
|
8721
8732
|
tiebreakTo?: number;
|
|
@@ -8734,6 +8745,7 @@ declare function analyzeSet(params: any): {
|
|
|
8734
8745
|
[key: string]: any;
|
|
8735
8746
|
};
|
|
8736
8747
|
|
|
8748
|
+
declare const query_analyzeScore: typeof analyzeScore;
|
|
8737
8749
|
declare const query_analyzeSet: typeof analyzeSet;
|
|
8738
8750
|
declare const query_checkScoreHasValue: typeof checkScoreHasValue;
|
|
8739
8751
|
declare const query_checkSetIsComplete: typeof checkSetIsComplete;
|
|
@@ -8744,13 +8756,14 @@ declare const query_parseScoreString: typeof parseScoreString;
|
|
|
8744
8756
|
declare const query_validateScore: typeof validateScore;
|
|
8745
8757
|
declare const query_validateTieFormat: typeof validateTieFormat;
|
|
8746
8758
|
declare namespace query {
|
|
8747
|
-
export { query_analyzeSet as analyzeSet, query_checkScoreHasValue as checkScoreHasValue, query_checkSetIsComplete as checkSetIsComplete, query_getSetComplement as getSetComplement, query_getTiebreakComplement as getTiebreakComplement, query_isValidMatchUpFormat as isValidMatchUpFormat, query_parseScoreString as parseScoreString, query_validateScore as validateScore, query_validateTieFormat as validateTieFormat };
|
|
8759
|
+
export { query_analyzeScore as analyzeScore, query_analyzeSet as analyzeSet, query_checkScoreHasValue as checkScoreHasValue, query_checkSetIsComplete as checkSetIsComplete, query_getSetComplement as getSetComplement, query_getTiebreakComplement as getTiebreakComplement, query_isValidMatchUpFormat as isValidMatchUpFormat, query_parseScoreString as parseScoreString, query_validateScore as validateScore, query_validateTieFormat as validateTieFormat };
|
|
8748
8760
|
}
|
|
8749
8761
|
|
|
8750
8762
|
declare const index$6_addGame: typeof addGame;
|
|
8751
8763
|
declare const index$6_addPoint: typeof addPoint;
|
|
8752
8764
|
declare const index$6_addSet: typeof addSet;
|
|
8753
8765
|
declare const index$6_addShot: typeof addShot;
|
|
8766
|
+
declare const index$6_analyzeScore: typeof analyzeScore;
|
|
8754
8767
|
declare const index$6_analyzeSet: typeof analyzeSet;
|
|
8755
8768
|
declare const index$6_calculateHistoryScore: typeof calculateHistoryScore;
|
|
8756
8769
|
declare const index$6_checkScoreHasValue: typeof checkScoreHasValue;
|
|
@@ -8773,7 +8786,7 @@ declare const index$6_undo: typeof undo;
|
|
|
8773
8786
|
declare const index$6_validateScore: typeof validateScore;
|
|
8774
8787
|
declare const index$6_validateTieFormat: typeof validateTieFormat;
|
|
8775
8788
|
declare namespace index$6 {
|
|
8776
|
-
export { index$6_addGame as addGame, index$6_addPoint as addPoint, index$6_addSet as addSet, index$6_addShot as addShot, index$6_analyzeSet as analyzeSet, index$6_calculateHistoryScore as calculateHistoryScore, index$6_checkScoreHasValue as checkScoreHasValue, index$6_checkSetIsComplete as checkSetIsComplete, index$6_clearHistory as clearHistory, generate$1 as generate, index$6_generateScoreString as generateScoreString, index$6_generateTieMatchUpScore as generateTieMatchUpScore, index$6_getSetComplement as getSetComplement, index$6_getTiebreakComplement as getTiebreakComplement, help as helpers, index$6_isValidMatchUpFormat as isValidMatchUpFormat, index$6_keyValueScore as keyValueScore, mutate$3 as mutate, parse as parseMatchUpFormat, index$6_parseScoreString as parseScoreString, index$6_query as query, index$6_redo as redo, index$6_reverseScore as reverseScore, index$6_setServingSide as setServingSide, stringify as stringifyMatchUpFormat, index$6_tidyScore as tidyScore, index$6_umo as umo, index$6_undo as undo, index$6_validateScore as validateScore, index$6_validateTieFormat as validateTieFormat };
|
|
8789
|
+
export { index$6_addGame as addGame, index$6_addPoint as addPoint, index$6_addSet as addSet, index$6_addShot as addShot, index$6_analyzeScore as analyzeScore, index$6_analyzeSet as analyzeSet, index$6_calculateHistoryScore as calculateHistoryScore, index$6_checkScoreHasValue as checkScoreHasValue, index$6_checkSetIsComplete as checkSetIsComplete, index$6_clearHistory as clearHistory, generate$1 as generate, index$6_generateScoreString as generateScoreString, index$6_generateTieMatchUpScore as generateTieMatchUpScore, index$6_getSetComplement as getSetComplement, index$6_getTiebreakComplement as getTiebreakComplement, help as helpers, index$6_isValidMatchUpFormat as isValidMatchUpFormat, index$6_keyValueScore as keyValueScore, mutate$3 as mutate, parse as parseMatchUpFormat, index$6_parseScoreString as parseScoreString, index$6_query as query, index$6_redo as redo, index$6_reverseScore as reverseScore, index$6_setServingSide as setServingSide, stringify as stringifyMatchUpFormat, index$6_tidyScore as tidyScore, index$6_umo as umo, index$6_undo as undo, index$6_validateScore as validateScore, index$6_validateTieFormat as validateTieFormat };
|
|
8777
8790
|
}
|
|
8778
8791
|
|
|
8779
8792
|
type ModifyCollectionDefinitionArgs = {
|
|
@@ -10849,6 +10862,7 @@ declare const extensionConstants: {
|
|
|
10849
10862
|
DISABLED: string;
|
|
10850
10863
|
DISABLE_LINKS: string;
|
|
10851
10864
|
DISABLE_AUTO_CALC: string;
|
|
10865
|
+
DISPLAY: string;
|
|
10852
10866
|
DRAW_DELETIONS: string;
|
|
10853
10867
|
DRAW_PROFILE: string;
|
|
10854
10868
|
ENTRY_PROFILE: string;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var namesData$1 = require('@Fixtures/data/teams.json');
|
|
6
|
+
|
|
5
7
|
function factoryVersion() {
|
|
6
|
-
return '2.0.
|
|
8
|
+
return '2.0.41';
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
function isFunction(obj) {
|
|
@@ -1256,6 +1258,9 @@ function skewedDistribution(min, max, skew, step, significantDecimals = 2) {
|
|
|
1256
1258
|
num = stepRound(num, step);
|
|
1257
1259
|
return parseFloat(num.toFixed(significantDecimals));
|
|
1258
1260
|
}
|
|
1261
|
+
function fixedDecimals(value, to = 2) {
|
|
1262
|
+
return parseFloat(Number(Math.round(value * 1000) / 1000).toFixed(to));
|
|
1263
|
+
}
|
|
1259
1264
|
|
|
1260
1265
|
function unique(arr) {
|
|
1261
1266
|
if (!Array.isArray(arr))
|
|
@@ -2709,6 +2714,7 @@ const DELEGATED_OUTCOME = 'delegatedOutcome';
|
|
|
2709
2714
|
const DISABLED = 'disabled';
|
|
2710
2715
|
const DISABLE_LINKS = 'disableLinks';
|
|
2711
2716
|
const DISABLE_AUTO_CALC = 'disableAutoCalc';
|
|
2717
|
+
const DISPLAY = 'display';
|
|
2712
2718
|
const DRAW_DELETIONS = 'drawDeletions';
|
|
2713
2719
|
const DRAW_PROFILE = 'drawProfile';
|
|
2714
2720
|
const ENTRY_PROFILE = 'entryProfile';
|
|
@@ -2740,6 +2746,7 @@ const extensionConstants = {
|
|
|
2740
2746
|
DISABLED,
|
|
2741
2747
|
DISABLE_LINKS,
|
|
2742
2748
|
DISABLE_AUTO_CALC,
|
|
2749
|
+
DISPLAY,
|
|
2743
2750
|
DRAW_DELETIONS,
|
|
2744
2751
|
DRAW_PROFILE,
|
|
2745
2752
|
ENTRY_PROFILE,
|
|
@@ -19702,6 +19709,153 @@ function generateAndPopulateRRplayoffStructures(params) {
|
|
|
19702
19709
|
};
|
|
19703
19710
|
}
|
|
19704
19711
|
|
|
19712
|
+
function convertRange({ value, sourceRange, targetRange }) {
|
|
19713
|
+
const minSourceRange = Math.min(...sourceRange);
|
|
19714
|
+
const maxSourceRange = Math.max(...sourceRange);
|
|
19715
|
+
const minTargetRange = Math.min(...targetRange);
|
|
19716
|
+
const maxTargetRange = Math.max(...targetRange);
|
|
19717
|
+
return (((value - minSourceRange) * (maxTargetRange - minTargetRange)) / (maxSourceRange - minSourceRange) + minTargetRange);
|
|
19718
|
+
}
|
|
19719
|
+
|
|
19720
|
+
const ELO = 'ELO';
|
|
19721
|
+
const NTRP = 'NTRP';
|
|
19722
|
+
const TRN = 'TRN';
|
|
19723
|
+
const UTR = 'UTR';
|
|
19724
|
+
const WTN = 'WTN';
|
|
19725
|
+
const ratingConstants = {
|
|
19726
|
+
ELO,
|
|
19727
|
+
NTRP,
|
|
19728
|
+
TRN,
|
|
19729
|
+
UTR,
|
|
19730
|
+
WTN,
|
|
19731
|
+
};
|
|
19732
|
+
|
|
19733
|
+
const ratingsParameters = {
|
|
19734
|
+
[ELO]: {
|
|
19735
|
+
defaultInitialization: 1500,
|
|
19736
|
+
decimalsCount: 0,
|
|
19737
|
+
range: [0, 3000],
|
|
19738
|
+
ascending: true,
|
|
19739
|
+
},
|
|
19740
|
+
[NTRP]: {
|
|
19741
|
+
accessors: ['ntrpRating', 'dntrpRatingHundredths'],
|
|
19742
|
+
attributes: { ustaRatingType: '' },
|
|
19743
|
+
accessor: 'dntrpRatingHundredths',
|
|
19744
|
+
defaultInitialization: 3,
|
|
19745
|
+
decimalsCount: 1,
|
|
19746
|
+
ascending: true,
|
|
19747
|
+
range: [1, 7],
|
|
19748
|
+
},
|
|
19749
|
+
[UTR]: {
|
|
19750
|
+
defaultInitialization: 6,
|
|
19751
|
+
accessors: ['utrRating'],
|
|
19752
|
+
accessor: 'utrRating',
|
|
19753
|
+
decimalsCount: 2,
|
|
19754
|
+
ascending: true,
|
|
19755
|
+
range: [1, 16],
|
|
19756
|
+
},
|
|
19757
|
+
[WTN]: {
|
|
19758
|
+
attributes: { confidence: { generator: true, range: [60, 100] } },
|
|
19759
|
+
accessors: ['wtnRating', 'confidence'],
|
|
19760
|
+
defaultInitialization: 23,
|
|
19761
|
+
accessor: 'wtnRating',
|
|
19762
|
+
ascending: false,
|
|
19763
|
+
decimalsCount: 2,
|
|
19764
|
+
range: [40, 1],
|
|
19765
|
+
},
|
|
19766
|
+
};
|
|
19767
|
+
|
|
19768
|
+
function getRatingConvertedToELO({ sourceRatingType, sourceRating }) {
|
|
19769
|
+
const sourceRatingRange = ratingsParameters[sourceRatingType].range;
|
|
19770
|
+
const invertedScale = sourceRatingRange[0] > sourceRatingRange[1];
|
|
19771
|
+
const eloRatingRange = ratingsParameters[ELO].range;
|
|
19772
|
+
return convertRange({
|
|
19773
|
+
value: invertedScale ? sourceRatingRange[0] - sourceRating : sourceRating,
|
|
19774
|
+
sourceRange: sourceRatingRange,
|
|
19775
|
+
targetRange: eloRatingRange,
|
|
19776
|
+
});
|
|
19777
|
+
}
|
|
19778
|
+
function getRatingConvertedFromELO({ targetRatingType, sourceRating }) {
|
|
19779
|
+
const decimalPlaces = ratingsParameters[targetRatingType].decimalsCount || 0;
|
|
19780
|
+
const targetRatingRange = ratingsParameters[targetRatingType].range;
|
|
19781
|
+
const invertedScale = targetRatingRange[0] > targetRatingRange[1];
|
|
19782
|
+
const maxTargetRatingRange = Math.max(...targetRatingRange);
|
|
19783
|
+
const eloRatingRange = ratingsParameters[ELO].range;
|
|
19784
|
+
const result = convertRange({
|
|
19785
|
+
targetRange: targetRatingRange,
|
|
19786
|
+
sourceRange: eloRatingRange,
|
|
19787
|
+
value: sourceRating,
|
|
19788
|
+
});
|
|
19789
|
+
const convertedRating = parseFloat(result.toFixed(decimalPlaces));
|
|
19790
|
+
return invertedScale ? maxTargetRatingRange - convertedRating : convertedRating;
|
|
19791
|
+
}
|
|
19792
|
+
|
|
19793
|
+
function getConvertedRating(params) {
|
|
19794
|
+
const paramsCheck = checkRequiredParameters(params, [{ ratings: true, [OF_TYPE]: OBJECT }]);
|
|
19795
|
+
if (paramsCheck.error)
|
|
19796
|
+
return paramsCheck;
|
|
19797
|
+
const matchUpType = params.matchUpType && [SINGLES, DOUBLES].includes(params.matchUpType) ? params.matchUpType : SINGLES;
|
|
19798
|
+
const ratingTypes = Object.keys(ratingsParameters);
|
|
19799
|
+
const targetRatingType = params.targetRatingType && ratingTypes.includes(params.targetRatingType) ? params.targetRatingType : ELO;
|
|
19800
|
+
const sourceRatings = params.ratings[matchUpType]
|
|
19801
|
+
? params.ratings[matchUpType].reduce((sr, rating) => (sr.includes(rating.scaleName) ? sr : sr.concat(rating.scaleName)), [])
|
|
19802
|
+
: [];
|
|
19803
|
+
if (!sourceRatings)
|
|
19804
|
+
return { error: NOT_FOUND };
|
|
19805
|
+
const sourceRatingObject = params.ratings[matchUpType]?.find((rating) => rating.scaleName === targetRatingType) ??
|
|
19806
|
+
params.ratings[matchUpType][0];
|
|
19807
|
+
if (sourceRatings[0] === targetRatingType)
|
|
19808
|
+
return sourceRatingObject;
|
|
19809
|
+
const sourceRatingType = sourceRatingObject.scaleName;
|
|
19810
|
+
const accessor = ratingsParameters[sourceRatingObject.scaleName].accessor;
|
|
19811
|
+
const sourceRating = accessor ? sourceRatingObject.scaleValue[accessor] : sourceRatingObject.scaleValue;
|
|
19812
|
+
const eloValue = getRatingConvertedToELO({ sourceRatingType, sourceRating });
|
|
19813
|
+
const convertedRating = getRatingConvertedFromELO({
|
|
19814
|
+
targetRatingType: targetRatingType,
|
|
19815
|
+
sourceRating: eloValue,
|
|
19816
|
+
});
|
|
19817
|
+
return { convertedRating, sourceRating };
|
|
19818
|
+
}
|
|
19819
|
+
|
|
19820
|
+
function calculatePressureRatings({ participantResults, sides, score }) {
|
|
19821
|
+
const side1 = sides.find(({ sideNumber }) => sideNumber === 1);
|
|
19822
|
+
const side2 = sides.find(({ sideNumber }) => sideNumber === 2);
|
|
19823
|
+
const side1ratings = side1?.participant?.ratings;
|
|
19824
|
+
const side2ratings = side2?.participant?.ratings;
|
|
19825
|
+
if (side1ratings[SINGLES] && side2ratings[SINGLES]) {
|
|
19826
|
+
const targetRatingType = ELO;
|
|
19827
|
+
const { convertedRating: side1ConvertedRating } = getConvertedRating({ ratings: side1ratings, targetRatingType });
|
|
19828
|
+
const { convertedRating: side2ConvertedRating } = getConvertedRating({ ratings: side2ratings, targetRatingType });
|
|
19829
|
+
const { side1pressure, side2pressure } = getSideValues$1({ side1ConvertedRating, side2ConvertedRating, score });
|
|
19830
|
+
participantResults[side1?.participantId].pressureScores.push(side1pressure);
|
|
19831
|
+
participantResults[side2?.participantId].pressureScores.push(side2pressure);
|
|
19832
|
+
const highRange = Math.max(...ratingsParameters[ELO].range);
|
|
19833
|
+
const side1Variation = fixedDecimals((side2ConvertedRating - side1ConvertedRating) / highRange);
|
|
19834
|
+
const side2Variation = fixedDecimals((side1ConvertedRating - side2ConvertedRating) / highRange);
|
|
19835
|
+
participantResults[side1?.participantId].ratingVariation.push(side1Variation);
|
|
19836
|
+
participantResults[side2?.participantId].ratingVariation.push(side2Variation);
|
|
19837
|
+
}
|
|
19838
|
+
}
|
|
19839
|
+
function getSideValues$1({ side1ConvertedRating, side2ConvertedRating, score }) {
|
|
19840
|
+
const highRating = side1ConvertedRating > side2ConvertedRating ? side1ConvertedRating : side2ConvertedRating;
|
|
19841
|
+
const lowRating = side1ConvertedRating > side2ConvertedRating ? side2ConvertedRating : side1ConvertedRating;
|
|
19842
|
+
const ratingsDifference = Math.abs(side1ConvertedRating - side2ConvertedRating);
|
|
19843
|
+
const eloRatingRange = ratingsParameters[ELO].range;
|
|
19844
|
+
const rangeMax = Math.max(...eloRatingRange);
|
|
19845
|
+
const bumpBump = (rangeMax - highRating) * 0;
|
|
19846
|
+
const discount = (highRating + bumpBump) / rangeMax;
|
|
19847
|
+
const lowSideBump = discount * ratingsDifference;
|
|
19848
|
+
const gamesWonSide1 = score?.sets?.reduce((total, set) => total + (set?.side1Score ?? 0), 0);
|
|
19849
|
+
const gamesWonSide2 = score?.sets?.reduce((total, set) => total + (set.side2Score ?? 0), 0);
|
|
19850
|
+
const lowSide = side1ConvertedRating > side2ConvertedRating ? 2 : 1;
|
|
19851
|
+
const side1value = gamesWonSide1 * (lowRating + (lowSide === 1 ? lowSideBump : 0));
|
|
19852
|
+
const side2value = gamesWonSide2 * (lowRating + (lowSide === 2 ? lowSideBump : 0));
|
|
19853
|
+
const combinedValues = side1value + side2value;
|
|
19854
|
+
const side1pressure = fixedDecimals(side1value / combinedValues);
|
|
19855
|
+
const side2pressure = fixedDecimals(side2value / combinedValues);
|
|
19856
|
+
return { side1pressure, side2pressure };
|
|
19857
|
+
}
|
|
19858
|
+
|
|
19705
19859
|
const FORMAT_STANDARD = 'SET3-S:6/TB7';
|
|
19706
19860
|
const FORMAT_STANDARD_NOAD = 'SET3-S:6NOAD';
|
|
19707
19861
|
const FORMAT_ATP_DOUBLES = 'SET3-S:6/TB7-F:TB10';
|
|
@@ -19907,114 +20061,6 @@ function calculatePercentages({ participantResults, matchUpFormat, tallyPolicy,
|
|
|
19907
20061
|
});
|
|
19908
20062
|
}
|
|
19909
20063
|
|
|
19910
|
-
function convertRange({ value, sourceRange, targetRange }) {
|
|
19911
|
-
const minSourceRange = Math.min(...sourceRange);
|
|
19912
|
-
const maxSourceRange = Math.max(...sourceRange);
|
|
19913
|
-
const minTargetRange = Math.min(...targetRange);
|
|
19914
|
-
const maxTargetRange = Math.max(...targetRange);
|
|
19915
|
-
return (((value - minSourceRange) * (maxTargetRange - minTargetRange)) / (maxSourceRange - minSourceRange) + minTargetRange);
|
|
19916
|
-
}
|
|
19917
|
-
|
|
19918
|
-
const ELO = 'ELO';
|
|
19919
|
-
const NTRP = 'NTRP';
|
|
19920
|
-
const TRN = 'TRN';
|
|
19921
|
-
const UTR = 'UTR';
|
|
19922
|
-
const WTN = 'WTN';
|
|
19923
|
-
const ratingConstants = {
|
|
19924
|
-
ELO,
|
|
19925
|
-
NTRP,
|
|
19926
|
-
TRN,
|
|
19927
|
-
UTR,
|
|
19928
|
-
WTN,
|
|
19929
|
-
};
|
|
19930
|
-
|
|
19931
|
-
const ratingsParameters = {
|
|
19932
|
-
[ELO]: {
|
|
19933
|
-
defaultInitialization: 1500,
|
|
19934
|
-
decimalsCount: 0,
|
|
19935
|
-
range: [0, 3000],
|
|
19936
|
-
ascending: true,
|
|
19937
|
-
},
|
|
19938
|
-
[NTRP]: {
|
|
19939
|
-
accessors: ['ntrpRating', 'dntrpRatingHundredths'],
|
|
19940
|
-
attributes: { ustaRatingType: '' },
|
|
19941
|
-
accessor: 'dntrpRatingHundredths',
|
|
19942
|
-
defaultInitialization: 3,
|
|
19943
|
-
decimalsCount: 1,
|
|
19944
|
-
ascending: true,
|
|
19945
|
-
range: [1, 7],
|
|
19946
|
-
},
|
|
19947
|
-
[UTR]: {
|
|
19948
|
-
defaultInitialization: 6,
|
|
19949
|
-
accessors: ['utrRating'],
|
|
19950
|
-
accessor: 'utrRating',
|
|
19951
|
-
decimalsCount: 2,
|
|
19952
|
-
ascending: true,
|
|
19953
|
-
range: [1, 16],
|
|
19954
|
-
},
|
|
19955
|
-
[WTN]: {
|
|
19956
|
-
attributes: { confidence: { generator: true, range: [60, 100] } },
|
|
19957
|
-
accessors: ['wtnRating', 'confidence'],
|
|
19958
|
-
defaultInitialization: 23,
|
|
19959
|
-
accessor: 'wtnRating',
|
|
19960
|
-
ascending: false,
|
|
19961
|
-
decimalsCount: 2,
|
|
19962
|
-
range: [40, 1],
|
|
19963
|
-
},
|
|
19964
|
-
};
|
|
19965
|
-
|
|
19966
|
-
function getRatingConvertedToELO({ sourceRatingType, sourceRating }) {
|
|
19967
|
-
const sourceRatingRange = ratingsParameters[sourceRatingType].range;
|
|
19968
|
-
const invertedScale = sourceRatingRange[0] > sourceRatingRange[1];
|
|
19969
|
-
const eloRatingRange = ratingsParameters[ELO].range;
|
|
19970
|
-
return convertRange({
|
|
19971
|
-
value: invertedScale ? sourceRatingRange[0] - sourceRating : sourceRating,
|
|
19972
|
-
sourceRange: sourceRatingRange,
|
|
19973
|
-
targetRange: eloRatingRange,
|
|
19974
|
-
});
|
|
19975
|
-
}
|
|
19976
|
-
function getRatingConvertedFromELO({ targetRatingType, sourceRating }) {
|
|
19977
|
-
const decimalPlaces = ratingsParameters[targetRatingType].decimalsCount || 0;
|
|
19978
|
-
const targetRatingRange = ratingsParameters[targetRatingType].range;
|
|
19979
|
-
const invertedScale = targetRatingRange[0] > targetRatingRange[1];
|
|
19980
|
-
const maxTargetRatingRange = Math.max(...targetRatingRange);
|
|
19981
|
-
const eloRatingRange = ratingsParameters[ELO].range;
|
|
19982
|
-
const result = convertRange({
|
|
19983
|
-
targetRange: targetRatingRange,
|
|
19984
|
-
sourceRange: eloRatingRange,
|
|
19985
|
-
value: sourceRating,
|
|
19986
|
-
});
|
|
19987
|
-
const convertedRating = parseFloat(result.toFixed(decimalPlaces));
|
|
19988
|
-
return invertedScale ? maxTargetRatingRange - convertedRating : convertedRating;
|
|
19989
|
-
}
|
|
19990
|
-
|
|
19991
|
-
function getConvertedRating(params) {
|
|
19992
|
-
const paramsCheck = checkRequiredParameters(params, [{ ratings: true, [OF_TYPE]: OBJECT }]);
|
|
19993
|
-
if (paramsCheck.error)
|
|
19994
|
-
return paramsCheck;
|
|
19995
|
-
const matchUpType = params.matchUpType && [SINGLES, DOUBLES].includes(params.matchUpType) ? params.matchUpType : SINGLES;
|
|
19996
|
-
const ratingTypes = Object.keys(ratingsParameters);
|
|
19997
|
-
const targetRatingType = params.targetRatingType && ratingTypes.includes(params.targetRatingType) ? params.targetRatingType : ELO;
|
|
19998
|
-
const sourceRatings = params.ratings[matchUpType]
|
|
19999
|
-
? params.ratings[matchUpType].reduce((sr, rating) => (sr.includes(rating.scaleName) ? sr : sr.concat(rating.scaleName)), [])
|
|
20000
|
-
: [];
|
|
20001
|
-
if (!sourceRatings)
|
|
20002
|
-
return { error: NOT_FOUND };
|
|
20003
|
-
const sourceRatingObject = params.ratings[matchUpType]?.find((rating) => rating.scaleName === targetRatingType) ??
|
|
20004
|
-
params.ratings[matchUpType][0];
|
|
20005
|
-
if (sourceRatings[0] === targetRatingType)
|
|
20006
|
-
return sourceRatingObject;
|
|
20007
|
-
const sourceRatingType = sourceRatingObject.scaleName;
|
|
20008
|
-
const accessor = ratingsParameters[sourceRatingObject.scaleName].accessor;
|
|
20009
|
-
const sourceRating = accessor ? sourceRatingObject.scaleValue[accessor] : sourceRatingObject.scaleValue;
|
|
20010
|
-
const eloValue = getRatingConvertedToELO({ sourceRatingType, sourceRating });
|
|
20011
|
-
const convertedRating = getRatingConvertedFromELO({
|
|
20012
|
-
targetRatingType: targetRatingType,
|
|
20013
|
-
sourceRating: eloValue,
|
|
20014
|
-
});
|
|
20015
|
-
return { convertedRating, sourceRating };
|
|
20016
|
-
}
|
|
20017
|
-
|
|
20018
20064
|
function getParticipantResults({ participantIds, pressureRating, matchUpFormat, tallyPolicy, perPlayer, matchUps, }) {
|
|
20019
20065
|
const participantResults = {};
|
|
20020
20066
|
const excludeMatchUpStatuses = tallyPolicy?.excludeMatchUpStatuses || [];
|
|
@@ -20134,6 +20180,7 @@ function getParticipantResults({ participantIds, pressureRating, matchUpFormat,
|
|
|
20134
20180
|
processMatchUp({
|
|
20135
20181
|
matchUpFormat: tieMatchUp.matchUpFormat,
|
|
20136
20182
|
matchUpStatus: tieMatchUp.matchUpStatus,
|
|
20183
|
+
matchUpType: tieMatchUp.matchUpType,
|
|
20137
20184
|
score: tieMatchUp.score,
|
|
20138
20185
|
sides: tieMatchUp.sides,
|
|
20139
20186
|
winningParticipantId,
|
|
@@ -20156,6 +20203,7 @@ function getParticipantResults({ participantIds, pressureRating, matchUpFormat,
|
|
|
20156
20203
|
else {
|
|
20157
20204
|
processMatchUp({
|
|
20158
20205
|
matchUpFormat: matchUp.matchUpFormat ?? matchUpFormat,
|
|
20206
|
+
matchUpType: matchUp.matchUpType,
|
|
20159
20207
|
isTieMatchUp: undefined,
|
|
20160
20208
|
winningParticipantId,
|
|
20161
20209
|
manualGamesOverride,
|
|
@@ -20269,24 +20317,11 @@ function processScore({ manualGamesOverride, participantResults, score, sides })
|
|
|
20269
20317
|
}
|
|
20270
20318
|
});
|
|
20271
20319
|
}
|
|
20272
|
-
function processMatchUp({ winningParticipantId, manualGamesOverride, losingParticipantId, participantResults, pressureRating, matchUpFormat, matchUpStatus, isTieMatchUp, tallyPolicy, winningSide, score, sides, }) {
|
|
20320
|
+
function processMatchUp({ winningParticipantId, manualGamesOverride, losingParticipantId, participantResults, pressureRating, matchUpFormat, matchUpStatus, isTieMatchUp, matchUpType, tallyPolicy, winningSide, score, sides, }) {
|
|
20273
20321
|
const winningSideIndex = winningSide && winningSide - 1;
|
|
20274
20322
|
const losingSideIndex = 1 - winningSideIndex;
|
|
20275
|
-
if (pressureRating) {
|
|
20276
|
-
|
|
20277
|
-
const gamesWonSide1 = score?.sets?.reduce((total, set) => total + (set?.side1Score ?? 0), 0);
|
|
20278
|
-
const gamesWonSide2 = score?.sets?.reduce((total, set) => total + (set.side2Score ?? 0), 0);
|
|
20279
|
-
const side1 = sides.find(({ sideNumber }) => sideNumber === 1);
|
|
20280
|
-
const side2 = sides.find(({ sideNumber }) => sideNumber === 2);
|
|
20281
|
-
const { convertedRating: side1ConvertedRating } = getConvertedRating({ ratings: side1?.participant?.ratings });
|
|
20282
|
-
const { convertedRating: side2ConvertedRating } = getConvertedRating({ ratings: side2?.participant?.ratings });
|
|
20283
|
-
const side1Value = gamesWonSide1 * side2ConvertedRating;
|
|
20284
|
-
const side2Value = gamesWonSide2 * side1ConvertedRating;
|
|
20285
|
-
participantResults[side1?.participantId].pressureScores.push(fixed2(side1Value / (side1Value + side2Value)));
|
|
20286
|
-
participantResults[side2?.participantId].pressureScores.push(fixed2(side2Value / (side1Value + side2Value)));
|
|
20287
|
-
const highRange = Math.max(...ratingsParameters[ELO].range);
|
|
20288
|
-
participantResults[side1?.participantId].ratingVariation.push(fixed2((side1ConvertedRating - side2ConvertedRating) / highRange));
|
|
20289
|
-
participantResults[side2?.participantId].ratingVariation.push(fixed2((side2ConvertedRating - side1ConvertedRating) / highRange));
|
|
20323
|
+
if (pressureRating && matchUpType === SINGLES) {
|
|
20324
|
+
calculatePressureRatings({ participantResults, sides, score });
|
|
20290
20325
|
}
|
|
20291
20326
|
if (!isTieMatchUp) {
|
|
20292
20327
|
processOutcome$1({
|
|
@@ -21041,9 +21076,9 @@ function modifyMatchUpScore(params) {
|
|
|
21041
21076
|
}
|
|
21042
21077
|
|
|
21043
21078
|
function attemptToModifyScore(params) {
|
|
21044
|
-
const {
|
|
21079
|
+
const { matchUpStatusCodes, matchUpStatus, structure, matchUp, dualMatchUp } = params;
|
|
21045
21080
|
const matchUpStatusIsValid = isDirectingMatchUpStatus({ matchUpStatus }) ||
|
|
21046
|
-
([CANCELLED$1, ABANDONED$1].includes(matchUpStatus) &&
|
|
21081
|
+
([CANCELLED$1, ABANDONED$1].includes(matchUpStatus) && dualMatchUp);
|
|
21047
21082
|
const stack = 'attemptToModifyScore';
|
|
21048
21083
|
const isCollectionMatchUp = Boolean(matchUp.collectionId);
|
|
21049
21084
|
const isAdHocMatchUp = isAdHoc({ structure });
|
|
@@ -21052,10 +21087,11 @@ function attemptToModifyScore(params) {
|
|
|
21052
21087
|
return { error: MISSING_ASSIGNMENTS };
|
|
21053
21088
|
}
|
|
21054
21089
|
const removeScore = [WALKOVER$2].includes(matchUpStatus);
|
|
21090
|
+
const updatedMatchUpStatus = matchUpStatusIsValid ? matchUpStatus : (params.winningSide && COMPLETED$1) || INCOMPLETE;
|
|
21055
21091
|
const result = modifyMatchUpScore({
|
|
21056
21092
|
...params,
|
|
21057
21093
|
matchUpStatusCodes: (matchUpStatusIsValid && matchUpStatusCodes) || [],
|
|
21058
|
-
matchUpStatus:
|
|
21094
|
+
matchUpStatus: updatedMatchUpStatus,
|
|
21059
21095
|
context: stack,
|
|
21060
21096
|
removeScore,
|
|
21061
21097
|
});
|
|
@@ -26542,9 +26578,9 @@ function calculateNewRatings(params) {
|
|
|
26542
26578
|
const updatedWinnerRating = invertedScale
|
|
26543
26579
|
? ratingRange[0] - convertedUpdatedWinnerRating
|
|
26544
26580
|
: convertedUpdatedWinnerRating;
|
|
26545
|
-
let newWinnerRating = parseFloat(
|
|
26581
|
+
let newWinnerRating = parseFloat(updatedWinnerRating.toFixed(decimalPlaces));
|
|
26546
26582
|
const updatedLoserRating = invertedScale ? ratingRange[0] - convertedUpdatedLoserRating : convertedUpdatedLoserRating;
|
|
26547
|
-
let newLoserRating = parseFloat(
|
|
26583
|
+
let newLoserRating = parseFloat(updatedLoserRating.toFixed(decimalPlaces));
|
|
26548
26584
|
const percentageDifference = Math.max(...ratingRange)
|
|
26549
26585
|
? Math.abs(winnerRating - loserRating) / Math.max(...ratingRange)
|
|
26550
26586
|
: 0;
|
|
@@ -30280,6 +30316,7 @@ function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, win
|
|
|
30280
30316
|
const matchUpScoringFormat = matchUpFormat ? parse(matchUpFormat) : undefined;
|
|
30281
30317
|
const maxSetsCount = Math.max(...setsWinCounts);
|
|
30282
30318
|
const maxSetsInstances = instanceCount(setsWinCounts)[maxSetsCount];
|
|
30319
|
+
const timed = matchUpScoringFormat?.setFormat?.timed || matchUpScoringFormat?.finalSetFormat?.timed;
|
|
30283
30320
|
const bestOf = matchUpScoringFormat?.bestOf;
|
|
30284
30321
|
const setsToWin = (bestOf && Math.ceil(bestOf / 2)) || 1;
|
|
30285
30322
|
const relevantMatchUpStatus = matchUpStatus ?? existingMatchUpStatus;
|
|
@@ -30316,10 +30353,13 @@ function analyzeScore({ existingMatchUpStatus, matchUpFormat, matchUpStatus, win
|
|
|
30316
30353
|
maxSetsInstances === 1 &&
|
|
30317
30354
|
setsWinCounts.indexOf(maxSetsCount) + 1) ||
|
|
30318
30355
|
undefined;
|
|
30319
|
-
const valid = validSets &&
|
|
30356
|
+
const valid = !!(validSets &&
|
|
30320
30357
|
((winningSide && winningSideSetsCount > losingSideSetsCount && winningSide === calculatedWinningSide) ||
|
|
30321
|
-
(
|
|
30322
|
-
|
|
30358
|
+
(winningSide && irregularEnding) ||
|
|
30359
|
+
(!winningSide &&
|
|
30360
|
+
!calculatedWinningSide &&
|
|
30361
|
+
(![COMPLETED$1, DEFAULTED, RETIRED$1, WALKOVER$2].includes(relevantMatchUpStatus) ||
|
|
30362
|
+
(timed && relevantMatchUpStatus === COMPLETED$1)))));
|
|
30323
30363
|
return { valid };
|
|
30324
30364
|
}
|
|
30325
30365
|
|
|
@@ -30729,6 +30769,7 @@ function checkValidTiebreakSetOutcome({ setObject, setFormat, sideTiebreakScores
|
|
|
30729
30769
|
|
|
30730
30770
|
var query$a = {
|
|
30731
30771
|
__proto__: null,
|
|
30772
|
+
analyzeScore: analyzeScore,
|
|
30732
30773
|
analyzeSet: analyzeSet,
|
|
30733
30774
|
checkScoreHasValue: checkScoreHasValue,
|
|
30734
30775
|
checkSetIsComplete: checkSetIsComplete,
|
|
@@ -30746,6 +30787,7 @@ var scoreGovernor = {
|
|
|
30746
30787
|
addPoint: addPoint,
|
|
30747
30788
|
addSet: addSet,
|
|
30748
30789
|
addShot: addShot,
|
|
30790
|
+
analyzeScore: analyzeScore,
|
|
30749
30791
|
analyzeSet: analyzeSet,
|
|
30750
30792
|
calculateHistoryScore: calculateHistoryScore,
|
|
30751
30793
|
checkScoreHasValue: checkScoreHasValue,
|
|
@@ -34082,6 +34124,7 @@ function getDrawData(params) {
|
|
|
34082
34124
|
drawType,
|
|
34083
34125
|
drawId,
|
|
34084
34126
|
}))(drawDefinition);
|
|
34127
|
+
drawInfo.display = findExtension({ element: drawDefinition, name: DISPLAY }).extension?.value;
|
|
34085
34128
|
let mainStageSeedAssignments, qualificationStageSeedAssignments;
|
|
34086
34129
|
const { allStructuresLinked, sourceStructureIds, hasDrawFeedProfile, structureGroups } = getStructureGroups({
|
|
34087
34130
|
drawDefinition,
|
|
@@ -34138,14 +34181,11 @@ function getDrawData(params) {
|
|
|
34138
34181
|
structure,
|
|
34139
34182
|
});
|
|
34140
34183
|
let participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
|
|
34184
|
+
const participantResult = findExtension({ element: assignment, name: TALLY })?.extension?.value;
|
|
34141
34185
|
const { drawPosition, participantId } = assignment;
|
|
34142
|
-
const { extension } = findExtension({
|
|
34143
|
-
element: assignment,
|
|
34144
|
-
name: TALLY,
|
|
34145
|
-
});
|
|
34146
34186
|
participantPlacements = true;
|
|
34147
34187
|
return {
|
|
34148
|
-
participantResult
|
|
34188
|
+
participantResult,
|
|
34149
34189
|
participantId,
|
|
34150
34190
|
drawPosition,
|
|
34151
34191
|
};
|
|
@@ -34178,6 +34218,7 @@ function getDrawData(params) {
|
|
|
34178
34218
|
stage,
|
|
34179
34219
|
}))(structure)
|
|
34180
34220
|
: {};
|
|
34221
|
+
structureInfo.display = findExtension({ element: structure, name: DISPLAY }).extension?.value;
|
|
34181
34222
|
structureInfo.sourceStructureIds = sourceStructureIds[structureId];
|
|
34182
34223
|
structureInfo.hasDrawFeedProfile = hasDrawFeedProfile[structureId];
|
|
34183
34224
|
structureInfo.positionAssignments = positionAssignments;
|
|
@@ -34359,6 +34400,10 @@ function getEventData(params) {
|
|
|
34359
34400
|
ballType,
|
|
34360
34401
|
discipline,
|
|
34361
34402
|
}))(event);
|
|
34403
|
+
eventInfo.display = findExtension({
|
|
34404
|
+
element: event,
|
|
34405
|
+
name: DISPLAY,
|
|
34406
|
+
}).extension?.value;
|
|
34362
34407
|
const eventData = {
|
|
34363
34408
|
tournamentInfo,
|
|
34364
34409
|
venuesData,
|
|
@@ -44154,7 +44199,8 @@ function setMatchUpStatus(params) {
|
|
|
44154
44199
|
params.drawDefinition = result.drawDefinition;
|
|
44155
44200
|
params.event = result.event;
|
|
44156
44201
|
}
|
|
44157
|
-
const { disableScoreValidation, policyDefinitions, tournamentRecord, disableAutoCalc, enableAutoCalc, drawDefinition,
|
|
44202
|
+
const { disableScoreValidation, policyDefinitions, tournamentRecord, disableAutoCalc, enableAutoCalc, drawDefinition, matchUpId, schedule, event, notes, } = params;
|
|
44203
|
+
const matchUpFormat = params.matchUpFormat || params.outcome?.matchUpFormat;
|
|
44158
44204
|
const { policy } = findPolicy({
|
|
44159
44205
|
policyType: POLICY_TYPE_SCORING,
|
|
44160
44206
|
tournamentRecord,
|
|
@@ -47246,7 +47292,7 @@ var firstMale = [
|
|
|
47246
47292
|
"Winston",
|
|
47247
47293
|
"Zoran"
|
|
47248
47294
|
];
|
|
47249
|
-
var namesData
|
|
47295
|
+
var namesData = {
|
|
47250
47296
|
lastNames: lastNames,
|
|
47251
47297
|
firstFemale: firstFemale,
|
|
47252
47298
|
firstMale: firstMale
|
|
@@ -47257,7 +47303,7 @@ function generatePersonData(params) {
|
|
|
47257
47303
|
if (!count || (sex && ![MALE, FEMALE].includes(sex)))
|
|
47258
47304
|
return { personData: [], error: INVALID_VALUES };
|
|
47259
47305
|
const buffer = Math.ceil(count * 1.3);
|
|
47260
|
-
const { lastNames, firstFemale, firstMale } = namesData
|
|
47306
|
+
const { lastNames, firstFemale, firstMale } = namesData;
|
|
47261
47307
|
const ISOs = countries.map(({ iso }) => iso).filter(Boolean);
|
|
47262
47308
|
const lastNameDupeCount = Math.ceil(buffer / lastNames.length);
|
|
47263
47309
|
const femaleDupeCount = Math.ceil(buffer / firstFemale.length);
|
|
@@ -47411,62 +47457,8 @@ function generatePersons(params) {
|
|
|
47411
47457
|
};
|
|
47412
47458
|
}
|
|
47413
47459
|
|
|
47414
|
-
var namesData = [
|
|
47415
|
-
"Ace Academy",
|
|
47416
|
-
"Avengers",
|
|
47417
|
-
"Ball Bouncers",
|
|
47418
|
-
"Baseliners",
|
|
47419
|
-
"Captivators",
|
|
47420
|
-
"Civil Disobedients",
|
|
47421
|
-
"Continentals",
|
|
47422
|
-
"Court Royal",
|
|
47423
|
-
"Court Sharks",
|
|
47424
|
-
"Diamond Dogs",
|
|
47425
|
-
"Danger Zone",
|
|
47426
|
-
"Doubles Dominators",
|
|
47427
|
-
"Double Faults",
|
|
47428
|
-
"Tricksters",
|
|
47429
|
-
"Eliminators",
|
|
47430
|
-
"Court Crusaders",
|
|
47431
|
-
"Fuzz Busters",
|
|
47432
|
-
"Game Changers",
|
|
47433
|
-
"Goal Gurus",
|
|
47434
|
-
"Good Volley",
|
|
47435
|
-
"Green Machine",
|
|
47436
|
-
"Hawk Eyes",
|
|
47437
|
-
"Inside Outers",
|
|
47438
|
-
"Killer Instinct",
|
|
47439
|
-
"Line Toers",
|
|
47440
|
-
"Masters of Mayhem",
|
|
47441
|
-
"Matter Catchers",
|
|
47442
|
-
"Cheap Shot",
|
|
47443
|
-
"Mean Machines",
|
|
47444
|
-
"Mindspace Invaders",
|
|
47445
|
-
"Net Centric",
|
|
47446
|
-
"Net Positive",
|
|
47447
|
-
"Smash Mullet",
|
|
47448
|
-
"Over Your Head",
|
|
47449
|
-
"Spin Meisters",
|
|
47450
|
-
"Aggressors",
|
|
47451
|
-
"Racket Machine",
|
|
47452
|
-
"Slice Happy",
|
|
47453
|
-
"Refs Nightmare",
|
|
47454
|
-
"Sandeaters",
|
|
47455
|
-
"Sun Seekers",
|
|
47456
|
-
"Slicer Dicers",
|
|
47457
|
-
"Sparkle Soul Tribe",
|
|
47458
|
-
"Stacked Deck",
|
|
47459
|
-
"Cross Stringers",
|
|
47460
|
-
"The Emergence",
|
|
47461
|
-
"Total Demolition",
|
|
47462
|
-
"Touch and Go",
|
|
47463
|
-
"Upside Downers",
|
|
47464
|
-
"Vertically Challenged",
|
|
47465
|
-
"Visual Spectacle"
|
|
47466
|
-
];
|
|
47467
|
-
|
|
47468
47460
|
function nameMocks({ nameRoot = 'TEAM', count = 1 } = {}) {
|
|
47469
|
-
const shuffledTeamNames = shuffleArray(namesData);
|
|
47461
|
+
const shuffledTeamNames = shuffleArray(namesData$1);
|
|
47470
47462
|
const names = shuffledTeamNames.slice(0, count);
|
|
47471
47463
|
if (names.length < count) {
|
|
47472
47464
|
generateRange(0, count - names.length).forEach((i) => names.push(`${nameRoot} ${i + 1}`));
|
|
@@ -49676,10 +49668,13 @@ function processLeagueProfiles(params) {
|
|
|
49676
49668
|
const mockTournamentNames = [
|
|
49677
49669
|
'Generated Tournament',
|
|
49678
49670
|
'CourtHive Challenge',
|
|
49671
|
+
'Replication Crisis',
|
|
49679
49672
|
'Open Competition',
|
|
49680
49673
|
'Factory Follies',
|
|
49681
49674
|
'Mock Tournament',
|
|
49675
|
+
'Atomic Culture',
|
|
49682
49676
|
'Racket Rally',
|
|
49677
|
+
'Stats Fail',
|
|
49683
49678
|
];
|
|
49684
49679
|
function generateTournamentRecord(params) {
|
|
49685
49680
|
let { startDate, endDate } = params ?? {};
|