GetOneOnly

This commit is contained in:
2024-05-27 09:14:59 -07:00
parent 365df1158a
commit 665fb8ec06
2 changed files with 54 additions and 15 deletions

View File

@ -838,7 +838,34 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
return result;
}
public List<SaveContainer> GetSaveContainers(string cResultsFullGroupDirectory, string dResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, Shared.Models.Methods.IDistanceLimits distanceLimits, ReadOnlyCollection<LocationContainer> matrix)
public ReadOnlyDictionary<string, LocationContainer> GetOneOnly(Shared.Models.Methods.IDistanceLimits distanceLimits, ReadOnlyCollection<LocationContainer> matrix)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
Dictionary<string, LocationContainer> results = [];
List<string> added = [];
LocationContainer? tryGetValue;
foreach (LocationContainer locationContainer in matrix)
{
if (_Configuration.SaveIndividually)
break;
if (locationContainer.LengthSource is null)
continue;
if (results.TryGetValue(locationContainer.LengthSource.Name, out tryGetValue))
{
if (locationContainer.PersonKey is not null && tryGetValue.PersonKey is not null && locationContainer.PersonKey.Value != tryGetValue.PersonKey)
_ = results.Remove(locationContainer.LengthSource.Name);
continue;
}
if (added.Contains(locationContainer.LengthSource.Name))
continue;
added.Add(locationContainer.LengthSource.Name);
results.Add(locationContainer.LengthSource.Name, locationContainer);
}
return new(results);
}
public List<SaveContainer> GetSaveContainers(string cResultsFullGroupDirectory, string dResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, Shared.Models.Methods.IDistanceLimits distanceLimits, ReadOnlyDictionary<string, LocationContainer> oneOnly)
{
if (_Configuration is null)
throw new NullReferenceException(nameof(_Configuration));
@ -862,17 +889,19 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
string resizeContentDirectory;
FileHolder? facePartsFileHolder;
FileHolder? hiddenFaceFileHolder;
bool sortingContainersAny = matrix.Count > 0;
LocationContainer locationContainer;
bool sortingContainersAny = oneOnly.Count > 0;
string cContentDirectory = Path.Combine(cResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultContent);
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
string d2FacePartsContentDirectory = Path.Combine(d2ResultsFullGroupDirectory, _Configuration.PropertyConfiguration.ResultContent);
foreach (LocationContainer locationContainer in matrix)
foreach (KeyValuePair<string, LocationContainer> keyValuePair in oneOnly)
{
if (_Configuration.SaveIndividually)
break;
locationContainer = keyValuePair.Value;
if (locationContainer.LengthPermyriad is null || locationContainer.LengthSource is null)
continue;
if (added.Contains(locationContainer.LengthSource.Name))
if (added.Contains(keyValuePair.Key))
continue;
segmentB = locationContainer.LengthPermyriad.Value.ToString().PadLeft(2, '0')[..2];
isCounterPersonYear = locationContainer.PersonKey is not null && IPersonBirthday.IsCounterPersonYear(locationContainer.PersonKey.Value);
@ -903,7 +932,7 @@ public partial class MapLogic : Shared.Models.Methods.IMapLogic
resizedFileHolder = IFileHolder.Get(Path.Combine(resizeContentDirectory, $"{locationContainer.LengthSource.FileNameFirstSegment}{Path.GetExtension(locationContainer.LengthSource.NameWithoutExtension)}"));
saveContainer = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, facePartsFileHolder, resizedFileHolder, shortcutFile);
results.Add(saveContainer);
added.Add(locationContainer.LengthSource.Name);
added.Add(keyValuePair.Key);
}
return results;
}