tods-competition-factory 1.6.11 → 1.6.12

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.
@@ -2186,7 +2186,7 @@ function getParticipantResults({
2186
2186
  const manualGamesOverride = tieFormat && matchUp._disableAutoCalc && tieFormat.collectionDefinitions.every(({ scoreValue }) => scoreValue);
2187
2187
  const winningParticipantId = winningSide && getWinningSideId(matchUp);
2188
2188
  const losingParticipantId = winningSide && getLosingSideId(matchUp);
2189
- if (!winningParticipantId || !losingParticipantId) {
2189
+ if (!winningParticipantId && !losingParticipantId) {
2190
2190
  if (completedMatchUpStatuses.includes(matchUpStatus)) {
2191
2191
  const participantIdSide1 = getSideId(matchUp, 0);
2192
2192
  const participantIdSide2 = getSideId(matchUp, 1);
@@ -2198,53 +2198,51 @@ function getParticipantResults({
2198
2198
  checkInitializeParticipant(participantResults, participantIdSide2);
2199
2199
  participantResults[participantIdSide2].matchUpsCancelled += 1;
2200
2200
  }
2201
- } else {
2202
- if (tieMatchUps?.length) {
2203
- perPlayer = 0;
2204
- for (const tieMatchUp of tieMatchUps) {
2205
- if (tieMatchUp.winningSide) {
2206
- const tieWinningParticipantId = sides.find(
2207
- ({ sideNumber }) => sideNumber === tieMatchUp.winningSide
2208
- )?.participantId;
2209
- const tieLosingParticipantId = sides.find(
2210
- ({ sideNumber }) => sideNumber === tieMatchUp.winningSide
2211
- )?.participantId;
2212
- if (tieWinningParticipantId && tieLosingParticipantId) {
2213
- checkInitializeParticipant(
2214
- participantResults,
2215
- tieWinningParticipantId
2216
- );
2217
- checkInitializeParticipant(
2218
- participantResults,
2219
- tieLosingParticipantId
2220
- );
2221
- participantResults[tieWinningParticipantId].tieMatchUpsWon += 1;
2222
- participantResults[tieLosingParticipantId].tieMatchUpsLost += 1;
2223
- if (tieMatchUp.matchUpType === SINGLES) {
2224
- participantResults[tieWinningParticipantId].tieSinglesWon += 1;
2225
- participantResults[tieLosingParticipantId].tieSinglesLost += 1;
2226
- } else if (tieMatchUp.matchUpType === DOUBLES) {
2227
- participantResults[tieWinningParticipantId].tieDoublesWon += 1;
2228
- participantResults[tieLosingParticipantId].tieDoublesLost += 1;
2229
- }
2201
+ } else if (tieMatchUps?.length) {
2202
+ perPlayer = 0;
2203
+ for (const tieMatchUp of tieMatchUps) {
2204
+ if (tieMatchUp.winningSide) {
2205
+ const tieWinningParticipantId = sides.find(
2206
+ ({ sideNumber }) => sideNumber === tieMatchUp.winningSide
2207
+ )?.participantId;
2208
+ const tieLosingParticipantId = sides.find(
2209
+ ({ sideNumber }) => sideNumber === tieMatchUp.winningSide
2210
+ )?.participantId;
2211
+ if (tieWinningParticipantId && tieLosingParticipantId) {
2212
+ checkInitializeParticipant(
2213
+ participantResults,
2214
+ tieWinningParticipantId
2215
+ );
2216
+ checkInitializeParticipant(
2217
+ participantResults,
2218
+ tieLosingParticipantId
2219
+ );
2220
+ participantResults[tieWinningParticipantId].tieMatchUpsWon += 1;
2221
+ participantResults[tieLosingParticipantId].tieMatchUpsLost += 1;
2222
+ if (tieMatchUp.matchUpType === SINGLES) {
2223
+ participantResults[tieWinningParticipantId].tieSinglesWon += 1;
2224
+ participantResults[tieLosingParticipantId].tieSinglesLost += 1;
2225
+ } else if (tieMatchUp.matchUpType === DOUBLES) {
2226
+ participantResults[tieWinningParticipantId].tieDoublesWon += 1;
2227
+ participantResults[tieLosingParticipantId].tieDoublesLost += 1;
2230
2228
  }
2231
2229
  }
2232
- processScore({
2233
- score: tieMatchUp.score,
2234
- manualGamesOverride,
2235
- participantResults,
2236
- sides
2237
- // use sides from the TEAM matchUp
2238
- });
2239
2230
  }
2240
- } else {
2241
2231
  processScore({
2232
+ score: tieMatchUp.score,
2242
2233
  manualGamesOverride,
2243
2234
  participantResults,
2244
- score,
2245
2235
  sides
2236
+ // use sides from the TEAM matchUp
2246
2237
  });
2247
2238
  }
2239
+ } else {
2240
+ processScore({
2241
+ manualGamesOverride,
2242
+ participantResults,
2243
+ score,
2244
+ sides
2245
+ });
2248
2246
  }
2249
2247
  } else {
2250
2248
  checkInitializeParticipant(participantResults, winningParticipantId);
@@ -11074,9 +11072,8 @@ function modifyMatchUpScore({
11074
11072
  return { error: MATCHUP_NOT_FOUND };
11075
11073
  ({ matchUp, structure } = findResult);
11076
11074
  }
11077
- } else {
11078
- if (matchUp.matchUpId !== matchUpId)
11079
- console.log("!!!!!");
11075
+ } else if (matchUp.matchUpId !== matchUpId) {
11076
+ console.log("!!!!!");
11080
11077
  }
11081
11078
  if (matchUpStatus && [WALKOVER$1, DOUBLE_WALKOVER].includes(matchUpStatus) || removeScore) {
11082
11079
  Object.assign(matchUp, { ...toBePlayed });
@@ -11114,31 +11111,45 @@ function modifyMatchUpScore({
11114
11111
  })?.appliedPolicies;
11115
11112
  defaultedProcessCodes = appliedPolicies?.[POLICY_TYPE_SCORING]?.processCodes?.incompleteAssignmentsOnDefault;
11116
11113
  }
11117
- if (structure?.structureType === CONTAINER && !matchUp.collectionId) {
11118
- matchUpFormat = isDualMatchUp ? "SET1-S:T100" : matchUpFormat || matchUp.matchUpFormat || structure?.matchUpFormat || drawDefinition?.matchUpFormat || event?.matchUpFormat;
11119
- const itemStructure = structure.structures.find((itemStructure2) => {
11120
- return itemStructure2?.matchUps.find(
11121
- (matchUp2) => matchUp2.matchUpId === matchUpId
11122
- );
11123
- });
11124
- const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
11125
- const { matchUps } = getAllStructureMatchUps({
11126
- afterRecoveryTimes: false,
11127
- structure: itemStructure,
11128
- inContext: true,
11129
- matchUpFilters,
11130
- event
11131
- });
11132
- const result = updateAssignmentParticipantResults({
11133
- positionAssignments: itemStructure.positionAssignments,
11134
- tournamentRecord,
11135
- drawDefinition,
11136
- matchUpFormat,
11137
- matchUps,
11138
- event
11139
- });
11140
- if (result.error)
11141
- return decorateResult({ result, stack });
11114
+ if (!matchUp.collectionId) {
11115
+ const isRoundRobin = structure?.structureType === CONTAINER;
11116
+ const isAdHocStructure = isAdHoc({ drawDefinition, structure });
11117
+ if (isLucky({ drawDefinition, structure }) || isAdHocStructure || isRoundRobin) {
11118
+ const updateTally = (structure2) => {
11119
+ matchUpFormat = isDualMatchUp ? "SET1-S:T100" : matchUpFormat ?? matchUp.matchUpFormat ?? structure2?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
11120
+ const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
11121
+ const { matchUps } = getAllStructureMatchUps({
11122
+ afterRecoveryTimes: false,
11123
+ inContext: true,
11124
+ matchUpFilters,
11125
+ structure: structure2,
11126
+ event
11127
+ });
11128
+ if (isAdHocStructure) {
11129
+ structure2.positionAssignments = unique(
11130
+ matchUps.flatMap(
11131
+ (matchUp2) => (matchUp2.sides ?? []).map((side) => side.participantId)
11132
+ ).filter(Boolean)
11133
+ ).map((participantId) => ({ participantId }));
11134
+ }
11135
+ return updateAssignmentParticipantResults({
11136
+ positionAssignments: structure2.positionAssignments,
11137
+ tournamentRecord,
11138
+ drawDefinition,
11139
+ matchUpFormat,
11140
+ matchUps,
11141
+ event
11142
+ });
11143
+ };
11144
+ const itemStructure = isRoundRobin && structure.structures.find((itemStructure2) => {
11145
+ return itemStructure2?.matchUps.find(
11146
+ (matchUp2) => matchUp2.matchUpId === matchUpId
11147
+ );
11148
+ });
11149
+ const result = updateTally(itemStructure || structure);
11150
+ if (result.error)
11151
+ return decorateResult({ result, stack });
11152
+ }
11142
11153
  }
11143
11154
  if (notes) {
11144
11155
  const result = addNotes({ element: matchUp, notes });
@@ -13097,7 +13108,7 @@ function getValidSeedBlocks({
13097
13108
  });
13098
13109
  const { positionAssignments } = structureAssignedDrawPositions({ structure });
13099
13110
  const positionsCount = positionAssignments?.length;
13100
- const seedsCount = seedAssignments?.length || 0;
13111
+ const seedsCount = seedAssignments?.length ?? 0;
13101
13112
  let allDrawPositions = [];
13102
13113
  const roundNumbers = Object.keys(roundMatchUps).map((n) => parseInt(n)).sort((a, b) => a - b);
13103
13114
  const uniqueDrawPositionsByRound = roundNumbers.map((roundNumber) => {