/// <summary>Unplaces the restricted spot.</summary> /// <param name="smoothPass">The smooth pass.</param> /// <param name="smoothSpot">The smooth spot.</param> /// <param name="smoothBreak">The smooth break.</param> /// <param name="spotActionMessage">The spot action message.</param> /// <param name="spotIdsUsed">The spot ids used.</param> private void UnplaceRestrictedSpot( SmoothPass smoothPass, SmoothSpot smoothSpot, SmoothBreak smoothBreak, string spotActionMessage, ISet <Guid> spotIdsUsed) { RaiseInfo( $"Unplacing booked spot {smoothSpot.Spot.ExternalSpotRef} " + $"from break {smoothBreak.TheBreak.ExternalBreakRef}: {spotActionMessage}" ); SpotPlacementService.RemoveSpotFromBreak( smoothBreak, smoothSpot.Spot, spotIdsUsed, _sponsorshipRestrictionService ); smoothSpot.IsCurrent = true; _smoothDiagnostics.LogSpotAction( smoothPass, 0, smoothSpot.Spot, smoothBreak, SmoothSpot.SmoothSpotActions.RemoveSpotFromBreak, spotActionMessage); }
/// <summary> /// Moves the spot to the unplaced spots list /// </summary> private void MoveSpotToUnplacedList( SmoothPass smoothPass, int smoothPassIteration, string externalSpotRef, IReadOnlyCollection <SmoothBreak> progSmoothBreaks, ICollection <Guid> spotIdsUsed, bool logSpotAction) { // Find the break that spot is placed in var smoothBreak = progSmoothBreaks.FirstOrDefault(sb => sb.SmoothSpots.Any(s => s.Spot.ExternalSpotRef == externalSpotRef) ); if (smoothBreak is null) { return; } // Spot was placed in break var smoothSpot = smoothBreak.SmoothSpots.FirstOrDefault(s => s.Spot.ExternalSpotRef == externalSpotRef); SpotPlacementService.RemoveSpotFromBreak( smoothBreak, smoothSpot.Spot, spotIdsUsed, _sponsorshipRestrictionService ); if (logSpotAction) { _smoothDiagnostics.LogSpotAction( smoothPass, smoothPassIteration, smoothSpot.Spot, smoothBreak, SmoothSpot.SmoothSpotActions.RemoveSpotFromBreak, "Scenario"); } }
/// <summary> /// Moves the spot to the break /// </summary> private void MoveSpotToBreak( SmoothPass smoothPass, int smoothPassIteration, string externalSpotRef, string externalBreakRef, IReadOnlyCollection <SmoothBreak> progSmoothBreaks, ICollection <Guid> spotIdsUsed, bool logSpotAction) { // Find the break that spot is placed in var srcSmoothBreak = progSmoothBreaks.FirstOrDefault(sb => sb.SmoothSpots.Any(s => s.Spot.ExternalSpotRef == externalSpotRef) ); if (srcSmoothBreak is null) { return; } SmoothSpot smoothSpot = srcSmoothBreak.SmoothSpots .First(s => s.Spot.ExternalSpotRef == externalSpotRef); SpotPlacementService.RemoveSpotFromBreak( srcSmoothBreak, smoothSpot.Spot, spotIdsUsed, _sponsorshipRestrictionService ); if (logSpotAction) { _smoothDiagnostics.LogSpotAction( smoothPass, smoothPassIteration, smoothSpot.Spot, srcSmoothBreak, SmoothSpot.SmoothSpotActions.RemoveSpotFromBreak, "Scenario"); } // Find the break that spot should be placed in. var dstSmoothBreak = progSmoothBreaks.FirstOrDefault(sb => sb.TheBreak.ExternalBreakRef == externalBreakRef); if (dstSmoothBreak is null) { return; } _ = SpotPlacementService.AddSpotsToBreak( dstSmoothBreak, smoothSpot.SmoothPassSequence, smoothPassIterationSequence: 0, new List <Spot>() { smoothSpot.Spot }, SpotPositionRules.Exact, canMoveSpotToOtherBreak: true, spotIdsUsed, bestBreakFactorGroupName: null, _spotInfos, _sponsorshipRestrictionService); if (logSpotAction) { _smoothDiagnostics.LogSpotAction( smoothPass, smoothPassIteration, smoothSpot.Spot, dstSmoothBreak, SmoothSpot.SmoothSpotActions.PlaceSpotInBreak, "Scenario"); } }