feat(import): import consumable item inventory

This commit is contained in:
gamer147
2026-05-29 18:33:11 -04:00
parent 71b3c3e19f
commit d7e5557d61
3 changed files with 55 additions and 0 deletions

View File

@@ -163,6 +163,25 @@ public class AdminController : SVSimController
}
}
if (request.Items is not null)
{
var wanted = request.Items
.GroupBy(i => i.ItemId)
.Select(g => g.First())
.ToList();
var ids = wanted.Select(i => i.ItemId).ToList();
var itemMaster = await _dbContext.Items
.Where(i => ids.Contains(i.Id))
.ToDictionaryAsync(i => i.Id);
viewer.Items.Clear();
foreach (var i in wanted)
{
if (!itemMaster.TryGetValue(i.ItemId, out var item)) continue; // unknown master id
viewer.Items.Add(new OwnedItemEntry { Item = item, Count = i.Count, Viewer = viewer });
}
}
// Clone the 8 starter decks into the viewer when freshly created — workaround for a
// client-side NRE in the deck-edit menu (DeckListUI.IsVisibleCreateNewButton at
// decompile Wizard/DeckListUI.cs:316 unconditionally reads `_deckGroup.DeckFormat`, but