tods-competition-factory 1.8.22 → 1.8.24

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.
@@ -1531,7 +1531,7 @@ type AddFinishingRoundsArgs = {
1531
1531
  };
1532
1532
  declare function addFinishingRounds({ finishingPositionOffset, finishingPositionLimit, positionsFed, roundsCount, roundLimit, matchUps, lucky, fmlc, }: AddFinishingRoundsArgs): MatchUp[];
1533
1533
 
1534
- declare function structureSort(a: Structure, b: Structure, config?: any): number;
1534
+ declare function structureSort(a: Structure | undefined, b: Structure | undefined, config?: any): number;
1535
1535
 
1536
1536
  /**
1537
1537
  * Sorting function to arrange matchUps by stage, stageSequence, roundNumber, roundPosition (where applicable)
@@ -2892,18 +2892,17 @@ function getTallyReport({ matchUps, order, report }) {
2892
2892
  readable.push(excluded);
2893
2893
  } else {
2894
2894
  const floatSort = (a, b) => parseFloat(step.reversed ? a : b) - parseFloat(step.reversed ? b : a);
2895
+ const participantsCount = step.groups ? Object.values(step.groups).flat(Infinity).length : step.participantIds?.length ?? 0;
2895
2896
  const getExplanation = (step2) => {
2896
- Object.keys(step2.groups).sort(floatSort).forEach((key) => {
2897
+ step2.groups && Object.keys(step2.groups).sort(floatSort).forEach((key) => {
2897
2898
  const participantNames = step2.groups[key].map((participantId) => participants[participantId]).join(", ");
2898
2899
  const explanation = `${key} ${step2.attribute}: ${participantNames}`;
2899
2900
  readable.push(explanation);
2900
2901
  });
2901
2902
  };
2902
2903
  const reversed = step.reversed ? " in reverse order" : "";
2903
- const participantsCount = Object.values(step.groups).flat(
2904
- Infinity
2905
- ).length;
2906
- const description = `Step ${i + 1}: ${participantsCount} particiants were grouped${reversed} by ${step.attribute}`;
2904
+ const action = step.groups ? "grouped" : "separated";
2905
+ const description = `Step ${i + 1}: ${participantsCount} particiants were ${action}${reversed} by ${step.attribute}`;
2907
2906
  readable.push(description);
2908
2907
  if (step.idsFilter) {
2909
2908
  const note = `${step.attribute} was calculated considering ONLY TIED PARTICIPANTS`;
@@ -2919,7 +2918,7 @@ function getTallyReport({ matchUps, order, report }) {
2919
2918
  const { participantId, resolved } = orderEntry;
2920
2919
  const pOrder = orderEntry.groupOrder || orderEntry.provisionalOrder;
2921
2920
  readable.push(
2922
- `${pOrder}: ${participants[participantId]} => resolved: ${resolved}`
2921
+ `${pOrder}: ${participants[participantId]} => resolved: ${!!resolved}`
2923
2922
  );
2924
2923
  });
2925
2924
  return readable.join("\r\n");
@@ -3008,7 +3007,7 @@ function getGroupOrder(params) {
3008
3007
  report.push({ attribute, groups: orderedTallyGroups });
3009
3008
  const groupOrder = Object.keys(orderedTallyGroups).map((key) => parseFloat(key)).sort((a, b) => b - a).map((key) => orderedTallyGroups[key]).map((participantIds) => {
3010
3009
  const result = groupSubSort({ participantIds, ...params });
3011
- report.push(result.report);
3010
+ report.push(...result.report || []);
3012
3011
  return result.order;
3013
3012
  }).flat(Infinity);
3014
3013
  let groupPosition = 1;
@@ -3100,7 +3099,7 @@ function processAttribute({
3100
3099
  tallyPolicy,
3101
3100
  matchUps
3102
3101
  });
3103
- report.push(result.report);
3102
+ report.push(...result.report || []);
3104
3103
  return result.order;
3105
3104
  }).flat(Infinity);
3106
3105
  }
@@ -3114,6 +3113,9 @@ function groupSubSort({
3114
3113
  tallyPolicy,
3115
3114
  matchUps
3116
3115
  }) {
3116
+ const excludedDirectives = [];
3117
+ const report = [];
3118
+ let result;
3117
3119
  if (participantIds?.length === 1) {
3118
3120
  const participantId = participantIds[0];
3119
3121
  return {
@@ -3122,13 +3124,13 @@ function groupSubSort({
3122
3124
  }
3123
3125
  if (participantIds?.length === 2 && (!tallyPolicy?.headToHead || !tallyPolicy.headToHead.disabled && !disableHeadToHead)) {
3124
3126
  const result2 = headToHeadWinner({ participantIds, participantResults });
3125
- if (result2)
3126
- return { order: [result2], headToHeadWinner: result2[0].participantId };
3127
+ if (result2) {
3128
+ const headToHeadWinner2 = result2[0].participantId;
3129
+ report.push({ attribute: "head2Head", participantIds, headToHeadWinner: headToHeadWinner2 });
3130
+ return { order: [result2], headToHeadWinner: headToHeadWinner2, report };
3131
+ }
3127
3132
  }
3128
3133
  const directives = tallyPolicy?.tallyDirectives || headToHeadTallyDirectives;
3129
- const excludedDirectives = [];
3130
- const report = [];
3131
- let result;
3132
3134
  const filteredDirectives = directives.filter((directive) => {
3133
3135
  const keepDirective = isNumeric(directive.maxParticipants) && participantIds?.length > directive.maxParticipants ? false : true;
3134
3136
  if (!keepDirective)
@@ -3902,7 +3904,7 @@ function findVenue({
3902
3904
  if (!venue && tournamentRecords) {
3903
3905
  const linkedTournamentIds = getLinkedTournamentIds({
3904
3906
  tournamentRecords
3905
- }).linkedTournamentIds || [];
3907
+ }).linkedTournamentIds ?? [];
3906
3908
  const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
3907
3909
  for (const tournamentId of relevantIds) {
3908
3910
  const record = tournamentRecords[tournamentId];
@@ -4460,7 +4462,7 @@ function getPairedParticipant({
4460
4462
  result: { error: MISSING_PARTICIPANT_IDS },
4461
4463
  stack
4462
4464
  });
4463
- tournamentParticipants = tournamentParticipants || tournamentRecord?.participants || [];
4465
+ tournamentParticipants = tournamentParticipants ?? tournamentRecord?.participants ?? [];
4464
4466
  const existingPairedParticipants = tournamentParticipants.filter(
4465
4467
  (participant) => participant.participantType === PAIR && intersection(participantIds, participant.individualParticipantIds).length === participantIds.length && participant.individualParticipantIds.length === participantIds.length
4466
4468
  );
@@ -5754,7 +5756,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
5754
5756
  [POLICY_TYPE_ROUND_NAMING]: {
5755
5757
  policyName: "Round Naming Default",
5756
5758
  namingConventions: {
5757
- round: "Round"
5759
+ round: "Round",
5760
+ pre: "Pre"
5758
5761
  },
5759
5762
  qualifyingFinishMap: {
5760
5763
  1: "Final"
@@ -5798,12 +5801,11 @@ function getRoundContextProfile({
5798
5801
  const roundNamingProfile = {};
5799
5802
  const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
5800
5803
  const isQualifying = structure.stage === QUALIFYING;
5801
- const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
5802
5804
  const qualifyingStageSequences = isQualifying ? Math.max(
5803
5805
  ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
5804
5806
  0
5805
5807
  ) : 0;
5806
- const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence || 1) || "" : "";
5808
+ const preQualifyingSequence = (structure.stageSequence ?? 1) < qualifyingStageSequences ? structure.stageSequence ?? 1 : "";
5807
5809
  const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
5808
5810
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
5809
5811
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
@@ -5827,6 +5829,7 @@ function getRoundContextProfile({
5827
5829
  })
5828
5830
  );
5829
5831
  } else {
5832
+ const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
5830
5833
  Object.assign(
5831
5834
  roundNamingProfile,
5832
5835
  ...roundProfileKeys.map((round) => {
@@ -6101,7 +6104,13 @@ function getAllStructureMatchUps({
6101
6104
  matchUps
6102
6105
  }));
6103
6106
  }
6104
- return { matchUps, roundMatchUps, roundProfile, collectionPositionMatchUps };
6107
+ return {
6108
+ collectionPositionMatchUps,
6109
+ roundMatchUps,
6110
+ roundProfile,
6111
+ matchUpsMap,
6112
+ matchUps
6113
+ };
6105
6114
  function addMatchUpContext({
6106
6115
  scheduleVisibilityFilters: scheduleVisibilityFilters2,
6107
6116
  sourceDrawPositionRanges,
@@ -10761,7 +10770,7 @@ function getContainedStructures({
10761
10770
  const containerStructures = {};
10762
10771
  const structureContainers = drawDefinitions.map((dd) => dd?.structures?.filter((structure) => structure?.structures)).flat().filter(Boolean);
10763
10772
  for (const structureContainer of structureContainers) {
10764
- const { structures, structureId } = structureContainer || {};
10773
+ const { structures, structureId } = structureContainer ?? {};
10765
10774
  structures && structureId && (containedStructures[structureId] = structures?.map(
10766
10775
  (structure) => structure.structureId
10767
10776
  )) && structures.forEach(
@@ -11543,8 +11552,10 @@ function modifyMatchUpScore({
11543
11552
  const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
11544
11553
  const { matchUps } = getAllStructureMatchUps({
11545
11554
  afterRecoveryTimes: false,
11555
+ tournamentRecord,
11546
11556
  inContext: true,
11547
11557
  matchUpFilters,
11558
+ drawDefinition,
11548
11559
  structure: structure2,
11549
11560
  event
11550
11561
  });
@@ -15319,7 +15330,6 @@ function getVenuesAndCourts({
15319
15330
  tournamentIds.forEach((tournamentId) => {
15320
15331
  const tournamentRecord = tournamentRecords[tournamentId];
15321
15332
  for (const venue of tournamentRecord.venues || []) {
15322
- tournamentRecord.venues;
15323
15333
  if (venueIds.length && !venueIds.includes(venue.venueId))
15324
15334
  continue;
15325
15335
  if (ignoreDisabled) {