mirror of
https://github.com/sp-tarkov/loot-dump-processor.git
synced 2025-02-13 08:50:44 -05:00
The changes include: - Replaced custom logging with Microsoft.Extensions.Logging - Added TarkovItemsProvider and ComposedKeyGenerator services - Simplified configuration models by removing redundant options - Improved dependency injection in processors and readers - Removed unused factory methods and simplified service registration
24 lines
901 B
C#
24 lines
901 B
C#
using LootDumpProcessor.Model;
|
|
using LootDumpProcessor.Model.Processing;
|
|
using LootDumpProcessor.Utils;
|
|
|
|
namespace LootDumpProcessor.Process;
|
|
|
|
public class ComposedKeyGenerator(ITarkovItemsProvider tarkovItemsProvider) : IComposedKeyGenerator
|
|
{
|
|
private readonly ITarkovItemsProvider _tarkovItemsProvider =
|
|
tarkovItemsProvider ?? throw new ArgumentNullException(nameof(tarkovItemsProvider));
|
|
|
|
public ComposedKey Generate(IEnumerable<Item> items)
|
|
{
|
|
var key = items?.Select(i => i.Tpl)
|
|
.Where(i => !string.IsNullOrEmpty(i) &&
|
|
!_tarkovItemsProvider.IsBaseClass(i, BaseClasses.Ammo))
|
|
.Cast<string>()
|
|
.Select(i => (double)i.GetHashCode())
|
|
.Sum()
|
|
.ToString() ?? KeyGenerator.GetNextKey();
|
|
var firstItem = items?.FirstOrDefault();
|
|
return new ComposedKey(key, firstItem);
|
|
}
|
|
} |