tods-competition-factory 0.48.1 → 0.48.2
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/tods-competition-factory.cjs.development.js +809 -783
- package/dist/tods-competition-factory.cjs.development.js.map +1 -1
- package/dist/tods-competition-factory.esm.js +809 -783
- package/dist/tods-competition-factory.esm.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
|
@@ -3602,7 +3602,7 @@ function generateTieMatchUpScore({
|
|
|
3602
3602
|
tieFormat,
|
|
3603
3603
|
matchUp
|
|
3604
3604
|
}) {
|
|
3605
|
-
var
|
|
3605
|
+
var _tieFormat;
|
|
3606
3606
|
|
|
3607
3607
|
if (!Array.isArray(sideAdjustments) || sideAdjustments.length !== 2 || isNaN(sideAdjustments.reduce((a, b) => a + b))) {
|
|
3608
3608
|
return {
|
|
@@ -3613,9 +3613,10 @@ function generateTieMatchUpScore({
|
|
|
3613
3613
|
if (!matchUp) return {
|
|
3614
3614
|
error: MISSING_MATCHUP
|
|
3615
3615
|
};
|
|
3616
|
+
tieFormat = matchUp.tieFormat || tieFormat;
|
|
3616
3617
|
const sidePoints = [0, 0];
|
|
3617
3618
|
const tieMatchUps = (matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps) || [];
|
|
3618
|
-
const collectionDefinitions = (
|
|
3619
|
+
const collectionDefinitions = ((_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : _tieFormat.collectionDefinitions) || [];
|
|
3619
3620
|
collectionDefinitions.forEach(collectionDefinition => {
|
|
3620
3621
|
const collectionMatchUps = tieMatchUps.filter(matchUp => matchUp.collectionId === collectionDefinition.collectionId);
|
|
3621
3622
|
|
|
@@ -3656,12 +3657,11 @@ function generateTieMatchUpScore({
|
|
|
3656
3657
|
const scoreStringSide2 = sideScores.slice().reverse().join(separator); // now calculate if there is a winningSide
|
|
3657
3658
|
|
|
3658
3659
|
let winningSide;
|
|
3659
|
-
const format = matchUp.tieFormat || tieFormat;
|
|
3660
3660
|
|
|
3661
|
-
if (
|
|
3662
|
-
var
|
|
3661
|
+
if (tieFormat) {
|
|
3662
|
+
var _tieFormat$winCriteri;
|
|
3663
3663
|
|
|
3664
|
-
const valueGoal = (
|
|
3664
|
+
const valueGoal = (_tieFormat$winCriteri = tieFormat.winCriteria) === null || _tieFormat$winCriteri === void 0 ? void 0 : _tieFormat$winCriteri.valueGoal;
|
|
3665
3665
|
|
|
3666
3666
|
if (valueGoal) {
|
|
3667
3667
|
const sideThatWon = sideScores.map((points, sideIndex) => ({
|
|
@@ -3956,600 +3956,11 @@ function checkTieFormat(tieFormat) {
|
|
|
3956
3956
|
};
|
|
3957
3957
|
}
|
|
3958
3958
|
|
|
3959
|
-
/**
|
|
3960
|
-
*
|
|
3961
|
-
* @param {object[]} - sets - TODS sets object
|
|
3962
|
-
* @param {string} - matchUpStatus - TODS matchUpStatus ENUM
|
|
3963
|
-
* @param {number || string} - winningSide - TODS side declaration: 1 or 2
|
|
3964
|
-
* @param {boolean} - winnerFirst - generate string with winner on left side
|
|
3965
|
-
* @param {boolean} - autoComplete - whether to convert undefined values to 0
|
|
3966
|
-
*
|
|
3967
|
-
*/
|
|
3968
|
-
|
|
3969
|
-
function generateScoreString(params) {
|
|
3970
|
-
const {
|
|
3971
|
-
sets,
|
|
3972
|
-
winningSide,
|
|
3973
|
-
autoComplete,
|
|
3974
|
-
matchUpStatus,
|
|
3975
|
-
reversed = false,
|
|
3976
|
-
winnerFirst = true,
|
|
3977
|
-
addOutcomeString
|
|
3978
|
-
} = params;
|
|
3979
|
-
if (!sets) return {
|
|
3980
|
-
error: MISSING_VALUE
|
|
3981
|
-
};
|
|
3982
|
-
const scoresInSideOrder = !winnerFirst || !winningSide || winningSide === 1;
|
|
3983
|
-
const reverseScores = reversed || !scoresInSideOrder;
|
|
3984
|
-
const outcomeString = addOutcomeString ? getOutcomeString({
|
|
3985
|
-
matchUpStatus
|
|
3986
|
-
}) : '';
|
|
3987
|
-
const setScores = (sets === null || sets === void 0 ? void 0 : sets.sort(setSort).map(setString).filter(Boolean) // handle situation where there are multiple empty set objects
|
|
3988
|
-
.join(' ')) || '';
|
|
3989
|
-
if (!outcomeString) return setScores;
|
|
3990
|
-
if (winningSide === 2) return `${outcomeString} ${setScores}`;
|
|
3991
|
-
return `${setScores} ${outcomeString}`;
|
|
3992
|
-
|
|
3993
|
-
function setString(currentSet) {
|
|
3994
|
-
const hasGameScores = set => isNumeric(set === null || set === void 0 ? void 0 : set.side1Score) || isNumeric(set === null || set === void 0 ? void 0 : set.side2Score);
|
|
3995
|
-
|
|
3996
|
-
const hasTiebreakScores = set => isNumeric(set === null || set === void 0 ? void 0 : set.side1TiebreakScore) || isNumeric(set === null || set === void 0 ? void 0 : set.side2TiebreakScore);
|
|
3997
|
-
|
|
3998
|
-
const isTiebreakSet = !hasGameScores(currentSet) && hasTiebreakScores(currentSet);
|
|
3999
|
-
const {
|
|
4000
|
-
side1Score,
|
|
4001
|
-
side2Score,
|
|
4002
|
-
side1TiebreakScore,
|
|
4003
|
-
side2TiebreakScore
|
|
4004
|
-
} = currentSet;
|
|
4005
|
-
const t1 = side1TiebreakScore || (isNumeric(side1TiebreakScore) || autoComplete ? 0 : '');
|
|
4006
|
-
const t2 = side2TiebreakScore || (isNumeric(side2TiebreakScore) || autoComplete ? 0 : '');
|
|
4007
|
-
|
|
4008
|
-
if (isTiebreakSet) {
|
|
4009
|
-
const tiebreakScore = reverseScores ? [t2, t1] : [t1, t2];
|
|
4010
|
-
return `[${tiebreakScore.join('-')}]`;
|
|
4011
|
-
}
|
|
4012
|
-
|
|
4013
|
-
const lowTiebreakScore = Math.min(t1, t2);
|
|
4014
|
-
const tiebreak = lowTiebreakScore ? `(${lowTiebreakScore})` : '';
|
|
4015
|
-
const s1 = side1Score || (isNumeric(side1Score) || autoComplete ? 0 : '');
|
|
4016
|
-
const s2 = side2Score || (isNumeric(side2Score) || autoComplete ? 0 : '');
|
|
4017
|
-
let scoreString = reverseScores ? `${[s2, s1].join('-')}${tiebreak}` : `${[s1, s2].join('-')}${tiebreak}`;
|
|
4018
|
-
if (['-', ' '].includes(scoreString)) scoreString = '';
|
|
4019
|
-
return scoreString;
|
|
4020
|
-
}
|
|
4021
|
-
}
|
|
4022
|
-
|
|
4023
|
-
function getOutcomeString({
|
|
4024
|
-
matchUpStatus
|
|
4025
|
-
}) {
|
|
4026
|
-
const outcomeStrings = {
|
|
4027
|
-
[RETIRED]: 'RET',
|
|
4028
|
-
[WALKOVER$1]: 'WO',
|
|
4029
|
-
[DOUBLE_WALKOVER]: 'WO/WO',
|
|
4030
|
-
[SUSPENDED]: 'SUS',
|
|
4031
|
-
[ABANDONED]: 'ABN',
|
|
4032
|
-
[DEFAULTED]: 'DEF',
|
|
4033
|
-
[DEAD_RUBBER]: 'DR'
|
|
4034
|
-
};
|
|
4035
|
-
return matchUpStatus && outcomeStrings[matchUpStatus] || '';
|
|
4036
|
-
}
|
|
4037
|
-
|
|
4038
|
-
function setSort(a, b) {
|
|
4039
|
-
return a.setNumber - b.setNumber;
|
|
4040
|
-
}
|
|
4041
|
-
|
|
4042
|
-
function getSetWinningSide({
|
|
4043
|
-
matchUpScoringFormat,
|
|
4044
|
-
isDecidingSet,
|
|
4045
|
-
isTiebreakSet,
|
|
4046
|
-
setObject
|
|
4047
|
-
}) {
|
|
4048
|
-
if (!setObject) return undefined;
|
|
4049
|
-
const leadingSide = getLeadingSide$1({
|
|
4050
|
-
set: setObject
|
|
4051
|
-
});
|
|
4052
|
-
const setIsComplete = checkSetIsComplete$1({
|
|
4053
|
-
matchUpScoringFormat,
|
|
4054
|
-
isDecidingSet,
|
|
4055
|
-
isTiebreakSet,
|
|
4056
|
-
set: setObject
|
|
4057
|
-
});
|
|
4058
|
-
return setIsComplete && leadingSide || undefined;
|
|
4059
|
-
}
|
|
4060
|
-
function checkSetIsComplete$1({
|
|
4061
|
-
ignoreTiebreak = false,
|
|
4062
|
-
matchUpScoringFormat,
|
|
4063
|
-
isTiebreakSet,
|
|
4064
|
-
isDecidingSet,
|
|
4065
|
-
set
|
|
4066
|
-
}) {
|
|
4067
|
-
if (!set) return {
|
|
4068
|
-
error: MISSING_VALUE
|
|
4069
|
-
};
|
|
4070
|
-
const setFormat = isDecidingSet && matchUpScoringFormat.finalSetFormat || (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.setFormat) || {};
|
|
4071
|
-
const {
|
|
4072
|
-
side1Score,
|
|
4073
|
-
side2Score
|
|
4074
|
-
} = set;
|
|
4075
|
-
const {
|
|
4076
|
-
setTo,
|
|
4077
|
-
tiebreakAt,
|
|
4078
|
-
tiebreakFormat
|
|
4079
|
-
} = setFormat;
|
|
4080
|
-
const NoAD = tiebreakFormat === null || tiebreakFormat === void 0 ? void 0 : tiebreakFormat.NoAd;
|
|
4081
|
-
const leadingSide = getLeadingSide$1({
|
|
4082
|
-
set
|
|
4083
|
-
});
|
|
4084
|
-
const scoreDiff = Math.abs(side1Score - side2Score);
|
|
4085
|
-
const containsSetTo = side1Score >= setTo || side2Score >= setTo;
|
|
4086
|
-
const requiresTiebreak = isTiebreakSet || side1Score >= setTo && side2Score >= setTo || tiebreakAt && tiebreakAt < setTo && (side1Score === tiebreakAt || side2Score === tiebreakAt);
|
|
4087
|
-
const tiebreakIsValid = ignoreTiebreak || requiresTiebreak && (leadingSide === 1 && set.side1TiebreakScore > set.side2TiebreakScore || leadingSide === 2 && set.side2TiebreakScore > set.side1TiebreakScore);
|
|
4088
|
-
const winMargin = requiresTiebreak && (tiebreakAt && !isTiebreakSet || isTiebreakSet && NoAD) ? 1 : 2;
|
|
4089
|
-
const hasWinMargin = scoreDiff >= winMargin;
|
|
4090
|
-
const validNormalSetScore = containsSetTo && (hasWinMargin || requiresTiebreak);
|
|
4091
|
-
return (validNormalSetScore || isTiebreakSet) && (!requiresTiebreak || tiebreakIsValid);
|
|
4092
|
-
}
|
|
4093
|
-
function getLeadingSide$1({
|
|
4094
|
-
set
|
|
4095
|
-
}) {
|
|
4096
|
-
if (set.side1Score || set.side2Score) {
|
|
4097
|
-
if (set.side1Score > set.side2Score) return 1;
|
|
4098
|
-
if (set.side2Score > set.side1Score) return 2;
|
|
4099
|
-
} else if (set.side1TiebreakScore || set.side2TiebreakScore) {
|
|
4100
|
-
if (set.side1TiebreakScore > set.side2TiebreakScore) return 1;
|
|
4101
|
-
if (set.side2TiebreakScore > set.side1TiebreakScore) return 2;
|
|
4102
|
-
}
|
|
4103
|
-
|
|
4104
|
-
return undefined;
|
|
4105
|
-
}
|
|
4106
|
-
|
|
4107
|
-
function analyzeSet(params) {
|
|
4108
|
-
const {
|
|
4109
|
-
setObject,
|
|
4110
|
-
matchUpScoringFormat
|
|
4111
|
-
} = params;
|
|
4112
|
-
if (!setObject) return {
|
|
4113
|
-
error: MISSING_SET_OBJECT
|
|
4114
|
-
};
|
|
4115
|
-
const {
|
|
4116
|
-
setNumber
|
|
4117
|
-
} = setObject || {};
|
|
4118
|
-
const {
|
|
4119
|
-
bestOf
|
|
4120
|
-
} = matchUpScoringFormat || {};
|
|
4121
|
-
const isDecidingSet = !!(setNumber && setNumber === bestOf);
|
|
4122
|
-
const setFormat = isDecidingSet && (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.finalSetFormat) || (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.setFormat);
|
|
4123
|
-
const expectTiebreakSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.tiebreakSet);
|
|
4124
|
-
const expectTimedSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.timed);
|
|
4125
|
-
const expectStandardSet = !expectTiebreakSet && !expectTimedSet;
|
|
4126
|
-
const isValidSetNumber = !!(setNumber && bestOf && setNumber <= bestOf);
|
|
4127
|
-
const sideGameScores = [setObject === null || setObject === void 0 ? void 0 : setObject.side1Score, setObject === null || setObject === void 0 ? void 0 : setObject.side2Score];
|
|
4128
|
-
const sidePointScores = [setObject === null || setObject === void 0 ? void 0 : setObject.side1PointScore, setObject === null || setObject === void 0 ? void 0 : setObject.side2PointScore];
|
|
4129
|
-
const sideTiebreakScores = [setObject === null || setObject === void 0 ? void 0 : setObject.side1TiebreakScore, setObject === null || setObject === void 0 ? void 0 : setObject.side2TiebreakScore];
|
|
4130
|
-
const sideGameScoresCount = sideGameScores.filter(sideScore => sideScore !== undefined).length;
|
|
4131
|
-
const sidePointScoresCount = sidePointScores.filter(sideScore => sideScore !== undefined).length;
|
|
4132
|
-
const sideTiebreakScoresCount = sideTiebreakScores.filter(tiebreakScore => tiebreakScore !== undefined).length;
|
|
4133
|
-
const gameScoresCount = sideGameScores === null || sideGameScores === void 0 ? void 0 : sideGameScores.filter(s => !isNaN(s)).length;
|
|
4134
|
-
const tiebreakScoresCount = sideTiebreakScores === null || sideTiebreakScores === void 0 ? void 0 : sideTiebreakScores.filter(s => !isNaN(s)).length;
|
|
4135
|
-
const {
|
|
4136
|
-
tiebreakAt
|
|
4137
|
-
} = setFormat || {};
|
|
4138
|
-
const hasTiebreakCondition = tiebreakAt && sideGameScores.filter(gameScore => gameScore >= tiebreakAt).length === 2;
|
|
4139
|
-
const leadingSide = hasTiebreakCondition && (sideGameScores[0] > sideGameScores[1] ? 1 : sideGameScores[1] > sideGameScores[0] ? 2 : undefined);
|
|
4140
|
-
const isTiebreakSet = !!(tiebreakScoresCount && !gameScoresCount);
|
|
4141
|
-
const isCompletedSet = !!(setObject && setObject !== null && setObject !== void 0 && setObject.winningSide);
|
|
4142
|
-
const {
|
|
4143
|
-
error: standardSetError,
|
|
4144
|
-
result: isValidStandardSetOutcome
|
|
4145
|
-
} = checkValidStandardSetOutcome({
|
|
4146
|
-
setObject,
|
|
4147
|
-
setFormat,
|
|
4148
|
-
sideGameScores,
|
|
4149
|
-
sideTiebreakScores
|
|
4150
|
-
});
|
|
4151
|
-
const {
|
|
4152
|
-
error: tiebreakSetError,
|
|
4153
|
-
result: isValidTiebreakSetOutcome
|
|
4154
|
-
} = checkValidTiebreakSetOutcome({
|
|
4155
|
-
setObject,
|
|
4156
|
-
setFormat,
|
|
4157
|
-
sideTiebreakScores
|
|
4158
|
-
});
|
|
4159
|
-
const isValidSetOutcome = expectStandardSet && !isTiebreakSet && isValidStandardSetOutcome || expectTiebreakSet && isTiebreakSet && isValidTiebreakSetOutcome;
|
|
4160
|
-
const isValidSet = isValidSetNumber && !(expectTiebreakSet && !isTiebreakSet) && !(expectStandardSet && isTiebreakSet) && (!isCompletedSet || isValidSetOutcome);
|
|
4161
|
-
const winningSide = getSetWinningSide({
|
|
4162
|
-
isDecidingSet,
|
|
4163
|
-
isTiebreakSet,
|
|
4164
|
-
matchUpScoringFormat,
|
|
4165
|
-
setObject
|
|
4166
|
-
});
|
|
4167
|
-
const analysis = {
|
|
4168
|
-
expectTiebreakSet,
|
|
4169
|
-
expectTimedSet,
|
|
4170
|
-
hasTiebreakCondition,
|
|
4171
|
-
isCompletedSet,
|
|
4172
|
-
isDecidingSet,
|
|
4173
|
-
isTiebreakSet,
|
|
4174
|
-
isValidSet,
|
|
4175
|
-
isValidSetNumber,
|
|
4176
|
-
isValidSetOutcome,
|
|
4177
|
-
leadingSide,
|
|
4178
|
-
setFormat,
|
|
4179
|
-
sideGameScores,
|
|
4180
|
-
sideGameScoresCount,
|
|
4181
|
-
sidePointScores,
|
|
4182
|
-
sidePointScoresCount,
|
|
4183
|
-
sideTiebreakScores,
|
|
4184
|
-
sideTiebreakScoresCount,
|
|
4185
|
-
winningSide
|
|
4186
|
-
};
|
|
4187
|
-
|
|
4188
|
-
if ((setObject === null || setObject === void 0 ? void 0 : setObject.winningSide) !== undefined) {
|
|
4189
|
-
if (isTiebreakSet) {
|
|
4190
|
-
analysis.isValidTiebreakSetOutcome = isValidTiebreakSetOutcome;
|
|
4191
|
-
|
|
4192
|
-
if (!isValidTiebreakSetOutcome) {
|
|
4193
|
-
analysis.tiebreakSetError = tiebreakSetError;
|
|
4194
|
-
}
|
|
4195
|
-
} else {
|
|
4196
|
-
analysis.isValidStandardSetOutcome = isValidStandardSetOutcome;
|
|
4197
|
-
|
|
4198
|
-
if (!isValidStandardSetOutcome) {
|
|
4199
|
-
analysis.standardSetError = standardSetError;
|
|
4200
|
-
}
|
|
4201
|
-
}
|
|
4202
|
-
}
|
|
4203
|
-
|
|
4204
|
-
return analysis;
|
|
4205
|
-
}
|
|
4206
|
-
|
|
4207
|
-
function checkValidStandardSetOutcome({
|
|
4208
|
-
setObject,
|
|
4209
|
-
setFormat,
|
|
4210
|
-
sideGameScores,
|
|
4211
|
-
sideTiebreakScores
|
|
4212
|
-
}) {
|
|
4213
|
-
if (!setObject) {
|
|
4214
|
-
return {
|
|
4215
|
-
result: false,
|
|
4216
|
-
error: MISSING_SET_OBJECT
|
|
4217
|
-
};
|
|
4218
|
-
}
|
|
4219
|
-
|
|
4220
|
-
const expectTiebreakSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.tiebreakSet);
|
|
4221
|
-
const expectTimedSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.timed);
|
|
4222
|
-
|
|
4223
|
-
if (!setFormat || expectTiebreakSet || expectTimedSet) {
|
|
4224
|
-
return {
|
|
4225
|
-
result: false,
|
|
4226
|
-
error: 'not standard set'
|
|
4227
|
-
};
|
|
4228
|
-
}
|
|
4229
|
-
|
|
4230
|
-
const validGameScores = (sideGameScores === null || sideGameScores === void 0 ? void 0 : sideGameScores.filter(s => !isNaN(s)).length) === 2;
|
|
4231
|
-
if (!validGameScores) return {
|
|
4232
|
-
result: false,
|
|
4233
|
-
error: INVALID_GAME_SCORES
|
|
4234
|
-
};
|
|
4235
|
-
const {
|
|
4236
|
-
setTo,
|
|
4237
|
-
tiebreakAt,
|
|
4238
|
-
tiebreakFormat,
|
|
4239
|
-
NoAD
|
|
4240
|
-
} = setFormat || {};
|
|
4241
|
-
const meetsSetTo = !!(setTo && sideGameScores !== null && sideGameScores !== void 0 && sideGameScores.find(gameScore => gameScore >= setTo));
|
|
4242
|
-
if (!meetsSetTo) return {
|
|
4243
|
-
result: false,
|
|
4244
|
-
error: INVALID_GAME_SCORES
|
|
4245
|
-
};
|
|
4246
|
-
const isValidWinningSide = [1, 2].includes(setObject === null || setObject === void 0 ? void 0 : setObject.winningSide);
|
|
4247
|
-
if (!setObject || !isValidWinningSide) return {
|
|
4248
|
-
result: false,
|
|
4249
|
-
error: INVALID_WINNING_SIDE
|
|
4250
|
-
};
|
|
4251
|
-
const winningSideIndex = (setObject === null || setObject === void 0 ? void 0 : setObject.winningSide) - 1;
|
|
4252
|
-
const losingSideIndex = 1 - winningSideIndex;
|
|
4253
|
-
const winningSideGameScore = sideGameScores[winningSideIndex];
|
|
4254
|
-
const losingSideGameScore = sideGameScores[losingSideIndex];
|
|
4255
|
-
const gamesDifference = winningSideGameScore - losingSideGameScore;
|
|
4256
|
-
const winningSideIsHighGameValue = winningSideGameScore > losingSideGameScore;
|
|
4257
|
-
|
|
4258
|
-
if (!winningSideIsHighGameValue) {
|
|
4259
|
-
return {
|
|
4260
|
-
result: false,
|
|
4261
|
-
error: 'winningSide game scoreString is not high'
|
|
4262
|
-
};
|
|
4263
|
-
}
|
|
4264
|
-
|
|
4265
|
-
const setTiebreakDefined = tiebreakAt && tiebreakFormat;
|
|
4266
|
-
const validTiebreakScores = (sideTiebreakScores === null || sideTiebreakScores === void 0 ? void 0 : sideTiebreakScores.filter(s => !isNaN(s)).length) === 2;
|
|
4267
|
-
const winningSideTiebreakScore = sideTiebreakScores && sideTiebreakScores[winningSideIndex];
|
|
4268
|
-
const losingSideTiebreakScore = sideTiebreakScores && sideTiebreakScores[losingSideIndex];
|
|
4269
|
-
const hasTiebreakCondition = tiebreakAt && sideGameScores.filter(gameScore => gameScore >= tiebreakAt).length === 2;
|
|
4270
|
-
|
|
4271
|
-
if (setTiebreakDefined) {
|
|
4272
|
-
const {
|
|
4273
|
-
NoAD: tiebreakNoAD,
|
|
4274
|
-
tiebreakTo
|
|
4275
|
-
} = tiebreakFormat;
|
|
4276
|
-
|
|
4277
|
-
if (hasTiebreakCondition) {
|
|
4278
|
-
if (gamesDifference > 1) {
|
|
4279
|
-
return {
|
|
4280
|
-
result: false,
|
|
4281
|
-
error: 'invalid winning game scoreString (5)'
|
|
4282
|
-
};
|
|
4283
|
-
}
|
|
4284
|
-
|
|
4285
|
-
if (!validTiebreakScores) {
|
|
4286
|
-
return {
|
|
4287
|
-
result: false,
|
|
4288
|
-
error: 'invalid tiebreak scores (1)'
|
|
4289
|
-
};
|
|
4290
|
-
}
|
|
4291
|
-
|
|
4292
|
-
if (isNaN(tiebreakTo)) {
|
|
4293
|
-
return {
|
|
4294
|
-
result: false,
|
|
4295
|
-
error: 'tiebreakTo error'
|
|
4296
|
-
}; // TODO: test this
|
|
4297
|
-
}
|
|
4298
|
-
|
|
4299
|
-
const meetsTiebreakTo = !!(tiebreakTo && sideTiebreakScores !== null && sideTiebreakScores !== void 0 && sideTiebreakScores.find(tiebreakScore => tiebreakScore >= tiebreakTo));
|
|
4300
|
-
|
|
4301
|
-
if (!meetsTiebreakTo) {
|
|
4302
|
-
return {
|
|
4303
|
-
result: false,
|
|
4304
|
-
error: 'invalid tiebreak scores (2)'
|
|
4305
|
-
};
|
|
4306
|
-
}
|
|
4307
|
-
|
|
4308
|
-
const maxGameScore = tiebreakAt < setTo ? setTo : setTo + 1;
|
|
4309
|
-
|
|
4310
|
-
if (winningSideGameScore > maxGameScore) {
|
|
4311
|
-
return {
|
|
4312
|
-
result: false,
|
|
4313
|
-
error: 'invalid winning game scoreString (1)'
|
|
4314
|
-
};
|
|
4315
|
-
}
|
|
4316
|
-
|
|
4317
|
-
if (!winningSideTiebreakScore || !losingSideTiebreakScore || winningSideTiebreakScore < losingSideTiebreakScore) {
|
|
4318
|
-
return {
|
|
4319
|
-
result: false,
|
|
4320
|
-
error: 'winningSide tiebreak value is not high'
|
|
4321
|
-
};
|
|
4322
|
-
}
|
|
4323
|
-
|
|
4324
|
-
const minimumTiebreakWinMargin = tiebreakNoAD ? 1 : 2;
|
|
4325
|
-
const tiebreakDifference = winningSideTiebreakScore - losingSideTiebreakScore;
|
|
4326
|
-
const losingSideGameScoreAtTiebreakToThreshold = losingSideTiebreakScore >= tiebreakTo - 1;
|
|
4327
|
-
const invalidTiebreakScore = tiebreakDifference && losingSideGameScoreAtTiebreakToThreshold && tiebreakDifference < minimumTiebreakWinMargin;
|
|
4328
|
-
|
|
4329
|
-
if (invalidTiebreakScore) {
|
|
4330
|
-
return {
|
|
4331
|
-
result: false,
|
|
4332
|
-
error: 'invalid tiebreak scores (3)'
|
|
4333
|
-
};
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
|
|
4337
|
-
const hasTiebreakGameScore = winningSideGameScore > setTo;
|
|
4338
|
-
|
|
4339
|
-
if (hasTiebreakGameScore && (!setTiebreakDefined || !hasTiebreakCondition)) {
|
|
4340
|
-
return {
|
|
4341
|
-
result: false,
|
|
4342
|
-
error: 'invalid winning game scoreString (2)'
|
|
4343
|
-
};
|
|
4344
|
-
}
|
|
4345
|
-
}
|
|
4346
|
-
|
|
4347
|
-
const minimumGamesWinMargin = NoAD ? 1 : 2;
|
|
4348
|
-
const losingSideGameScoreAtSetToThreshold = losingSideGameScore >= setTo - 1;
|
|
4349
|
-
const invalidWinningScore = gamesDifference && losingSideGameScoreAtSetToThreshold && !hasTiebreakCondition && gamesDifference < minimumGamesWinMargin;
|
|
4350
|
-
|
|
4351
|
-
if (invalidWinningScore) {
|
|
4352
|
-
return {
|
|
4353
|
-
result: false,
|
|
4354
|
-
error: 'invalid winning game scoreString (3)'
|
|
4355
|
-
};
|
|
4356
|
-
}
|
|
4357
|
-
|
|
4358
|
-
if (gamesDifference > minimumGamesWinMargin && winningSideGameScore > setTo) {
|
|
4359
|
-
return {
|
|
4360
|
-
result: false,
|
|
4361
|
-
error: 'invalid winning game scoreString (4)'
|
|
4362
|
-
};
|
|
4363
|
-
}
|
|
4364
|
-
|
|
4365
|
-
return {
|
|
4366
|
-
result: true
|
|
4367
|
-
};
|
|
4368
|
-
}
|
|
4369
|
-
|
|
4370
|
-
function checkValidTiebreakSetOutcome({
|
|
4371
|
-
setObject,
|
|
4372
|
-
setFormat,
|
|
4373
|
-
sideTiebreakScores
|
|
4374
|
-
}) {
|
|
4375
|
-
if (!setObject) {
|
|
4376
|
-
return {
|
|
4377
|
-
result: false,
|
|
4378
|
-
error: MISSING_SET_OBJECT
|
|
4379
|
-
};
|
|
4380
|
-
}
|
|
4381
|
-
|
|
4382
|
-
const expectTiebreakSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.tiebreakSet);
|
|
4383
|
-
const expectTimedSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.timed);
|
|
4384
|
-
|
|
4385
|
-
if (!setFormat || !expectTiebreakSet || expectTimedSet) {
|
|
4386
|
-
return {
|
|
4387
|
-
result: false,
|
|
4388
|
-
error: 'not tiebreak set'
|
|
4389
|
-
};
|
|
4390
|
-
}
|
|
4391
|
-
|
|
4392
|
-
const isValidWinningSide = [1, 2].includes(setObject === null || setObject === void 0 ? void 0 : setObject.winningSide);
|
|
4393
|
-
if (!setObject || !isValidWinningSide) return {
|
|
4394
|
-
result: false,
|
|
4395
|
-
error: INVALID_WINNING_SIDE
|
|
4396
|
-
};
|
|
4397
|
-
const {
|
|
4398
|
-
tiebreakSet
|
|
4399
|
-
} = setFormat || {};
|
|
4400
|
-
const {
|
|
4401
|
-
NoAD,
|
|
4402
|
-
tiebreakTo
|
|
4403
|
-
} = tiebreakSet || {};
|
|
4404
|
-
const validTiebreakScores = (sideTiebreakScores === null || sideTiebreakScores === void 0 ? void 0 : sideTiebreakScores.filter(s => !isNaN(s)).length) === 2;
|
|
4405
|
-
|
|
4406
|
-
if (!validTiebreakScores) {
|
|
4407
|
-
return {
|
|
4408
|
-
result: false,
|
|
4409
|
-
error: 'invalid tiebreak scores (1)'
|
|
4410
|
-
};
|
|
4411
|
-
}
|
|
4412
|
-
|
|
4413
|
-
if (isNaN(tiebreakTo)) {
|
|
4414
|
-
return {
|
|
4415
|
-
result: false,
|
|
4416
|
-
error: 'tiebreakTo error'
|
|
4417
|
-
}; // TODO: test this
|
|
4418
|
-
}
|
|
4419
|
-
|
|
4420
|
-
const meetsTiebreakTo = !!(sideTiebreakScores !== null && sideTiebreakScores !== void 0 && sideTiebreakScores.find(tiebreakScore => tiebreakScore >= tiebreakTo));
|
|
4421
|
-
|
|
4422
|
-
if (!meetsTiebreakTo) {
|
|
4423
|
-
return {
|
|
4424
|
-
result: false,
|
|
4425
|
-
error: 'invalid tiebreak scores (2)'
|
|
4426
|
-
};
|
|
4427
|
-
}
|
|
4428
|
-
|
|
4429
|
-
const winningSideIndex = (setObject === null || setObject === void 0 ? void 0 : setObject.winningSide) - 1;
|
|
4430
|
-
const losingSideIndex = 1 - winningSideIndex;
|
|
4431
|
-
const winningSideTiebreakScore = sideTiebreakScores[winningSideIndex];
|
|
4432
|
-
const losingSideTiebreakScore = sideTiebreakScores[losingSideIndex];
|
|
4433
|
-
|
|
4434
|
-
if (!winningSideTiebreakScore || !losingSideTiebreakScore || winningSideTiebreakScore < losingSideTiebreakScore) {
|
|
4435
|
-
return {
|
|
4436
|
-
result: false,
|
|
4437
|
-
error: 'winningSide tiebreak value is not high'
|
|
4438
|
-
};
|
|
4439
|
-
}
|
|
4440
|
-
|
|
4441
|
-
const minimumTiebreakWinMargin = NoAD ? 1 : 2;
|
|
4442
|
-
const tiebreakDifference = winningSideTiebreakScore - losingSideTiebreakScore;
|
|
4443
|
-
const losingSideGameScoreAtTiebreakToThreshold = losingSideTiebreakScore >= tiebreakTo - 1;
|
|
4444
|
-
const invalidTiebreakScore = tiebreakDifference && losingSideGameScoreAtTiebreakToThreshold && tiebreakDifference < minimumTiebreakWinMargin;
|
|
4445
|
-
|
|
4446
|
-
if (invalidTiebreakScore) {
|
|
4447
|
-
return {
|
|
4448
|
-
result: false,
|
|
4449
|
-
error: 'invalid tiebreak scores (3)'
|
|
4450
|
-
};
|
|
4451
|
-
}
|
|
4452
|
-
|
|
4453
|
-
return {
|
|
4454
|
-
result: true
|
|
4455
|
-
};
|
|
4456
|
-
}
|
|
4457
|
-
|
|
4458
|
-
function analyzeMatchUp(params) {
|
|
4459
|
-
var _matchUp$score;
|
|
4460
|
-
|
|
4461
|
-
const {
|
|
4462
|
-
matchUp,
|
|
4463
|
-
sideNumber,
|
|
4464
|
-
setNumber,
|
|
4465
|
-
isTiebreakValue,
|
|
4466
|
-
isPointValue
|
|
4467
|
-
} = params || {};
|
|
4468
|
-
let {
|
|
4469
|
-
matchUpFormat
|
|
4470
|
-
} = params || {};
|
|
4471
|
-
if (!matchUp) return {
|
|
4472
|
-
error: MISSING_MATCHUP
|
|
4473
|
-
};
|
|
4474
|
-
matchUpFormat = matchUpFormat || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpFormat);
|
|
4475
|
-
const matchUpScoringFormat = dist.exports.matchUpFormatCode === null || dist.exports.matchUpFormatCode === void 0 ? void 0 : dist.exports.matchUpFormatCode.parse(matchUpFormat);
|
|
4476
|
-
const isCompletedMatchUp = !!(matchUp !== null && matchUp !== void 0 && matchUp.winningSide);
|
|
4477
|
-
const sets = (_matchUp$score = matchUp.score) === null || _matchUp$score === void 0 ? void 0 : _matchUp$score.sets;
|
|
4478
|
-
const setsCount = sets === null || sets === void 0 ? void 0 : sets.length;
|
|
4479
|
-
const setIndex = setNumber && setNumber - 1;
|
|
4480
|
-
const isExistingSet = !!(sets !== null && sets !== void 0 && sets.find((set, index) => set.setNumber === setNumber && index === setIndex));
|
|
4481
|
-
const completedSets = (sets === null || sets === void 0 ? void 0 : sets.filter(set => set === null || set === void 0 ? void 0 : set.winningSide)) || [];
|
|
4482
|
-
const completedSetsCount = (completedSets === null || completedSets === void 0 ? void 0 : completedSets.length) || 0;
|
|
4483
|
-
const setsFollowingCurrent = setNumber && (sets === null || sets === void 0 ? void 0 : sets.slice(setNumber)) || [];
|
|
4484
|
-
const isLastSetWithValues = !!(setsCount && setNumber && // EVERY: is this a candidate for .every?
|
|
4485
|
-
setsFollowingCurrent !== null && setsFollowingCurrent !== void 0 && setsFollowingCurrent.reduce((noValues, set) => {
|
|
4486
|
-
return (!set || !set.side1Score && !set.side2Score && !set.side1TiebreakScore && !set.side2TiebreakScore && !set.side1PointScore && !set.side2PointScore) && noValues;
|
|
4487
|
-
}, true));
|
|
4488
|
-
const setObject = setNumber <= setsCount && sets.find(set => set.setNumber === setNumber);
|
|
4489
|
-
const specifiedSetAnalysis = setObject && analyzeSet({
|
|
4490
|
-
setObject,
|
|
4491
|
-
matchUpScoringFormat
|
|
4492
|
-
});
|
|
4493
|
-
const {
|
|
4494
|
-
isCompletedSet,
|
|
4495
|
-
sideGameScores,
|
|
4496
|
-
// sidePointScores,
|
|
4497
|
-
sideTiebreakScores
|
|
4498
|
-
} = specifiedSetAnalysis || {};
|
|
4499
|
-
const isActiveSet = !!(setObject && !isCompletedSet && isLastSetWithValues || setNumber && setNumber === setsCount + 1 && !isCompletedMatchUp);
|
|
4500
|
-
const isValidSideNumber = [1, 2].includes(sideNumber);
|
|
4501
|
-
const sideIndex = isValidSideNumber ? sideNumber - 1 : 0;
|
|
4502
|
-
const existingValue = setObject && isValidSideNumber && (!isTiebreakValue && !isPointValue && sideGameScores[sideIndex] !== undefined && sideGameScores[sideIndex] || isTiebreakValue && sideTiebreakScores[sideIndex] !== undefined && sideTiebreakScores[sideIndex]);
|
|
4503
|
-
const hasExistingValue = !!existingValue;
|
|
4504
|
-
const completedSetsHaveValidOutcomes = completedSets && completedSets.map(setObject => analyzeSet({
|
|
4505
|
-
setObject,
|
|
4506
|
-
matchUpScoringFormat
|
|
4507
|
-
}).isValidSetOutcome).reduce((valid, validOutcome) => valid && validOutcome, true);
|
|
4508
|
-
const setsWinCounts = completedSets.reduce((counts, set) => {
|
|
4509
|
-
const {
|
|
4510
|
-
winningSide
|
|
4511
|
-
} = set;
|
|
4512
|
-
const winningSideIndex = winningSide - 1;
|
|
4513
|
-
counts[winningSideIndex]++;
|
|
4514
|
-
return counts;
|
|
4515
|
-
}, [0, 0]);
|
|
4516
|
-
const matchUpWinningSide = matchUp === null || matchUp === void 0 ? void 0 : matchUp.winningSide;
|
|
4517
|
-
const matchUpWinningSideIndex = matchUpWinningSide && matchUpWinningSide - 1;
|
|
4518
|
-
const matchUpLosingSideIndex = 1 - matchUpWinningSideIndex;
|
|
4519
|
-
const winningSideSetsCount = setsWinCounts[matchUpWinningSideIndex];
|
|
4520
|
-
const losingSideSetsCount = setsWinCounts[matchUpLosingSideIndex];
|
|
4521
|
-
const maxSetsCount = Math.max(...setsWinCounts);
|
|
4522
|
-
const maxSetsInstances = instanceCount(setsWinCounts)[maxSetsCount];
|
|
4523
|
-
const {
|
|
4524
|
-
bestOf
|
|
4525
|
-
} = matchUpScoringFormat || {};
|
|
4526
|
-
const setsToWin = bestOf && Math.ceil(bestOf / 2) || 1;
|
|
4527
|
-
const calculatedWinningSide = maxSetsCount === setsToWin && maxSetsInstances === 1 && setsWinCounts.indexOf(maxSetsCount) + 1 || undefined;
|
|
4528
|
-
const validMatchUpWinningSide = winningSideSetsCount > losingSideSetsCount && matchUpWinningSide === calculatedWinningSide;
|
|
4529
|
-
const validMatchUpOutcome = calculatedWinningSide && completedSetsHaveValidOutcomes && validMatchUpWinningSide;
|
|
4530
|
-
return {
|
|
4531
|
-
isActiveSet,
|
|
4532
|
-
isExistingSet,
|
|
4533
|
-
existingValue,
|
|
4534
|
-
hasExistingValue,
|
|
4535
|
-
isValidSideNumber,
|
|
4536
|
-
completedSetsCount,
|
|
4537
|
-
isCompletedMatchUp,
|
|
4538
|
-
isLastSetWithValues,
|
|
4539
|
-
validMatchUpOutcome,
|
|
4540
|
-
matchUpScoringFormat,
|
|
4541
|
-
calculatedWinningSide,
|
|
4542
|
-
validMatchUpWinningSide,
|
|
4543
|
-
completedSetsHaveValidOutcomes,
|
|
4544
|
-
...specifiedSetAnalysis
|
|
4545
|
-
};
|
|
4546
|
-
}
|
|
4547
|
-
|
|
4548
3959
|
function getWinningSide({
|
|
4549
3960
|
analysis,
|
|
4550
3961
|
set
|
|
4551
3962
|
}) {
|
|
4552
|
-
const leadingSide = getLeadingSide({
|
|
3963
|
+
const leadingSide = getLeadingSide$1({
|
|
4553
3964
|
set
|
|
4554
3965
|
});
|
|
4555
3966
|
const {
|
|
@@ -4557,7 +3968,7 @@ function getWinningSide({
|
|
|
4557
3968
|
isTiebreakSet,
|
|
4558
3969
|
matchUpScoringFormat
|
|
4559
3970
|
} = analysis;
|
|
4560
|
-
const setIsComplete = checkSetIsComplete({
|
|
3971
|
+
const setIsComplete = checkSetIsComplete$1({
|
|
4561
3972
|
matchUpScoringFormat,
|
|
4562
3973
|
isDecidingSet,
|
|
4563
3974
|
isTiebreakSet,
|
|
@@ -4565,17 +3976,21 @@ function getWinningSide({
|
|
|
4565
3976
|
});
|
|
4566
3977
|
return setIsComplete && leadingSide;
|
|
4567
3978
|
}
|
|
4568
|
-
function checkSetIsComplete({
|
|
3979
|
+
function checkSetIsComplete$1({
|
|
4569
3980
|
ignoreTiebreak = false,
|
|
4570
3981
|
matchUpScoringFormat,
|
|
3982
|
+
matchUpFormat,
|
|
4571
3983
|
isTiebreakSet,
|
|
4572
3984
|
isDecidingSet,
|
|
4573
3985
|
set
|
|
4574
3986
|
}) {
|
|
3987
|
+
var _matchUpScoringFormat;
|
|
3988
|
+
|
|
4575
3989
|
if (!set) return {
|
|
4576
3990
|
error: MISSING_VALUE
|
|
4577
3991
|
};
|
|
4578
|
-
|
|
3992
|
+
matchUpScoringFormat = matchUpScoringFormat || matchUpFormat;
|
|
3993
|
+
const setFormat = isDecidingSet && matchUpScoringFormat.finalSetFormat || ((_matchUpScoringFormat = matchUpScoringFormat) === null || _matchUpScoringFormat === void 0 ? void 0 : _matchUpScoringFormat.setFormat);
|
|
4579
3994
|
const {
|
|
4580
3995
|
side1Score,
|
|
4581
3996
|
side2Score
|
|
@@ -4587,7 +4002,7 @@ function checkSetIsComplete({
|
|
|
4587
4002
|
tiebreakFormat
|
|
4588
4003
|
} = setFormat;
|
|
4589
4004
|
const tiebreakNoAd = tiebreakFormat === null || tiebreakFormat === void 0 ? void 0 : tiebreakFormat.NoAd;
|
|
4590
|
-
const leadingSide = getLeadingSide({
|
|
4005
|
+
const leadingSide = getLeadingSide$1({
|
|
4591
4006
|
set
|
|
4592
4007
|
});
|
|
4593
4008
|
const scoreDiff = Math.abs(side1Score - side2Score);
|
|
@@ -4599,7 +4014,7 @@ function checkSetIsComplete({
|
|
|
4599
4014
|
const validNormalSetScore = containsSetTo && (hasWinMargin || requiresTiebreak);
|
|
4600
4015
|
return (validNormalSetScore || isTiebreakSet) && (!requiresTiebreak || tiebreakIsValid);
|
|
4601
4016
|
}
|
|
4602
|
-
function getLeadingSide({
|
|
4017
|
+
function getLeadingSide$1({
|
|
4603
4018
|
set
|
|
4604
4019
|
}) {
|
|
4605
4020
|
if (set.side1Score || set.side2Score) {
|
|
@@ -5736,148 +5151,741 @@ function keyValueScore(params) {
|
|
|
5736
5151
|
tiebreakFormat
|
|
5737
5152
|
} = analysis.setFormat;
|
|
5738
5153
|
const {
|
|
5739
|
-
tiebreakTo,
|
|
5740
|
-
NoAD
|
|
5741
|
-
} = tiebreakFormat || {};
|
|
5742
|
-
const leadingSide = getLeadingSide({
|
|
5743
|
-
set
|
|
5744
|
-
});
|
|
5154
|
+
tiebreakTo,
|
|
5155
|
+
NoAD
|
|
5156
|
+
} = tiebreakFormat || {};
|
|
5157
|
+
const leadingSide = getLeadingSide$1({
|
|
5158
|
+
set
|
|
5159
|
+
});
|
|
5160
|
+
|
|
5161
|
+
if (!analysis.isTiebreakSet) {
|
|
5162
|
+
const lowTiebreakScore = parseInt(scoreString.split(open).reverse()[0]);
|
|
5163
|
+
const highTiebreakScore = getHighTiebreakValue({
|
|
5164
|
+
lowValue: lowTiebreakScore,
|
|
5165
|
+
tiebreakTo,
|
|
5166
|
+
NoAD
|
|
5167
|
+
});
|
|
5168
|
+
|
|
5169
|
+
if (leadingSide === 1) {
|
|
5170
|
+
set.side1TiebreakScore = highTiebreakScore;
|
|
5171
|
+
set.side2TiebreakScore = lowTiebreakScore;
|
|
5172
|
+
} else {
|
|
5173
|
+
set.side1TiebreakScore = lowTiebreakScore;
|
|
5174
|
+
set.side2TiebreakScore = highTiebreakScore;
|
|
5175
|
+
}
|
|
5176
|
+
}
|
|
5177
|
+
|
|
5178
|
+
scoreString = (scoreString || '') + close;
|
|
5179
|
+
if (!analysis.isDecidingSet) scoreString += SPACE_CHARACTER;
|
|
5180
|
+
const winningSide = getWinningSide({
|
|
5181
|
+
analysis,
|
|
5182
|
+
set
|
|
5183
|
+
});
|
|
5184
|
+
set.winningSide = winningSide || undefined;
|
|
5185
|
+
updated = true;
|
|
5186
|
+
} else if (analysis.isTiebreakSetValue) {
|
|
5187
|
+
({
|
|
5188
|
+
message,
|
|
5189
|
+
scoreString,
|
|
5190
|
+
sets,
|
|
5191
|
+
updated
|
|
5192
|
+
} = processTiebreakSet({
|
|
5193
|
+
analysis,
|
|
5194
|
+
auto,
|
|
5195
|
+
lowSide,
|
|
5196
|
+
scoreString,
|
|
5197
|
+
sets,
|
|
5198
|
+
value
|
|
5199
|
+
}));
|
|
5200
|
+
} else if (analysis.isSetTiebreakEntry) {
|
|
5201
|
+
const [open] = SET_TIEBREAK_BRACKETS.split('');
|
|
5202
|
+
const lastOpenBracketIndex = Math.max(...indices(open, scoreString.split('')));
|
|
5203
|
+
const tiebreakValue = scoreString.slice(lastOpenBracketIndex + 1);
|
|
5204
|
+
const hasZeroStart = tiebreakValue && parseInt(tiebreakValue) === ZERO;
|
|
5205
|
+
const newTiebreakValue = parseInt(tiebreakValue ? tiebreakValue + value : value);
|
|
5206
|
+
const {
|
|
5207
|
+
tiebreakFormat
|
|
5208
|
+
} = analysis.setFormat;
|
|
5209
|
+
const {
|
|
5210
|
+
tiebreakTo,
|
|
5211
|
+
NoAD
|
|
5212
|
+
} = tiebreakFormat || {};
|
|
5213
|
+
|
|
5214
|
+
if (!hasZeroStart && tiebreakValue.length < 2) {
|
|
5215
|
+
if (NoAD && newTiebreakValue > tiebreakTo - 1) {
|
|
5216
|
+
message = 'invalid low value for NoAD tiebreak';
|
|
5217
|
+
} else {
|
|
5218
|
+
updated = true;
|
|
5219
|
+
scoreString = (scoreString || '') + value;
|
|
5220
|
+
}
|
|
5221
|
+
} else {
|
|
5222
|
+
message = hasZeroStart ? 'tiebreak begins with zero' : 'tiebreak digit limit';
|
|
5223
|
+
}
|
|
5224
|
+
} else if (analysis.isCloser) {
|
|
5225
|
+
message = `invalid key: ${value}`;
|
|
5226
|
+
} else if (analysis.isGameScoreEntry) {
|
|
5227
|
+
message = 'game scoreString entry';
|
|
5228
|
+
} else {
|
|
5229
|
+
if (analysis.lastSetIsComplete || !sets.length) {
|
|
5230
|
+
var _sets, _sets2;
|
|
5231
|
+
|
|
5232
|
+
updated = true;
|
|
5233
|
+
const {
|
|
5234
|
+
scoreString: newScore,
|
|
5235
|
+
set
|
|
5236
|
+
} = keyValueSetScore({
|
|
5237
|
+
analysis,
|
|
5238
|
+
lowSide,
|
|
5239
|
+
scoreString,
|
|
5240
|
+
value: parseInt(value)
|
|
5241
|
+
});
|
|
5242
|
+
if (set) set.setNumber = ((_sets = sets) === null || _sets === void 0 ? void 0 : _sets.length) + 1 || 1;
|
|
5243
|
+
sets = ((_sets2 = sets) === null || _sets2 === void 0 ? void 0 : _sets2.concat(set).filter(Boolean)) || [set];
|
|
5244
|
+
scoreString = newScore || undefined;
|
|
5245
|
+
} else {
|
|
5246
|
+
console.log('error: unknown outcome');
|
|
5247
|
+
}
|
|
5248
|
+
}
|
|
5249
|
+
|
|
5250
|
+
if (updated) {
|
|
5251
|
+
var _sets3;
|
|
5252
|
+
|
|
5253
|
+
sets = (_sets3 = sets) === null || _sets3 === void 0 ? void 0 : _sets3.filter(Boolean);
|
|
5254
|
+
const {
|
|
5255
|
+
matchUpWinningSide
|
|
5256
|
+
} = getMatchUpWinner({
|
|
5257
|
+
sets,
|
|
5258
|
+
winningSide,
|
|
5259
|
+
matchUpStatus,
|
|
5260
|
+
matchUpFormat
|
|
5261
|
+
});
|
|
5262
|
+
winningSide = matchUpWinningSide;
|
|
5263
|
+
|
|
5264
|
+
if (matchUpWinningSide && (!matchUpStatus || [TO_BE_PLAYED, INCOMPLETE].includes(matchUpStatus))) {
|
|
5265
|
+
matchUpStatus = OUTCOME_COMPLETE;
|
|
5266
|
+
sets = sets.filter(set => {
|
|
5267
|
+
const {
|
|
5268
|
+
side1Score,
|
|
5269
|
+
side2Score,
|
|
5270
|
+
side1TiebreakScore,
|
|
5271
|
+
side2TiebreakScore
|
|
5272
|
+
} = set;
|
|
5273
|
+
return side1Score || side2Score || side1TiebreakScore || side2TiebreakScore;
|
|
5274
|
+
});
|
|
5275
|
+
} else if (scoreString && !winningSide && ![STATUS_SUSPENDED, STATUS_ABANDONED, STATUS_INTERRUPTED].includes(matchUpStatus)) {
|
|
5276
|
+
matchUpStatus = undefined;
|
|
5277
|
+
}
|
|
5278
|
+
|
|
5279
|
+
return {
|
|
5280
|
+
updated,
|
|
5281
|
+
scoreString,
|
|
5282
|
+
sets,
|
|
5283
|
+
winningSide,
|
|
5284
|
+
matchUpStatus,
|
|
5285
|
+
message
|
|
5286
|
+
};
|
|
5287
|
+
}
|
|
5288
|
+
|
|
5289
|
+
return {
|
|
5290
|
+
updated,
|
|
5291
|
+
scoreString,
|
|
5292
|
+
sets,
|
|
5293
|
+
winningSide,
|
|
5294
|
+
matchUpStatus,
|
|
5295
|
+
message
|
|
5296
|
+
};
|
|
5297
|
+
}
|
|
5298
|
+
|
|
5299
|
+
/**
|
|
5300
|
+
*
|
|
5301
|
+
* @param {object[]} - sets - TODS sets object
|
|
5302
|
+
* @param {string} - matchUpStatus - TODS matchUpStatus ENUM
|
|
5303
|
+
* @param {number || string} - winningSide - TODS side declaration: 1 or 2
|
|
5304
|
+
* @param {boolean} - winnerFirst - generate string with winner on left side
|
|
5305
|
+
* @param {boolean} - autoComplete - whether to convert undefined values to 0
|
|
5306
|
+
*
|
|
5307
|
+
*/
|
|
5308
|
+
|
|
5309
|
+
function generateScoreString(params) {
|
|
5310
|
+
const {
|
|
5311
|
+
sets,
|
|
5312
|
+
winningSide,
|
|
5313
|
+
autoComplete,
|
|
5314
|
+
matchUpStatus,
|
|
5315
|
+
reversed = false,
|
|
5316
|
+
winnerFirst = true,
|
|
5317
|
+
addOutcomeString
|
|
5318
|
+
} = params;
|
|
5319
|
+
if (!sets) return {
|
|
5320
|
+
error: MISSING_VALUE
|
|
5321
|
+
};
|
|
5322
|
+
const scoresInSideOrder = !winnerFirst || !winningSide || winningSide === 1;
|
|
5323
|
+
const reverseScores = reversed || !scoresInSideOrder;
|
|
5324
|
+
const outcomeString = addOutcomeString ? getOutcomeString({
|
|
5325
|
+
matchUpStatus
|
|
5326
|
+
}) : '';
|
|
5327
|
+
const setScores = (sets === null || sets === void 0 ? void 0 : sets.sort(setSort).map(setString).filter(Boolean) // handle situation where there are multiple empty set objects
|
|
5328
|
+
.join(' ')) || '';
|
|
5329
|
+
if (!outcomeString) return setScores;
|
|
5330
|
+
if (winningSide === 2) return `${outcomeString} ${setScores}`;
|
|
5331
|
+
return `${setScores} ${outcomeString}`;
|
|
5332
|
+
|
|
5333
|
+
function setString(currentSet) {
|
|
5334
|
+
const hasGameScores = set => isNumeric(set === null || set === void 0 ? void 0 : set.side1Score) || isNumeric(set === null || set === void 0 ? void 0 : set.side2Score);
|
|
5335
|
+
|
|
5336
|
+
const hasTiebreakScores = set => isNumeric(set === null || set === void 0 ? void 0 : set.side1TiebreakScore) || isNumeric(set === null || set === void 0 ? void 0 : set.side2TiebreakScore);
|
|
5337
|
+
|
|
5338
|
+
const isTiebreakSet = !hasGameScores(currentSet) && hasTiebreakScores(currentSet);
|
|
5339
|
+
const {
|
|
5340
|
+
side1Score,
|
|
5341
|
+
side2Score,
|
|
5342
|
+
side1TiebreakScore,
|
|
5343
|
+
side2TiebreakScore
|
|
5344
|
+
} = currentSet;
|
|
5345
|
+
const t1 = side1TiebreakScore || (isNumeric(side1TiebreakScore) || autoComplete ? 0 : '');
|
|
5346
|
+
const t2 = side2TiebreakScore || (isNumeric(side2TiebreakScore) || autoComplete ? 0 : '');
|
|
5347
|
+
|
|
5348
|
+
if (isTiebreakSet) {
|
|
5349
|
+
const tiebreakScore = reverseScores ? [t2, t1] : [t1, t2];
|
|
5350
|
+
return `[${tiebreakScore.join('-')}]`;
|
|
5351
|
+
}
|
|
5352
|
+
|
|
5353
|
+
const lowTiebreakScore = Math.min(t1, t2);
|
|
5354
|
+
const tiebreak = lowTiebreakScore ? `(${lowTiebreakScore})` : '';
|
|
5355
|
+
const s1 = side1Score || (isNumeric(side1Score) || autoComplete ? 0 : '');
|
|
5356
|
+
const s2 = side2Score || (isNumeric(side2Score) || autoComplete ? 0 : '');
|
|
5357
|
+
let scoreString = reverseScores ? `${[s2, s1].join('-')}${tiebreak}` : `${[s1, s2].join('-')}${tiebreak}`;
|
|
5358
|
+
if (['-', ' '].includes(scoreString)) scoreString = '';
|
|
5359
|
+
return scoreString;
|
|
5360
|
+
}
|
|
5361
|
+
}
|
|
5362
|
+
|
|
5363
|
+
function getOutcomeString({
|
|
5364
|
+
matchUpStatus
|
|
5365
|
+
}) {
|
|
5366
|
+
const outcomeStrings = {
|
|
5367
|
+
[RETIRED]: 'RET',
|
|
5368
|
+
[WALKOVER$1]: 'WO',
|
|
5369
|
+
[DOUBLE_WALKOVER]: 'WO/WO',
|
|
5370
|
+
[SUSPENDED]: 'SUS',
|
|
5371
|
+
[ABANDONED]: 'ABN',
|
|
5372
|
+
[DEFAULTED]: 'DEF',
|
|
5373
|
+
[DEAD_RUBBER]: 'DR'
|
|
5374
|
+
};
|
|
5375
|
+
return matchUpStatus && outcomeStrings[matchUpStatus] || '';
|
|
5376
|
+
}
|
|
5377
|
+
|
|
5378
|
+
function setSort(a, b) {
|
|
5379
|
+
return a.setNumber - b.setNumber;
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5382
|
+
function getSetWinningSide({
|
|
5383
|
+
matchUpScoringFormat,
|
|
5384
|
+
isDecidingSet,
|
|
5385
|
+
isTiebreakSet,
|
|
5386
|
+
setObject
|
|
5387
|
+
}) {
|
|
5388
|
+
if (!setObject) return undefined;
|
|
5389
|
+
const leadingSide = getLeadingSide({
|
|
5390
|
+
set: setObject
|
|
5391
|
+
});
|
|
5392
|
+
const setIsComplete = checkSetIsComplete({
|
|
5393
|
+
matchUpScoringFormat,
|
|
5394
|
+
isDecidingSet,
|
|
5395
|
+
isTiebreakSet,
|
|
5396
|
+
set: setObject
|
|
5397
|
+
});
|
|
5398
|
+
return setIsComplete && leadingSide || undefined;
|
|
5399
|
+
}
|
|
5400
|
+
function checkSetIsComplete({
|
|
5401
|
+
ignoreTiebreak = false,
|
|
5402
|
+
matchUpScoringFormat,
|
|
5403
|
+
matchUpFormat,
|
|
5404
|
+
isTiebreakSet,
|
|
5405
|
+
isDecidingSet,
|
|
5406
|
+
set
|
|
5407
|
+
}) {
|
|
5408
|
+
var _matchUpScoringFormat;
|
|
5409
|
+
|
|
5410
|
+
if (!set) return {
|
|
5411
|
+
error: MISSING_VALUE
|
|
5412
|
+
};
|
|
5413
|
+
matchUpScoringFormat = matchUpScoringFormat || matchUpFormat;
|
|
5414
|
+
const setFormat = isDecidingSet && matchUpScoringFormat.finalSetFormat || ((_matchUpScoringFormat = matchUpScoringFormat) === null || _matchUpScoringFormat === void 0 ? void 0 : _matchUpScoringFormat.setFormat) || {};
|
|
5415
|
+
const {
|
|
5416
|
+
side1Score,
|
|
5417
|
+
side2Score
|
|
5418
|
+
} = set;
|
|
5419
|
+
const {
|
|
5420
|
+
setTo,
|
|
5421
|
+
tiebreakAt,
|
|
5422
|
+
tiebreakFormat
|
|
5423
|
+
} = setFormat;
|
|
5424
|
+
const NoAD = tiebreakFormat === null || tiebreakFormat === void 0 ? void 0 : tiebreakFormat.NoAd;
|
|
5425
|
+
const leadingSide = getLeadingSide({
|
|
5426
|
+
set
|
|
5427
|
+
});
|
|
5428
|
+
const scoreDiff = Math.abs(side1Score - side2Score);
|
|
5429
|
+
const containsSetTo = side1Score >= setTo || side2Score >= setTo;
|
|
5430
|
+
const requiresTiebreak = isTiebreakSet || side1Score >= setTo && side2Score >= setTo || tiebreakAt && tiebreakAt < setTo && (side1Score === tiebreakAt || side2Score === tiebreakAt);
|
|
5431
|
+
const tiebreakIsValid = ignoreTiebreak || requiresTiebreak && (leadingSide === 1 && set.side1TiebreakScore > set.side2TiebreakScore || leadingSide === 2 && set.side2TiebreakScore > set.side1TiebreakScore);
|
|
5432
|
+
const winMargin = requiresTiebreak && (tiebreakAt && !isTiebreakSet || isTiebreakSet && NoAD) ? 1 : 2;
|
|
5433
|
+
const hasWinMargin = scoreDiff >= winMargin;
|
|
5434
|
+
const validNormalSetScore = containsSetTo && (hasWinMargin || requiresTiebreak);
|
|
5435
|
+
return (validNormalSetScore || isTiebreakSet) && (!requiresTiebreak || tiebreakIsValid);
|
|
5436
|
+
}
|
|
5437
|
+
function getLeadingSide({
|
|
5438
|
+
set
|
|
5439
|
+
}) {
|
|
5440
|
+
if (set.side1Score || set.side2Score) {
|
|
5441
|
+
if (set.side1Score > set.side2Score) return 1;
|
|
5442
|
+
if (set.side2Score > set.side1Score) return 2;
|
|
5443
|
+
} else if (set.side1TiebreakScore || set.side2TiebreakScore) {
|
|
5444
|
+
if (set.side1TiebreakScore > set.side2TiebreakScore) return 1;
|
|
5445
|
+
if (set.side2TiebreakScore > set.side1TiebreakScore) return 2;
|
|
5446
|
+
}
|
|
5447
|
+
|
|
5448
|
+
return undefined;
|
|
5449
|
+
}
|
|
5450
|
+
|
|
5451
|
+
function analyzeSet(params) {
|
|
5452
|
+
const {
|
|
5453
|
+
setObject,
|
|
5454
|
+
matchUpScoringFormat
|
|
5455
|
+
} = params;
|
|
5456
|
+
if (!setObject) return {
|
|
5457
|
+
error: MISSING_SET_OBJECT
|
|
5458
|
+
};
|
|
5459
|
+
const {
|
|
5460
|
+
setNumber
|
|
5461
|
+
} = setObject || {};
|
|
5462
|
+
const {
|
|
5463
|
+
bestOf
|
|
5464
|
+
} = matchUpScoringFormat || {};
|
|
5465
|
+
const isDecidingSet = !!(setNumber && setNumber === bestOf);
|
|
5466
|
+
const setFormat = isDecidingSet && (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.finalSetFormat) || (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.setFormat);
|
|
5467
|
+
const expectTiebreakSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.tiebreakSet);
|
|
5468
|
+
const expectTimedSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.timed);
|
|
5469
|
+
const expectStandardSet = !expectTiebreakSet && !expectTimedSet;
|
|
5470
|
+
const isValidSetNumber = !!(setNumber && bestOf && setNumber <= bestOf);
|
|
5471
|
+
const sideGameScores = [setObject === null || setObject === void 0 ? void 0 : setObject.side1Score, setObject === null || setObject === void 0 ? void 0 : setObject.side2Score];
|
|
5472
|
+
const sidePointScores = [setObject === null || setObject === void 0 ? void 0 : setObject.side1PointScore, setObject === null || setObject === void 0 ? void 0 : setObject.side2PointScore];
|
|
5473
|
+
const sideTiebreakScores = [setObject === null || setObject === void 0 ? void 0 : setObject.side1TiebreakScore, setObject === null || setObject === void 0 ? void 0 : setObject.side2TiebreakScore];
|
|
5474
|
+
const sideGameScoresCount = sideGameScores.filter(sideScore => sideScore !== undefined).length;
|
|
5475
|
+
const sidePointScoresCount = sidePointScores.filter(sideScore => sideScore !== undefined).length;
|
|
5476
|
+
const sideTiebreakScoresCount = sideTiebreakScores.filter(tiebreakScore => tiebreakScore !== undefined).length;
|
|
5477
|
+
const gameScoresCount = sideGameScores === null || sideGameScores === void 0 ? void 0 : sideGameScores.filter(s => !isNaN(s)).length;
|
|
5478
|
+
const tiebreakScoresCount = sideTiebreakScores === null || sideTiebreakScores === void 0 ? void 0 : sideTiebreakScores.filter(s => !isNaN(s)).length;
|
|
5479
|
+
const {
|
|
5480
|
+
tiebreakAt
|
|
5481
|
+
} = setFormat || {};
|
|
5482
|
+
const hasTiebreakCondition = tiebreakAt && sideGameScores.filter(gameScore => gameScore >= tiebreakAt).length === 2;
|
|
5483
|
+
const leadingSide = hasTiebreakCondition && (sideGameScores[0] > sideGameScores[1] ? 1 : sideGameScores[1] > sideGameScores[0] ? 2 : undefined);
|
|
5484
|
+
const isTiebreakSet = !!(tiebreakScoresCount && !gameScoresCount);
|
|
5485
|
+
const isCompletedSet = !!(setObject && setObject !== null && setObject !== void 0 && setObject.winningSide);
|
|
5486
|
+
const {
|
|
5487
|
+
error: standardSetError,
|
|
5488
|
+
result: isValidStandardSetOutcome
|
|
5489
|
+
} = checkValidStandardSetOutcome({
|
|
5490
|
+
setObject,
|
|
5491
|
+
setFormat,
|
|
5492
|
+
sideGameScores,
|
|
5493
|
+
sideTiebreakScores
|
|
5494
|
+
});
|
|
5495
|
+
const {
|
|
5496
|
+
error: tiebreakSetError,
|
|
5497
|
+
result: isValidTiebreakSetOutcome
|
|
5498
|
+
} = checkValidTiebreakSetOutcome({
|
|
5499
|
+
setObject,
|
|
5500
|
+
setFormat,
|
|
5501
|
+
sideTiebreakScores
|
|
5502
|
+
});
|
|
5503
|
+
const isValidSetOutcome = expectStandardSet && !isTiebreakSet && isValidStandardSetOutcome || expectTiebreakSet && isTiebreakSet && isValidTiebreakSetOutcome;
|
|
5504
|
+
const isValidSet = isValidSetNumber && !(expectTiebreakSet && !isTiebreakSet) && !(expectStandardSet && isTiebreakSet) && (!isCompletedSet || isValidSetOutcome);
|
|
5505
|
+
const winningSide = getSetWinningSide({
|
|
5506
|
+
isDecidingSet,
|
|
5507
|
+
isTiebreakSet,
|
|
5508
|
+
matchUpScoringFormat,
|
|
5509
|
+
setObject
|
|
5510
|
+
});
|
|
5511
|
+
const analysis = {
|
|
5512
|
+
expectTiebreakSet,
|
|
5513
|
+
expectTimedSet,
|
|
5514
|
+
hasTiebreakCondition,
|
|
5515
|
+
isCompletedSet,
|
|
5516
|
+
isDecidingSet,
|
|
5517
|
+
isTiebreakSet,
|
|
5518
|
+
isValidSet,
|
|
5519
|
+
isValidSetNumber,
|
|
5520
|
+
isValidSetOutcome,
|
|
5521
|
+
leadingSide,
|
|
5522
|
+
setFormat,
|
|
5523
|
+
sideGameScores,
|
|
5524
|
+
sideGameScoresCount,
|
|
5525
|
+
sidePointScores,
|
|
5526
|
+
sidePointScoresCount,
|
|
5527
|
+
sideTiebreakScores,
|
|
5528
|
+
sideTiebreakScoresCount,
|
|
5529
|
+
winningSide
|
|
5530
|
+
};
|
|
5531
|
+
|
|
5532
|
+
if ((setObject === null || setObject === void 0 ? void 0 : setObject.winningSide) !== undefined) {
|
|
5533
|
+
if (isTiebreakSet) {
|
|
5534
|
+
analysis.isValidTiebreakSetOutcome = isValidTiebreakSetOutcome;
|
|
5535
|
+
|
|
5536
|
+
if (!isValidTiebreakSetOutcome) {
|
|
5537
|
+
analysis.tiebreakSetError = tiebreakSetError;
|
|
5538
|
+
}
|
|
5539
|
+
} else {
|
|
5540
|
+
analysis.isValidStandardSetOutcome = isValidStandardSetOutcome;
|
|
5541
|
+
|
|
5542
|
+
if (!isValidStandardSetOutcome) {
|
|
5543
|
+
analysis.standardSetError = standardSetError;
|
|
5544
|
+
}
|
|
5545
|
+
}
|
|
5546
|
+
}
|
|
5547
|
+
|
|
5548
|
+
return analysis;
|
|
5549
|
+
}
|
|
5550
|
+
|
|
5551
|
+
function checkValidStandardSetOutcome({
|
|
5552
|
+
setObject,
|
|
5553
|
+
setFormat,
|
|
5554
|
+
sideGameScores,
|
|
5555
|
+
sideTiebreakScores
|
|
5556
|
+
}) {
|
|
5557
|
+
if (!setObject) {
|
|
5558
|
+
return {
|
|
5559
|
+
result: false,
|
|
5560
|
+
error: MISSING_SET_OBJECT
|
|
5561
|
+
};
|
|
5562
|
+
}
|
|
5563
|
+
|
|
5564
|
+
const expectTiebreakSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.tiebreakSet);
|
|
5565
|
+
const expectTimedSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.timed);
|
|
5566
|
+
|
|
5567
|
+
if (!setFormat || expectTiebreakSet || expectTimedSet) {
|
|
5568
|
+
return {
|
|
5569
|
+
result: false,
|
|
5570
|
+
error: 'not standard set'
|
|
5571
|
+
};
|
|
5572
|
+
}
|
|
5573
|
+
|
|
5574
|
+
const validGameScores = (sideGameScores === null || sideGameScores === void 0 ? void 0 : sideGameScores.filter(s => !isNaN(s)).length) === 2;
|
|
5575
|
+
if (!validGameScores) return {
|
|
5576
|
+
result: false,
|
|
5577
|
+
error: INVALID_GAME_SCORES
|
|
5578
|
+
};
|
|
5579
|
+
const {
|
|
5580
|
+
setTo,
|
|
5581
|
+
tiebreakAt,
|
|
5582
|
+
tiebreakFormat,
|
|
5583
|
+
NoAD
|
|
5584
|
+
} = setFormat || {};
|
|
5585
|
+
const meetsSetTo = !!(setTo && sideGameScores !== null && sideGameScores !== void 0 && sideGameScores.find(gameScore => gameScore >= setTo));
|
|
5586
|
+
if (!meetsSetTo) return {
|
|
5587
|
+
result: false,
|
|
5588
|
+
error: INVALID_GAME_SCORES
|
|
5589
|
+
};
|
|
5590
|
+
const isValidWinningSide = [1, 2].includes(setObject === null || setObject === void 0 ? void 0 : setObject.winningSide);
|
|
5591
|
+
if (!setObject || !isValidWinningSide) return {
|
|
5592
|
+
result: false,
|
|
5593
|
+
error: INVALID_WINNING_SIDE
|
|
5594
|
+
};
|
|
5595
|
+
const winningSideIndex = (setObject === null || setObject === void 0 ? void 0 : setObject.winningSide) - 1;
|
|
5596
|
+
const losingSideIndex = 1 - winningSideIndex;
|
|
5597
|
+
const winningSideGameScore = sideGameScores[winningSideIndex];
|
|
5598
|
+
const losingSideGameScore = sideGameScores[losingSideIndex];
|
|
5599
|
+
const gamesDifference = winningSideGameScore - losingSideGameScore;
|
|
5600
|
+
const winningSideIsHighGameValue = winningSideGameScore > losingSideGameScore;
|
|
5601
|
+
|
|
5602
|
+
if (!winningSideIsHighGameValue) {
|
|
5603
|
+
return {
|
|
5604
|
+
result: false,
|
|
5605
|
+
error: 'winningSide game scoreString is not high'
|
|
5606
|
+
};
|
|
5607
|
+
}
|
|
5608
|
+
|
|
5609
|
+
const setTiebreakDefined = tiebreakAt && tiebreakFormat;
|
|
5610
|
+
const validTiebreakScores = (sideTiebreakScores === null || sideTiebreakScores === void 0 ? void 0 : sideTiebreakScores.filter(s => !isNaN(s)).length) === 2;
|
|
5611
|
+
const winningSideTiebreakScore = sideTiebreakScores && sideTiebreakScores[winningSideIndex];
|
|
5612
|
+
const losingSideTiebreakScore = sideTiebreakScores && sideTiebreakScores[losingSideIndex];
|
|
5613
|
+
const hasTiebreakCondition = tiebreakAt && sideGameScores.filter(gameScore => gameScore >= tiebreakAt).length === 2;
|
|
5614
|
+
|
|
5615
|
+
if (setTiebreakDefined) {
|
|
5616
|
+
const {
|
|
5617
|
+
NoAD: tiebreakNoAD,
|
|
5618
|
+
tiebreakTo
|
|
5619
|
+
} = tiebreakFormat;
|
|
5745
5620
|
|
|
5746
|
-
if (
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
}
|
|
5621
|
+
if (hasTiebreakCondition) {
|
|
5622
|
+
if (gamesDifference > 1) {
|
|
5623
|
+
return {
|
|
5624
|
+
result: false,
|
|
5625
|
+
error: 'invalid winning game scoreString (5)'
|
|
5626
|
+
};
|
|
5627
|
+
}
|
|
5753
5628
|
|
|
5754
|
-
if (
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
set.side2TiebreakScore = highTiebreakScore;
|
|
5629
|
+
if (!validTiebreakScores) {
|
|
5630
|
+
return {
|
|
5631
|
+
result: false,
|
|
5632
|
+
error: 'invalid tiebreak scores (1)'
|
|
5633
|
+
};
|
|
5760
5634
|
}
|
|
5761
|
-
}
|
|
5762
5635
|
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
set.winningSide = winningSide || undefined;
|
|
5770
|
-
updated = true;
|
|
5771
|
-
} else if (analysis.isTiebreakSetValue) {
|
|
5772
|
-
({
|
|
5773
|
-
message,
|
|
5774
|
-
scoreString,
|
|
5775
|
-
sets,
|
|
5776
|
-
updated
|
|
5777
|
-
} = processTiebreakSet({
|
|
5778
|
-
analysis,
|
|
5779
|
-
auto,
|
|
5780
|
-
lowSide,
|
|
5781
|
-
scoreString,
|
|
5782
|
-
sets,
|
|
5783
|
-
value
|
|
5784
|
-
}));
|
|
5785
|
-
} else if (analysis.isSetTiebreakEntry) {
|
|
5786
|
-
const [open] = SET_TIEBREAK_BRACKETS.split('');
|
|
5787
|
-
const lastOpenBracketIndex = Math.max(...indices(open, scoreString.split('')));
|
|
5788
|
-
const tiebreakValue = scoreString.slice(lastOpenBracketIndex + 1);
|
|
5789
|
-
const hasZeroStart = tiebreakValue && parseInt(tiebreakValue) === ZERO;
|
|
5790
|
-
const newTiebreakValue = parseInt(tiebreakValue ? tiebreakValue + value : value);
|
|
5791
|
-
const {
|
|
5792
|
-
tiebreakFormat
|
|
5793
|
-
} = analysis.setFormat;
|
|
5794
|
-
const {
|
|
5795
|
-
tiebreakTo,
|
|
5796
|
-
NoAD
|
|
5797
|
-
} = tiebreakFormat || {};
|
|
5636
|
+
if (isNaN(tiebreakTo)) {
|
|
5637
|
+
return {
|
|
5638
|
+
result: false,
|
|
5639
|
+
error: 'tiebreakTo error'
|
|
5640
|
+
}; // TODO: test this
|
|
5641
|
+
}
|
|
5798
5642
|
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5643
|
+
const meetsTiebreakTo = !!(tiebreakTo && sideTiebreakScores !== null && sideTiebreakScores !== void 0 && sideTiebreakScores.find(tiebreakScore => tiebreakScore >= tiebreakTo));
|
|
5644
|
+
|
|
5645
|
+
if (!meetsTiebreakTo) {
|
|
5646
|
+
return {
|
|
5647
|
+
result: false,
|
|
5648
|
+
error: 'invalid tiebreak scores (2)'
|
|
5649
|
+
};
|
|
5650
|
+
}
|
|
5651
|
+
|
|
5652
|
+
const maxGameScore = tiebreakAt < setTo ? setTo : setTo + 1;
|
|
5653
|
+
|
|
5654
|
+
if (winningSideGameScore > maxGameScore) {
|
|
5655
|
+
return {
|
|
5656
|
+
result: false,
|
|
5657
|
+
error: 'invalid winning game scoreString (1)'
|
|
5658
|
+
};
|
|
5659
|
+
}
|
|
5660
|
+
|
|
5661
|
+
if (!winningSideTiebreakScore || !losingSideTiebreakScore || winningSideTiebreakScore < losingSideTiebreakScore) {
|
|
5662
|
+
return {
|
|
5663
|
+
result: false,
|
|
5664
|
+
error: 'winningSide tiebreak value is not high'
|
|
5665
|
+
};
|
|
5666
|
+
}
|
|
5667
|
+
|
|
5668
|
+
const minimumTiebreakWinMargin = tiebreakNoAD ? 1 : 2;
|
|
5669
|
+
const tiebreakDifference = winningSideTiebreakScore - losingSideTiebreakScore;
|
|
5670
|
+
const losingSideGameScoreAtTiebreakToThreshold = losingSideTiebreakScore >= tiebreakTo - 1;
|
|
5671
|
+
const invalidTiebreakScore = tiebreakDifference && losingSideGameScoreAtTiebreakToThreshold && tiebreakDifference < minimumTiebreakWinMargin;
|
|
5672
|
+
|
|
5673
|
+
if (invalidTiebreakScore) {
|
|
5674
|
+
return {
|
|
5675
|
+
result: false,
|
|
5676
|
+
error: 'invalid tiebreak scores (3)'
|
|
5677
|
+
};
|
|
5805
5678
|
}
|
|
5806
|
-
} else {
|
|
5807
|
-
message = hasZeroStart ? 'tiebreak begins with zero' : 'tiebreak digit limit';
|
|
5808
5679
|
}
|
|
5809
|
-
} else if (analysis.isCloser) {
|
|
5810
|
-
message = `invalid key: ${value}`;
|
|
5811
|
-
} else if (analysis.isGameScoreEntry) {
|
|
5812
|
-
message = 'game scoreString entry';
|
|
5813
|
-
} else {
|
|
5814
|
-
if (analysis.lastSetIsComplete || !sets.length) {
|
|
5815
|
-
var _sets, _sets2;
|
|
5816
5680
|
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
scoreString,
|
|
5825
|
-
value: parseInt(value)
|
|
5826
|
-
});
|
|
5827
|
-
if (set) set.setNumber = ((_sets = sets) === null || _sets === void 0 ? void 0 : _sets.length) + 1 || 1;
|
|
5828
|
-
sets = ((_sets2 = sets) === null || _sets2 === void 0 ? void 0 : _sets2.concat(set).filter(Boolean)) || [set];
|
|
5829
|
-
scoreString = newScore || undefined;
|
|
5830
|
-
} else {
|
|
5831
|
-
console.log('error: unknown outcome');
|
|
5681
|
+
const hasTiebreakGameScore = winningSideGameScore > setTo;
|
|
5682
|
+
|
|
5683
|
+
if (hasTiebreakGameScore && (!setTiebreakDefined || !hasTiebreakCondition)) {
|
|
5684
|
+
return {
|
|
5685
|
+
result: false,
|
|
5686
|
+
error: 'invalid winning game scoreString (2)'
|
|
5687
|
+
};
|
|
5832
5688
|
}
|
|
5833
5689
|
}
|
|
5834
5690
|
|
|
5835
|
-
|
|
5836
|
-
|
|
5691
|
+
const minimumGamesWinMargin = NoAD ? 1 : 2;
|
|
5692
|
+
const losingSideGameScoreAtSetToThreshold = losingSideGameScore >= setTo - 1;
|
|
5693
|
+
const invalidWinningScore = gamesDifference && losingSideGameScoreAtSetToThreshold && !hasTiebreakCondition && gamesDifference < minimumGamesWinMargin;
|
|
5837
5694
|
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
matchUpStatus,
|
|
5845
|
-
matchUpFormat
|
|
5846
|
-
});
|
|
5847
|
-
winningSide = matchUpWinningSide;
|
|
5695
|
+
if (invalidWinningScore) {
|
|
5696
|
+
return {
|
|
5697
|
+
result: false,
|
|
5698
|
+
error: 'invalid winning game scoreString (3)'
|
|
5699
|
+
};
|
|
5700
|
+
}
|
|
5848
5701
|
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
} else if (scoreString && !winningSide && ![STATUS_SUSPENDED, STATUS_ABANDONED, STATUS_INTERRUPTED].includes(matchUpStatus)) {
|
|
5861
|
-
matchUpStatus = undefined;
|
|
5862
|
-
}
|
|
5702
|
+
if (gamesDifference > minimumGamesWinMargin && winningSideGameScore > setTo) {
|
|
5703
|
+
return {
|
|
5704
|
+
result: false,
|
|
5705
|
+
error: 'invalid winning game scoreString (4)'
|
|
5706
|
+
};
|
|
5707
|
+
}
|
|
5708
|
+
|
|
5709
|
+
return {
|
|
5710
|
+
result: true
|
|
5711
|
+
};
|
|
5712
|
+
}
|
|
5863
5713
|
|
|
5714
|
+
function checkValidTiebreakSetOutcome({
|
|
5715
|
+
setObject,
|
|
5716
|
+
setFormat,
|
|
5717
|
+
sideTiebreakScores
|
|
5718
|
+
}) {
|
|
5719
|
+
if (!setObject) {
|
|
5864
5720
|
return {
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5721
|
+
result: false,
|
|
5722
|
+
error: MISSING_SET_OBJECT
|
|
5723
|
+
};
|
|
5724
|
+
}
|
|
5725
|
+
|
|
5726
|
+
const expectTiebreakSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.tiebreakSet);
|
|
5727
|
+
const expectTimedSet = !!(setFormat !== null && setFormat !== void 0 && setFormat.timed);
|
|
5728
|
+
|
|
5729
|
+
if (!setFormat || !expectTiebreakSet || expectTimedSet) {
|
|
5730
|
+
return {
|
|
5731
|
+
result: false,
|
|
5732
|
+
error: 'not tiebreak set'
|
|
5733
|
+
};
|
|
5734
|
+
}
|
|
5735
|
+
|
|
5736
|
+
const isValidWinningSide = [1, 2].includes(setObject === null || setObject === void 0 ? void 0 : setObject.winningSide);
|
|
5737
|
+
if (!setObject || !isValidWinningSide) return {
|
|
5738
|
+
result: false,
|
|
5739
|
+
error: INVALID_WINNING_SIDE
|
|
5740
|
+
};
|
|
5741
|
+
const {
|
|
5742
|
+
tiebreakSet
|
|
5743
|
+
} = setFormat || {};
|
|
5744
|
+
const {
|
|
5745
|
+
NoAD,
|
|
5746
|
+
tiebreakTo
|
|
5747
|
+
} = tiebreakSet || {};
|
|
5748
|
+
const validTiebreakScores = (sideTiebreakScores === null || sideTiebreakScores === void 0 ? void 0 : sideTiebreakScores.filter(s => !isNaN(s)).length) === 2;
|
|
5749
|
+
|
|
5750
|
+
if (!validTiebreakScores) {
|
|
5751
|
+
return {
|
|
5752
|
+
result: false,
|
|
5753
|
+
error: 'invalid tiebreak scores (1)'
|
|
5754
|
+
};
|
|
5755
|
+
}
|
|
5756
|
+
|
|
5757
|
+
if (isNaN(tiebreakTo)) {
|
|
5758
|
+
return {
|
|
5759
|
+
result: false,
|
|
5760
|
+
error: 'tiebreakTo error'
|
|
5761
|
+
}; // TODO: test this
|
|
5762
|
+
}
|
|
5763
|
+
|
|
5764
|
+
const meetsTiebreakTo = !!(sideTiebreakScores !== null && sideTiebreakScores !== void 0 && sideTiebreakScores.find(tiebreakScore => tiebreakScore >= tiebreakTo));
|
|
5765
|
+
|
|
5766
|
+
if (!meetsTiebreakTo) {
|
|
5767
|
+
return {
|
|
5768
|
+
result: false,
|
|
5769
|
+
error: 'invalid tiebreak scores (2)'
|
|
5770
|
+
};
|
|
5771
|
+
}
|
|
5772
|
+
|
|
5773
|
+
const winningSideIndex = (setObject === null || setObject === void 0 ? void 0 : setObject.winningSide) - 1;
|
|
5774
|
+
const losingSideIndex = 1 - winningSideIndex;
|
|
5775
|
+
const winningSideTiebreakScore = sideTiebreakScores[winningSideIndex];
|
|
5776
|
+
const losingSideTiebreakScore = sideTiebreakScores[losingSideIndex];
|
|
5777
|
+
|
|
5778
|
+
if (!winningSideTiebreakScore || !losingSideTiebreakScore || winningSideTiebreakScore < losingSideTiebreakScore) {
|
|
5779
|
+
return {
|
|
5780
|
+
result: false,
|
|
5781
|
+
error: 'winningSide tiebreak value is not high'
|
|
5782
|
+
};
|
|
5783
|
+
}
|
|
5784
|
+
|
|
5785
|
+
const minimumTiebreakWinMargin = NoAD ? 1 : 2;
|
|
5786
|
+
const tiebreakDifference = winningSideTiebreakScore - losingSideTiebreakScore;
|
|
5787
|
+
const losingSideGameScoreAtTiebreakToThreshold = losingSideTiebreakScore >= tiebreakTo - 1;
|
|
5788
|
+
const invalidTiebreakScore = tiebreakDifference && losingSideGameScoreAtTiebreakToThreshold && tiebreakDifference < minimumTiebreakWinMargin;
|
|
5789
|
+
|
|
5790
|
+
if (invalidTiebreakScore) {
|
|
5791
|
+
return {
|
|
5792
|
+
result: false,
|
|
5793
|
+
error: 'invalid tiebreak scores (3)'
|
|
5871
5794
|
};
|
|
5872
5795
|
}
|
|
5873
5796
|
|
|
5874
5797
|
return {
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5798
|
+
result: true
|
|
5799
|
+
};
|
|
5800
|
+
}
|
|
5801
|
+
|
|
5802
|
+
function analyzeMatchUp(params) {
|
|
5803
|
+
var _matchUp$score;
|
|
5804
|
+
|
|
5805
|
+
const {
|
|
5806
|
+
matchUp,
|
|
5807
|
+
sideNumber,
|
|
5808
|
+
setNumber,
|
|
5809
|
+
isTiebreakValue,
|
|
5810
|
+
isPointValue
|
|
5811
|
+
} = params || {};
|
|
5812
|
+
let {
|
|
5813
|
+
matchUpFormat
|
|
5814
|
+
} = params || {};
|
|
5815
|
+
if (!matchUp) return {
|
|
5816
|
+
error: MISSING_MATCHUP
|
|
5817
|
+
};
|
|
5818
|
+
matchUpFormat = matchUpFormat || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpFormat);
|
|
5819
|
+
const matchUpScoringFormat = dist.exports.matchUpFormatCode === null || dist.exports.matchUpFormatCode === void 0 ? void 0 : dist.exports.matchUpFormatCode.parse(matchUpFormat);
|
|
5820
|
+
const isCompletedMatchUp = !!(matchUp !== null && matchUp !== void 0 && matchUp.winningSide);
|
|
5821
|
+
const sets = (_matchUp$score = matchUp.score) === null || _matchUp$score === void 0 ? void 0 : _matchUp$score.sets;
|
|
5822
|
+
const setsCount = sets === null || sets === void 0 ? void 0 : sets.length;
|
|
5823
|
+
const setIndex = setNumber && setNumber - 1;
|
|
5824
|
+
const isExistingSet = !!(sets !== null && sets !== void 0 && sets.find((set, index) => set.setNumber === setNumber && index === setIndex));
|
|
5825
|
+
const completedSets = (sets === null || sets === void 0 ? void 0 : sets.filter(set => set === null || set === void 0 ? void 0 : set.winningSide)) || [];
|
|
5826
|
+
const completedSetsCount = (completedSets === null || completedSets === void 0 ? void 0 : completedSets.length) || 0;
|
|
5827
|
+
const setsFollowingCurrent = setNumber && (sets === null || sets === void 0 ? void 0 : sets.slice(setNumber)) || [];
|
|
5828
|
+
const isLastSetWithValues = !!(setsCount && setNumber && // EVERY: is this a candidate for .every?
|
|
5829
|
+
setsFollowingCurrent !== null && setsFollowingCurrent !== void 0 && setsFollowingCurrent.reduce((noValues, set) => {
|
|
5830
|
+
return (!set || !set.side1Score && !set.side2Score && !set.side1TiebreakScore && !set.side2TiebreakScore && !set.side1PointScore && !set.side2PointScore) && noValues;
|
|
5831
|
+
}, true));
|
|
5832
|
+
const setObject = setNumber <= setsCount && sets.find(set => set.setNumber === setNumber);
|
|
5833
|
+
const specifiedSetAnalysis = setObject && analyzeSet({
|
|
5834
|
+
setObject,
|
|
5835
|
+
matchUpScoringFormat
|
|
5836
|
+
});
|
|
5837
|
+
const {
|
|
5838
|
+
isCompletedSet,
|
|
5839
|
+
sideGameScores,
|
|
5840
|
+
// sidePointScores,
|
|
5841
|
+
sideTiebreakScores
|
|
5842
|
+
} = specifiedSetAnalysis || {};
|
|
5843
|
+
const isActiveSet = !!(setObject && !isCompletedSet && isLastSetWithValues || setNumber && setNumber === setsCount + 1 && !isCompletedMatchUp);
|
|
5844
|
+
const isValidSideNumber = [1, 2].includes(sideNumber);
|
|
5845
|
+
const sideIndex = isValidSideNumber ? sideNumber - 1 : 0;
|
|
5846
|
+
const existingValue = setObject && isValidSideNumber && (!isTiebreakValue && !isPointValue && sideGameScores[sideIndex] !== undefined && sideGameScores[sideIndex] || isTiebreakValue && sideTiebreakScores[sideIndex] !== undefined && sideTiebreakScores[sideIndex]);
|
|
5847
|
+
const hasExistingValue = !!existingValue;
|
|
5848
|
+
const completedSetsHaveValidOutcomes = completedSets && completedSets.map(setObject => analyzeSet({
|
|
5849
|
+
setObject,
|
|
5850
|
+
matchUpScoringFormat
|
|
5851
|
+
}).isValidSetOutcome).reduce((valid, validOutcome) => valid && validOutcome, true);
|
|
5852
|
+
const setsWinCounts = completedSets.reduce((counts, set) => {
|
|
5853
|
+
const {
|
|
5854
|
+
winningSide
|
|
5855
|
+
} = set;
|
|
5856
|
+
const winningSideIndex = winningSide - 1;
|
|
5857
|
+
counts[winningSideIndex]++;
|
|
5858
|
+
return counts;
|
|
5859
|
+
}, [0, 0]);
|
|
5860
|
+
const matchUpWinningSide = matchUp === null || matchUp === void 0 ? void 0 : matchUp.winningSide;
|
|
5861
|
+
const matchUpWinningSideIndex = matchUpWinningSide && matchUpWinningSide - 1;
|
|
5862
|
+
const matchUpLosingSideIndex = 1 - matchUpWinningSideIndex;
|
|
5863
|
+
const winningSideSetsCount = setsWinCounts[matchUpWinningSideIndex];
|
|
5864
|
+
const losingSideSetsCount = setsWinCounts[matchUpLosingSideIndex];
|
|
5865
|
+
const maxSetsCount = Math.max(...setsWinCounts);
|
|
5866
|
+
const maxSetsInstances = instanceCount(setsWinCounts)[maxSetsCount];
|
|
5867
|
+
const {
|
|
5868
|
+
bestOf
|
|
5869
|
+
} = matchUpScoringFormat || {};
|
|
5870
|
+
const setsToWin = bestOf && Math.ceil(bestOf / 2) || 1;
|
|
5871
|
+
const calculatedWinningSide = maxSetsCount === setsToWin && maxSetsInstances === 1 && setsWinCounts.indexOf(maxSetsCount) + 1 || undefined;
|
|
5872
|
+
const validMatchUpWinningSide = winningSideSetsCount > losingSideSetsCount && matchUpWinningSide === calculatedWinningSide;
|
|
5873
|
+
const validMatchUpOutcome = calculatedWinningSide && completedSetsHaveValidOutcomes && validMatchUpWinningSide;
|
|
5874
|
+
return {
|
|
5875
|
+
isActiveSet,
|
|
5876
|
+
isExistingSet,
|
|
5877
|
+
existingValue,
|
|
5878
|
+
hasExistingValue,
|
|
5879
|
+
isValidSideNumber,
|
|
5880
|
+
completedSetsCount,
|
|
5881
|
+
isCompletedMatchUp,
|
|
5882
|
+
isLastSetWithValues,
|
|
5883
|
+
validMatchUpOutcome,
|
|
5884
|
+
matchUpScoringFormat,
|
|
5885
|
+
calculatedWinningSide,
|
|
5886
|
+
validMatchUpWinningSide,
|
|
5887
|
+
completedSetsHaveValidOutcomes,
|
|
5888
|
+
...specifiedSetAnalysis
|
|
5881
5889
|
};
|
|
5882
5890
|
}
|
|
5883
5891
|
|
|
@@ -5889,6 +5897,7 @@ const scoreGovernor = {
|
|
|
5889
5897
|
tallyParticipantResults,
|
|
5890
5898
|
getTiebreakComplement,
|
|
5891
5899
|
generateScoreString,
|
|
5900
|
+
checkSetIsComplete: checkSetIsComplete$1,
|
|
5892
5901
|
validateTieFormat,
|
|
5893
5902
|
getSetComplement,
|
|
5894
5903
|
analyzeMatchUp,
|
|
@@ -13430,7 +13439,8 @@ function findMatchUp({
|
|
|
13430
13439
|
contextProfile,
|
|
13431
13440
|
nextMatchUps,
|
|
13432
13441
|
matchUpId,
|
|
13433
|
-
inContext
|
|
13442
|
+
inContext,
|
|
13443
|
+
event
|
|
13434
13444
|
});
|
|
13435
13445
|
return {
|
|
13436
13446
|
matchUp,
|
|
@@ -13586,6 +13596,7 @@ function getProjectedDualWinningSide({
|
|
|
13586
13596
|
winningSide,
|
|
13587
13597
|
dualMatchUp,
|
|
13588
13598
|
tieFormat,
|
|
13599
|
+
structure,
|
|
13589
13600
|
matchUp,
|
|
13590
13601
|
event
|
|
13591
13602
|
}) {
|
|
@@ -13610,7 +13621,7 @@ function getProjectedDualWinningSide({
|
|
|
13610
13621
|
}
|
|
13611
13622
|
}
|
|
13612
13623
|
|
|
13613
|
-
tieFormat = tieFormat || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
13624
|
+
tieFormat = tieFormat || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) || (structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
13614
13625
|
const {
|
|
13615
13626
|
winningSide: projectedWinningSide
|
|
13616
13627
|
} = generateTieMatchUpScore({
|
|
@@ -15660,18 +15671,6 @@ function updateAssignmentParticipantResults({
|
|
|
15660
15671
|
};
|
|
15661
15672
|
}
|
|
15662
15673
|
|
|
15663
|
-
const toBePlayed = {
|
|
15664
|
-
matchUpStatus: TO_BE_PLAYED,
|
|
15665
|
-
matchUpStatusCodes: [],
|
|
15666
|
-
score: {
|
|
15667
|
-
scoreStringSide1: '',
|
|
15668
|
-
scoreStringSide2: '',
|
|
15669
|
-
sets: undefined
|
|
15670
|
-
},
|
|
15671
|
-
matchUpFormat: undefined,
|
|
15672
|
-
winningSide: undefined
|
|
15673
|
-
};
|
|
15674
|
-
|
|
15675
15674
|
/**
|
|
15676
15675
|
*
|
|
15677
15676
|
* @param {string} eventId - indicates that invocation is via tournamentEngine
|
|
@@ -15717,6 +15716,18 @@ function getFlightProfile({
|
|
|
15717
15716
|
};
|
|
15718
15717
|
}
|
|
15719
15718
|
|
|
15719
|
+
const toBePlayed = {
|
|
15720
|
+
matchUpStatus: TO_BE_PLAYED,
|
|
15721
|
+
matchUpStatusCodes: [],
|
|
15722
|
+
score: {
|
|
15723
|
+
scoreStringSide1: '',
|
|
15724
|
+
scoreStringSide2: '',
|
|
15725
|
+
sets: undefined
|
|
15726
|
+
},
|
|
15727
|
+
matchUpFormat: undefined,
|
|
15728
|
+
winningSide: undefined
|
|
15729
|
+
};
|
|
15730
|
+
|
|
15720
15731
|
/**
|
|
15721
15732
|
*
|
|
15722
15733
|
* Single place where matchUp.score can be modified.
|
|
@@ -15787,9 +15798,10 @@ function modifyMatchUpScore({
|
|
|
15787
15798
|
matchUpId,
|
|
15788
15799
|
event
|
|
15789
15800
|
}));
|
|
15790
|
-
}
|
|
15801
|
+
} // if the matchUp has a collectionId it is a tieMatchUp contained in a dual matchUp
|
|
15802
|
+
|
|
15791
15803
|
|
|
15792
|
-
if (((_structure = structure) === null || _structure === void 0 ? void 0 : _structure.structureType) === CONTAINER) {
|
|
15804
|
+
if (((_structure = structure) === null || _structure === void 0 ? void 0 : _structure.structureType) === CONTAINER && !matchUp.collectionId) {
|
|
15793
15805
|
var _structure2;
|
|
15794
15806
|
|
|
15795
15807
|
matchUpFormat = matchUpFormat || matchUp.matchUpFormat || ((_structure2 = structure) === null || _structure2 === void 0 ? void 0 : _structure2.matchUpFormat) || drawDefinition.matchUpFormat || (event === null || event === void 0 ? void 0 : event.matchUpFormat);
|
|
@@ -15847,8 +15859,9 @@ function modifyMatchUpScore({
|
|
|
15847
15859
|
|
|
15848
15860
|
function updateTieMatchUpScore({
|
|
15849
15861
|
drawDefinition,
|
|
15850
|
-
|
|
15851
|
-
|
|
15862
|
+
matchUpId,
|
|
15863
|
+
structure,
|
|
15864
|
+
event
|
|
15852
15865
|
}) {
|
|
15853
15866
|
if (!drawDefinition) return {
|
|
15854
15867
|
error: MISSING_DRAW_DEFINITION
|
|
@@ -15856,7 +15869,6 @@ function updateTieMatchUpScore({
|
|
|
15856
15869
|
if (!matchUpId) return {
|
|
15857
15870
|
error: MISSING_MATCHUP
|
|
15858
15871
|
};
|
|
15859
|
-
if (!event) console.log('noe');
|
|
15860
15872
|
const {
|
|
15861
15873
|
matchUp,
|
|
15862
15874
|
error
|
|
@@ -15871,7 +15883,7 @@ function updateTieMatchUpScore({
|
|
|
15871
15883
|
if (!matchUp) return {
|
|
15872
15884
|
error: MATCHUP_NOT_FOUND
|
|
15873
15885
|
};
|
|
15874
|
-
const tieFormat = matchUp.tieFormat || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
15886
|
+
const tieFormat = matchUp.tieFormat || (structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
15875
15887
|
const {
|
|
15876
15888
|
winningSide,
|
|
15877
15889
|
set,
|
|
@@ -15970,6 +15982,7 @@ function removeDirectedParticipants(params) {
|
|
|
15970
15982
|
} = updateTieMatchUpScore({
|
|
15971
15983
|
matchUpId: matchUpTieId,
|
|
15972
15984
|
drawDefinition,
|
|
15985
|
+
structure,
|
|
15973
15986
|
event
|
|
15974
15987
|
});
|
|
15975
15988
|
if (!dualWinningSideChange && !removeWinningSide) return { ...SUCCESS
|
|
@@ -18720,6 +18733,7 @@ function directParticipants(params) {
|
|
|
18720
18733
|
updateTieMatchUpScore({
|
|
18721
18734
|
matchUpId: matchUpTieId,
|
|
18722
18735
|
drawDefinition,
|
|
18736
|
+
structure,
|
|
18723
18737
|
event
|
|
18724
18738
|
});
|
|
18725
18739
|
const matchUpTie = inContextDrawMatchUps.find(({
|
|
@@ -19062,13 +19076,16 @@ function scoreModification(params) {
|
|
|
19062
19076
|
if (isCollectionMatchUp) {
|
|
19063
19077
|
const {
|
|
19064
19078
|
matchUpTieId,
|
|
19065
|
-
drawDefinition
|
|
19079
|
+
drawDefinition,
|
|
19080
|
+
structure,
|
|
19081
|
+
event
|
|
19066
19082
|
} = params;
|
|
19067
19083
|
const {
|
|
19068
19084
|
removeWinningSide
|
|
19069
19085
|
} = updateTieMatchUpScore({
|
|
19070
19086
|
matchUpId: matchUpTieId,
|
|
19071
19087
|
drawDefinition,
|
|
19088
|
+
structure,
|
|
19072
19089
|
event
|
|
19073
19090
|
});
|
|
19074
19091
|
console.log('ndd', {
|
|
@@ -19326,6 +19343,22 @@ function setMatchUpStatus$2(params) {
|
|
|
19326
19343
|
inContextDrawMatchUps,
|
|
19327
19344
|
drawDefinition
|
|
19328
19345
|
});
|
|
19346
|
+
const structureId = inContextMatchUp.structureId;
|
|
19347
|
+
const {
|
|
19348
|
+
structure
|
|
19349
|
+
} = findStructure({
|
|
19350
|
+
drawDefinition,
|
|
19351
|
+
structureId
|
|
19352
|
+
});
|
|
19353
|
+
Object.assign(params, {
|
|
19354
|
+
inContextDrawMatchUps,
|
|
19355
|
+
inContextMatchUp,
|
|
19356
|
+
matchUpTieId,
|
|
19357
|
+
matchUpsMap,
|
|
19358
|
+
targetData,
|
|
19359
|
+
structure,
|
|
19360
|
+
matchUp
|
|
19361
|
+
});
|
|
19329
19362
|
let dualWinningSideChange;
|
|
19330
19363
|
|
|
19331
19364
|
if (matchUpTieId) {
|
|
@@ -19345,6 +19378,7 @@ function setMatchUpStatus$2(params) {
|
|
|
19345
19378
|
winningSide,
|
|
19346
19379
|
dualMatchUp,
|
|
19347
19380
|
tieFormat,
|
|
19381
|
+
structure,
|
|
19348
19382
|
matchUp,
|
|
19349
19383
|
event
|
|
19350
19384
|
});
|
|
@@ -19358,24 +19392,8 @@ function setMatchUpStatus$2(params) {
|
|
|
19358
19392
|
dualMatchUp,
|
|
19359
19393
|
tieFormat
|
|
19360
19394
|
});
|
|
19361
|
-
}
|
|
19395
|
+
} // with propagating winningSide changes, activeDownstream only applies to eventType: TEAM
|
|
19362
19396
|
|
|
19363
|
-
const structureId = inContextMatchUp.structureId;
|
|
19364
|
-
const {
|
|
19365
|
-
structure
|
|
19366
|
-
} = findStructure({
|
|
19367
|
-
drawDefinition,
|
|
19368
|
-
structureId
|
|
19369
|
-
});
|
|
19370
|
-
Object.assign(params, {
|
|
19371
|
-
inContextDrawMatchUps,
|
|
19372
|
-
inContextMatchUp,
|
|
19373
|
-
matchUpTieId,
|
|
19374
|
-
matchUpsMap,
|
|
19375
|
-
targetData,
|
|
19376
|
-
structure,
|
|
19377
|
-
matchUp
|
|
19378
|
-
}); // with propagating winningSide changes, activeDownstream only applies to eventType: TEAM
|
|
19379
19397
|
|
|
19380
19398
|
const activeDownstream = isActiveDownstream(params);
|
|
19381
19399
|
const directingMatchUpStatus = isDirectingMatchUpStatus({
|
|
@@ -19471,13 +19489,15 @@ function applyMatchUpValues(params) {
|
|
|
19471
19489
|
if (params.isCollectionMatchUp) {
|
|
19472
19490
|
const {
|
|
19473
19491
|
matchUpTieId,
|
|
19474
|
-
drawDefinition
|
|
19492
|
+
drawDefinition,
|
|
19493
|
+
structure
|
|
19475
19494
|
} = params;
|
|
19476
19495
|
const {
|
|
19477
19496
|
removeWinningSide
|
|
19478
19497
|
} = updateTieMatchUpScore({
|
|
19479
19498
|
matchUpId: matchUpTieId,
|
|
19480
19499
|
drawDefinition,
|
|
19500
|
+
structure,
|
|
19481
19501
|
event
|
|
19482
19502
|
});
|
|
19483
19503
|
console.log('sms', {
|
|
@@ -23638,11 +23658,11 @@ function modifyMatchUpFormatTiming({
|
|
|
23638
23658
|
|
|
23639
23659
|
function getMatchUpFormat({
|
|
23640
23660
|
tournamentRecord,
|
|
23641
|
-
drawId,
|
|
23642
23661
|
drawDefinition,
|
|
23643
|
-
event,
|
|
23644
23662
|
structureId,
|
|
23645
|
-
matchUpId
|
|
23663
|
+
matchUpId,
|
|
23664
|
+
drawId,
|
|
23665
|
+
event
|
|
23646
23666
|
}) {
|
|
23647
23667
|
var _structure, _drawDefinition, _matchUpResult$matchU;
|
|
23648
23668
|
|
|
@@ -23655,8 +23675,9 @@ function getMatchUpFormat({
|
|
|
23655
23675
|
const matchUpResult = findMatchUp({
|
|
23656
23676
|
tournamentRecord,
|
|
23657
23677
|
drawDefinition,
|
|
23678
|
+
matchUpId,
|
|
23658
23679
|
drawId,
|
|
23659
|
-
|
|
23680
|
+
event
|
|
23660
23681
|
});
|
|
23661
23682
|
|
|
23662
23683
|
if (matchUpId && matchUpResult !== null && matchUpResult !== void 0 && matchUpResult.error) {
|
|
@@ -27372,7 +27393,7 @@ const scheduleGovernor$1 = {
|
|
|
27372
27393
|
};
|
|
27373
27394
|
|
|
27374
27395
|
function factoryVersion() {
|
|
27375
|
-
return '0.48.
|
|
27396
|
+
return '0.48.2';
|
|
27376
27397
|
}
|
|
27377
27398
|
|
|
27378
27399
|
function attachPolicies$2({
|
|
@@ -33754,6 +33775,7 @@ function getUnseededByePositions({
|
|
|
33754
33775
|
|
|
33755
33776
|
function getByesData({
|
|
33756
33777
|
drawDefinition,
|
|
33778
|
+
event,
|
|
33757
33779
|
matchUpsMap,
|
|
33758
33780
|
structure
|
|
33759
33781
|
}) {
|
|
@@ -33769,7 +33791,8 @@ function getByesData({
|
|
|
33769
33791
|
drawDefinition,
|
|
33770
33792
|
matchUpFilters,
|
|
33771
33793
|
matchUpsMap,
|
|
33772
|
-
structure
|
|
33794
|
+
structure,
|
|
33795
|
+
event
|
|
33773
33796
|
});
|
|
33774
33797
|
const firstRoundMatchUps = roundMatchUps && roundMatchUps[1] || []; // firstRoundMatchUps don't work for CONTAINER / ROUND_ROBIN structures
|
|
33775
33798
|
|
|
@@ -33830,10 +33853,11 @@ function getByesData({
|
|
|
33830
33853
|
function positionByes({
|
|
33831
33854
|
blockOrdered = false,
|
|
33832
33855
|
drawDefinition,
|
|
33856
|
+
matchUpsMap,
|
|
33833
33857
|
structureId,
|
|
33834
33858
|
structure,
|
|
33835
33859
|
seedsOnly,
|
|
33836
|
-
|
|
33860
|
+
event
|
|
33837
33861
|
}) {
|
|
33838
33862
|
if (!structure) ({
|
|
33839
33863
|
structure
|
|
@@ -33850,8 +33874,9 @@ function positionByes({
|
|
|
33850
33874
|
relevantMatchUps
|
|
33851
33875
|
} = getByesData({
|
|
33852
33876
|
drawDefinition,
|
|
33877
|
+
matchUpsMap,
|
|
33853
33878
|
structure,
|
|
33854
|
-
|
|
33879
|
+
event
|
|
33855
33880
|
});
|
|
33856
33881
|
const byesToPlace = byesCount - placedByes;
|
|
33857
33882
|
if (byesToPlace <= 0) return SUCCESS;
|
|
@@ -34086,13 +34111,14 @@ function positionSeedBlock({
|
|
|
34086
34111
|
}
|
|
34087
34112
|
|
|
34088
34113
|
function automatedPositioning$1({
|
|
34114
|
+
inContextDrawMatchUps,
|
|
34089
34115
|
drawDefinition,
|
|
34090
34116
|
candidatesCount,
|
|
34091
34117
|
participants,
|
|
34092
34118
|
structureId,
|
|
34119
|
+
matchUpsMap,
|
|
34093
34120
|
seedsOnly,
|
|
34094
|
-
|
|
34095
|
-
matchUpsMap
|
|
34121
|
+
event
|
|
34096
34122
|
}) {
|
|
34097
34123
|
const {
|
|
34098
34124
|
structure,
|
|
@@ -34136,9 +34162,10 @@ function automatedPositioning$1({
|
|
|
34136
34162
|
// BYEs must be placed first to ensure lower seeds get BYEs
|
|
34137
34163
|
let result = positionByes({
|
|
34138
34164
|
drawDefinition,
|
|
34165
|
+
matchUpsMap,
|
|
34139
34166
|
structure,
|
|
34140
34167
|
seedsOnly,
|
|
34141
|
-
|
|
34168
|
+
event
|
|
34142
34169
|
});
|
|
34143
34170
|
if (result.error) return result;
|
|
34144
34171
|
result = positionSeedBlocks({
|
|
@@ -34161,11 +34188,12 @@ function automatedPositioning$1({
|
|
|
34161
34188
|
});
|
|
34162
34189
|
if (result.error) return result;
|
|
34163
34190
|
result = positionByes({
|
|
34191
|
+
inContextDrawMatchUps,
|
|
34164
34192
|
drawDefinition,
|
|
34193
|
+
matchUpsMap,
|
|
34165
34194
|
structure,
|
|
34166
34195
|
seedsOnly,
|
|
34167
|
-
|
|
34168
|
-
inContextDrawMatchUps
|
|
34196
|
+
event
|
|
34169
34197
|
});
|
|
34170
34198
|
if (result.error) return result;
|
|
34171
34199
|
}
|
|
@@ -37075,9 +37103,8 @@ function generateDrawType(params = {}) {
|
|
|
37075
37103
|
});
|
|
37076
37104
|
Object.assign(matchUp, {
|
|
37077
37105
|
tieMatchUps,
|
|
37078
|
-
tieFormat,
|
|
37079
37106
|
matchUpType
|
|
37080
|
-
});
|
|
37107
|
+
});
|
|
37081
37108
|
});
|
|
37082
37109
|
}
|
|
37083
37110
|
|
|
@@ -39405,9 +39432,8 @@ function addPlayoffStructures$1(params) {
|
|
|
39405
39432
|
});
|
|
39406
39433
|
Object.assign(matchUp, {
|
|
39407
39434
|
tieMatchUps,
|
|
39408
|
-
tieFormat,
|
|
39409
39435
|
matchUpType: TEAM$3
|
|
39410
|
-
});
|
|
39436
|
+
});
|
|
39411
39437
|
});
|
|
39412
39438
|
}
|
|
39413
39439
|
} // now advance any players from completed matchUps into the newly added structures
|
|
@@ -40152,11 +40178,11 @@ function generateVoluntaryConsolationStructure$1({
|
|
|
40152
40178
|
|
|
40153
40179
|
if (automated) {
|
|
40154
40180
|
automatedPositioning$1({
|
|
40181
|
+
structureId: structureId || structure.structureId,
|
|
40182
|
+
// either passed in or generated in template
|
|
40155
40183
|
drawDefinition,
|
|
40156
40184
|
participants,
|
|
40157
|
-
event
|
|
40158
|
-
structureId: structureId || structure.structureId // either passed in or generated in template
|
|
40159
|
-
|
|
40185
|
+
event
|
|
40160
40186
|
});
|
|
40161
40187
|
}
|
|
40162
40188
|
|