tods-competition-factory 1.8.20 → 1.8.21

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.
@@ -4308,6 +4308,9 @@ const POLICY_ROUND_NAMING_DEFAULT = {
4308
4308
  namingConventions: {
4309
4309
  round: "Round"
4310
4310
  },
4311
+ qualifyingFinishMap: {
4312
+ 1: "Final"
4313
+ },
4311
4314
  abbreviatedRoundNamingMap: {
4312
4315
  // key is matchUpsCount for the round
4313
4316
  1: "F",
@@ -4321,7 +4324,8 @@ const POLICY_ROUND_NAMING_DEFAULT = {
4321
4324
  },
4322
4325
  affixes: {
4323
4326
  roundNumber: "R",
4324
- preFeedRound: "Q"
4327
+ preFeedRound: "Q",
4328
+ preQualifying: "P"
4325
4329
  },
4326
4330
  stageConstants: {
4327
4331
  [MAIN]: "",
@@ -4334,6 +4338,7 @@ const POLICY_ROUND_NAMING_DEFAULT = {
4334
4338
 
4335
4339
  function getRoundContextProfile({
4336
4340
  roundNamingPolicy,
4341
+ drawDefinition,
4337
4342
  structure,
4338
4343
  matchUps
4339
4344
  }) {
@@ -4344,21 +4349,31 @@ function getRoundContextProfile({
4344
4349
  const isRoundRobin = structure.structures;
4345
4350
  const roundNamingProfile = {};
4346
4351
  const defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
4352
+ const isQualifying = structure.stage === QUALIFYING;
4353
+ const qualifyingFinishgMap = isQualifying && (roundNamingPolicy?.qualifyingFinishMap || defaultRoundNamingPolicy?.qualifyingFinishMap || {});
4354
+ const qualifyingStageSequences = isQualifying ? Math.max(
4355
+ ...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
4356
+ 0
4357
+ ) : 0;
4358
+ const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence || 1) || "" : "";
4359
+ const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
4347
4360
  const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
4348
4361
  const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
4349
- const roundNamePrefix = roundNamingPolicy?.affixes || defaultRoundNamingPolicy.affixes;
4350
- const roundNumberAffix = roundNamePrefix.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
4362
+ const preFeedAffix = roundNamingPolicy?.affixes?.preFeedRound || defaultRoundNamingPolicy.affixes.preFeedRound;
4363
+ const roundNumberAffix = roundNamingPolicy?.affixes?.roundNumber || defaultRoundNamingPolicy.affixes.roundNumber;
4351
4364
  const namingConventions = roundNamingPolicy?.namingConventions || defaultRoundNamingPolicy.namingConventions;
4352
4365
  const roundNameFallback = namingConventions.round;
4353
- const stageInitial = stage && stage !== MAIN && stage[0];
4354
- const stageConstants = roundNamingPolicy?.stageConstants;
4355
- const stageConstant = stage && stageConstants?.[stage] || stageInitial;
4366
+ const stageInitial = stage && stage !== MAIN ? stage[0] : "";
4367
+ const stageConstants = roundNamingPolicy?.stageConstants || defaultRoundNamingPolicy.stageConstants;
4368
+ const stageIndicator = stage && stageConstants?.[stage] || stageInitial;
4369
+ const stageConstant = `${preQualifyingAffix}${stageIndicator}${preQualifyingSequence}`;
4356
4370
  const roundProfileKeys = roundProfile ? Object.keys(roundProfile) : [];
4371
+ const qualifyingAffix = isQualifying && stageConstants?.[QUALIFYING] ? `${stageConstants?.[QUALIFYING]}-` : "";
4357
4372
  if (isRoundRobin || isAdHocStructure || isLuckyStructure) {
4358
4373
  Object.assign(
4359
4374
  roundNamingProfile,
4360
4375
  ...roundProfileKeys.map((key) => {
4361
- const roundName = `${roundNameFallback} ${key}`;
4376
+ const roundName = `${qualifyingAffix}${roundNameFallback} ${key}`;
4362
4377
  const abbreviatedRoundName = `${roundNumberAffix}${key}`;
4363
4378
  return { [key]: { roundName, abbreviatedRoundName } };
4364
4379
  })
@@ -4371,15 +4386,15 @@ function getRoundContextProfile({
4371
4386
  return;
4372
4387
  const { matchUpsCount, preFeedRound } = roundProfile[round];
4373
4388
  const participantsCount = matchUpsCount * 2;
4374
- const sizedRoundName = roundNamingMap[matchUpsCount] || `${roundNamePrefix.roundNumber}${participantsCount}`;
4375
- const suffix = preFeedRound ? `-${roundNamePrefix.preFeedRound}` : "";
4389
+ const sizedRoundName = qualifyingFinishgMap?.[roundProfile?.[round].finishingRound] || qualifyingFinishgMap && `${roundNumberAffix}${participantsCount}` || roundNamingMap[matchUpsCount] || `${roundNumberAffix}${participantsCount}`;
4390
+ const suffix = preFeedRound ? `-${preFeedAffix}` : "";
4376
4391
  const profileRoundName = `${sizedRoundName}${suffix}`;
4377
4392
  const roundName = [
4378
4393
  stageConstant,
4379
4394
  structureAbbreviation,
4380
4395
  profileRoundName
4381
4396
  ].filter(Boolean).join("-");
4382
- const sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] || `${roundNamePrefix.roundNumber}${participantsCount}`;
4397
+ const sizedAbbreviation = abbreviatedRoundNamingMap[matchUpsCount] || `${roundNumberAffix}${participantsCount}`;
4383
4398
  const profileAbbreviation = `${sizedAbbreviation}${suffix}`;
4384
4399
  const abbreviatedRoundName = [
4385
4400
  stageConstant,
@@ -4552,6 +4567,7 @@ function getAllStructureMatchUps({
4552
4567
  const roundNamingPolicy = appliedPolicies?.[POLICY_TYPE_ROUND_NAMING];
4553
4568
  const result = getRoundContextProfile({
4554
4569
  roundNamingPolicy,
4570
+ drawDefinition,
4555
4571
  structure,
4556
4572
  matchUps
4557
4573
  });