tods-competition-factory 1.8.23 → 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)
@@ -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) => {
@@ -11549,8 +11552,10 @@ function modifyMatchUpScore({
11549
11552
  const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM$2] } : void 0;
11550
11553
  const { matchUps } = getAllStructureMatchUps({
11551
11554
  afterRecoveryTimes: false,
11555
+ tournamentRecord,
11552
11556
  inContext: true,
11553
11557
  matchUpFilters,
11558
+ drawDefinition,
11554
11559
  structure: structure2,
11555
11560
  event
11556
11561
  });