tods-competition-factory 0.45.0 → 0.45.1

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.
@@ -26608,7 +26608,7 @@ const scheduleGovernor = {
26608
26608
  };
26609
26609
 
26610
26610
  function factoryVersion() {
26611
- return '0.45.0';
26611
+ return '0.45.1';
26612
26612
  }
26613
26613
 
26614
26614
  function attachPolicies({
@@ -26659,6 +26659,7 @@ function attachPolicies({
26659
26659
  }
26660
26660
  function attachEventPolicies({
26661
26661
  policyDefinitions,
26662
+ allowReplacement,
26662
26663
  event
26663
26664
  }) {
26664
26665
  if (!event) {
@@ -26681,8 +26682,10 @@ function attachEventPolicies({
26681
26682
  event
26682
26683
  });
26683
26684
  Object.keys(policyDefinitions).forEach(policyType => {
26684
- appliedPolicies[policyType] = policyDefinitions[policyType];
26685
- policiesApplied++;
26685
+ if (!appliedPolicies[policyType] || allowReplacement) {
26686
+ appliedPolicies[policyType] = policyDefinitions[policyType];
26687
+ policiesApplied++;
26688
+ }
26686
26689
  });
26687
26690
 
26688
26691
  if (policiesApplied) {
@@ -34343,10 +34346,10 @@ function initializeStructureSeedAssignments({
34343
34346
  const {
34344
34347
  policyDefinitions
34345
34348
  } = getPolicyDefinitions({
34349
+ policyTypes: [POLICY_TYPE_SEEDING],
34346
34350
  tournamentRecord,
34347
34351
  drawDefinition,
34348
- event,
34349
- policyTypes: [POLICY_TYPE_SEEDING]
34352
+ event
34350
34353
  });
34351
34354
  const {
34352
34355
  seedsCount: maxSeedsCount
@@ -41033,21 +41036,44 @@ function getValidAlternatesAction({
41033
41036
  drawId,
41034
41037
  event
41035
41038
  }) {
41039
+ var _policyDefinitions$PO;
41036
41040
 
41037
41041
  if (activeDrawPositions.includes(drawPosition)) return {};
41042
+ const otherFlightEntries = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : (_policyDefinitions$PO = policyDefinitions[POLICY_TYPE_POSITION_ACTIONS]) === null || _policyDefinitions$PO === void 0 ? void 0 : _policyDefinitions$PO.otherFlightEntries;
41043
+ const drawEnteredParticpantIds = (drawDefinition.entries || []).map(({
41044
+ participantId
41045
+ }) => participantId).filter(Boolean);
41038
41046
  const assignedParticipantIds = positionAssignments.map(assignment => assignment.participantId).filter(Boolean);
41039
41047
  const eventEntries = event.entries || [];
41040
41048
  const availableAlternatesParticipantIds = eventEntries.filter(entry => entry.entryStatus === ALTERNATE && eligibleEntryStage({
41041
41049
  structure,
41042
41050
  entry
41043
- }) && !assignedParticipantIds.includes(entry.participantId)).sort((a, b) => (a.entryPosition || 0) - (b.entryPosition || 0)).map(entry => entry.participantId);
41051
+ }) && !assignedParticipantIds.includes(entry.participantId)).sort((a, b) => (a.entryPosition || 9999) - (b.entryPosition || 9999)).map(entry => entry.participantId);
41052
+
41053
+ if (otherFlightEntries) {
41054
+ var _flightProfile$flight;
41055
+
41056
+ const {
41057
+ flightProfile
41058
+ } = getFlightProfile({
41059
+ event
41060
+ });
41061
+ const otherFlightEnteredParticipantIds = flightProfile === null || flightProfile === void 0 ? void 0 : (_flightProfile$flight = flightProfile.flights) === null || _flightProfile$flight === void 0 ? void 0 : _flightProfile$flight.filter(flight => flight.drawId !== drawId).map(flight => flight.drawEntries.filter(entry => entry.participantId && !drawEnteredParticpantIds.includes(entry.participantId)).map(({
41062
+ participantId
41063
+ }) => participantId)).flat().filter(Boolean);
41064
+
41065
+ if (otherFlightEnteredParticipantIds !== null && otherFlightEnteredParticipantIds !== void 0 && otherFlightEnteredParticipantIds.length) {
41066
+ // include direct acceptance participants from other flights
41067
+ availableAlternatesParticipantIds.push(...otherFlightEnteredParticipantIds);
41068
+ }
41069
+ }
41044
41070
 
41045
41071
  const availableAlternates = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.filter(participant => availableAlternatesParticipantIds.includes(participant.participantId));
41046
41072
  availableAlternates.forEach(alternate => {
41047
41073
  const entry = (drawDefinition.entries || []).find(entry => entry.participantId === alternate.participantId);
41048
41074
  alternate.entryPosition = entry === null || entry === void 0 ? void 0 : entry.entryPosition;
41049
41075
  });
41050
- availableAlternates.sort((a, b) => (a.entryPosition || 0) - (b.entryPosition || 0));
41076
+ availableAlternates.sort((a, b) => (a.entryPosition || 9999) - (b.entryPosition || 9999));
41051
41077
 
41052
41078
  if (availableAlternatesParticipantIds.length) {
41053
41079
  const validAlternatesAction = {
@@ -41419,8 +41445,8 @@ function isAvailableAction({
41419
41445
  */
41420
41446
 
41421
41447
  function positionActions({
41448
+ policyDefinitions: specifiedPolicyDefinitions,
41422
41449
  tournamentParticipants = [],
41423
- policyDefinitions,
41424
41450
  tournamentRecord,
41425
41451
  drawDefinition,
41426
41452
  drawPosition,
@@ -41453,6 +41479,15 @@ function positionActions({
41453
41479
  if (error) return {
41454
41480
  error
41455
41481
  };
41482
+ const {
41483
+ policyDefinitions: attachedPolicyDefinitions
41484
+ } = getPolicyDefinitions({
41485
+ policyTypes: [POLICY_TYPE_POSITION_ACTIONS],
41486
+ tournamentRecord,
41487
+ drawDefinition,
41488
+ event
41489
+ });
41490
+ const policyDefinitions = specifiedPolicyDefinitions || attachedPolicyDefinitions;
41456
41491
  const {
41457
41492
  enabledStructures,
41458
41493
  actionsDisabled
@@ -48044,7 +48079,7 @@ const mocksGovernor = {
48044
48079
  const mocksEngine = /*#__PURE__*/function () {
48045
48080
  const engine = {
48046
48081
  version: () => {
48047
- return '0.45.0';
48082
+ return '0.45.1';
48048
48083
  },
48049
48084
  devContext: isDev => {
48050
48085
  setDevContext(isDev);