1
0
mirror of https://github.com/wangdage12/Snap.Hutao.git synced 2026-07-31 04:10:25 +08:00

修复某系周本没有纳入转换范围

This commit is contained in:
mfkvfhpdx
2026-05-04 17:01:48 +08:00
parent 82f1820ca9
commit 57461a06dd
@@ -129,6 +129,7 @@ internal sealed partial class CultivationService : ICultivationService
token.ThrowIfCancellationRequested(); token.ThrowIfCancellationRequested();
Dictionary</* ItemId */ uint, StatisticsCultivateItem> resultItems = []; Dictionary</* ItemId */ uint, StatisticsCultivateItem> resultItems = [];
Guid projectId = cultivateProject.InnerId; Guid projectId = cultivateProject.InnerId;
Dictionary<uint, uint> inventoryCounts = [];
foreach (ref readonly CultivateEntry entry in cultivationRepository.GetCultivateEntryImmutableArrayByProjectId(projectId).AsSpan()) foreach (ref readonly CultivateEntry entry in cultivationRepository.GetCultivateEntryImmutableArrayByProjectId(projectId).AsSpan())
{ {
@@ -153,6 +154,7 @@ internal sealed partial class CultivationService : ICultivationService
foreach (ref readonly InventoryItem inventoryItem in inventoryRepository.GetInventoryItemImmutableArrayByProjectId(projectId).AsSpan()) foreach (ref readonly InventoryItem inventoryItem in inventoryRepository.GetInventoryItemImmutableArrayByProjectId(projectId).AsSpan())
{ {
token.ThrowIfCancellationRequested(); token.ThrowIfCancellationRequested();
inventoryCounts[inventoryItem.ItemId] = inventoryItem.Count;
ref StatisticsCultivateItem existedItem = ref CollectionsMarshal.GetValueRefOrNullRef(resultItems, inventoryItem.ItemId); ref StatisticsCultivateItem existedItem = ref CollectionsMarshal.GetValueRefOrNullRef(resultItems, inventoryItem.ItemId);
if (!Unsafe.IsNullRef(in existedItem)) if (!Unsafe.IsNullRef(in existedItem))
{ {
@@ -160,6 +162,13 @@ internal sealed partial class CultivationService : ICultivationService
} }
} }
AddWeeklyBossGroupInventoryDonors(
resultItems,
inventoryCounts,
context,
cultivateProject.ServerTimeZoneOffset,
mergeOptions.WeeklyBossMaterialInterchange);
CultivationStatisticsSurplusMerge.Apply(resultItems, context, mergeOptions); CultivationStatisticsSurplusMerge.Apply(resultItems, context, mergeOptions);
CultivationStatisticsWeeklyBossInterchange.Apply( CultivationStatisticsWeeklyBossInterchange.Apply(
resultItems, resultItems,
@@ -171,6 +180,55 @@ internal sealed partial class CultivationService : ICultivationService
} }
} }
private static void AddWeeklyBossGroupInventoryDonors(
Dictionary<uint, StatisticsCultivateItem> items,
Dictionary<uint, uint> inventoryCounts,
ICultivationMetadataContext context,
TimeSpan offset,
bool enabled)
{
if (!enabled || context.WeeklyBossMaterialInterchangeGroups.IsDefaultOrEmpty)
{
return;
}
foreach (ImmutableArray<MaterialId> group in context.WeeklyBossMaterialInterchangeGroups)
{
bool anyPlannedInGroup = false;
foreach (MaterialId mid in group)
{
if (items.ContainsKey(mid))
{
anyPlannedInGroup = true;
break;
}
}
if (!anyPlannedInGroup)
{
continue;
}
foreach (MaterialId mid in group)
{
uint id = mid;
if (items.ContainsKey(id))
{
continue;
}
if (!inventoryCounts.TryGetValue(id, out uint inv) || inv is 0U)
{
continue;
}
StatisticsCultivateItem donor = StatisticsCultivateItem.Create(context.GetMaterial(id), offset);
donor.Current = inv;
items[id] = donor;
}
}
}
public ValueTask<ResinStatistics> GetResinStatisticsAsync(StatisticsCultivateItemCollection statisticsCultivateItems, CancellationToken token) public ValueTask<ResinStatistics> GetResinStatisticsAsync(StatisticsCultivateItemCollection statisticsCultivateItems, CancellationToken token)
{ {
return cultivationResinStatisticsService.GetResinStatisticsAsync(statisticsCultivateItems, token); return cultivationResinStatisticsService.GetResinStatisticsAsync(statisticsCultivateItems, token);