diff --git a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaStatisticsFactory.cs b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaStatisticsFactory.cs index 99c464b7..5c26e0b7 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaStatisticsFactory.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/Factory/GachaStatisticsFactory.cs @@ -8,6 +8,7 @@ using Snap.Hutao.Model.Metadata.Avatar; using Snap.Hutao.Model.Metadata.Weapon; using Snap.Hutao.Service.Metadata; using Snap.Hutao.ViewModel.GachaLog; +using Snap.Hutao.Web.Hoyolab.Hk4e.Event.GachaInfo; using Snap.Hutao.Web.Hutao.GachaLog; using System.Runtime.InteropServices; @@ -59,14 +60,19 @@ internal sealed partial class GachaStatisticsFactory : IGachaStatisticsFactory Dictionary purpleWeaponCounter = new(); Dictionary blueWeaponCounter = new(); + // Pre group builders + Dictionary> historyWishBuilderMap = historyWishBuilders + .GroupBy(b => b.ConfigType) + .ToDictionary(g => g.Key, g => g.ToList().SortBy(b => b.From)); + // Items are ordered by precise time, first is oldest // 'ref' is not allowed here because we have lambda below foreach (Model.Entity.GachaItem item in CollectionsMarshal.AsSpan(items)) { // Find target history wish to operate. - HistoryWishBuilder? targetHistoryWishBuilder = historyWishBuilders - .Where(w => w.ConfigType == item.GachaType) - .SingleOrDefault(w => w.From <= item.Time && w.To >= item.Time); + HistoryWishBuilder? targetHistoryWishBuilder = item.GachaType is not GachaConfigType.StandardWish + ? historyWishBuilderMap[item.GachaType].FirstOrDefault(w => w.From <= item.Time && w.To >= item.Time) + : default; switch (item.ItemId.StringLength()) { diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs index 880a804a..75e280f7 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/GameService.cs @@ -184,7 +184,7 @@ internal sealed partial class GameService : IGameService { GameResource resource = response.Data; - if (!LaunchSchemeMatchesExecutable(launchScheme, gameFileName)) + if (!launchScheme.ExecutableMatches(gameFileName)) { bool replaced = await packageConverter .EnsureGameResourceAsync(launchScheme, resource, gameFolder, progress) @@ -398,6 +398,4 @@ internal sealed partial class GameService : IGameService _ => false, }; } - - private static bool LaunchScheme } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchScheme.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchScheme.cs index 00f69330..178b2b34 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchScheme.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/LaunchScheme.cs @@ -75,19 +75,4 @@ internal sealed partial class LaunchScheme _ => false, }; } - - public bool SdkLibraryMatches(string gameFolder) - { - if (IsOversea) - { - return false; - } - - if (LauncherId is SdkStaticLauncherBilibiliId) - { - - } - - string sdkDll = Path.Combine(gameFolder, GameConstants.YuanShenData, "Plugins\\PCGameSDK.dll"); - } } \ No newline at end of file