feat(inventory): GrantAsync handles Item branch

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-31 15:52:42 -04:00
parent a1cf1d7519
commit 1f3f81d878
2 changed files with 73 additions and 0 deletions

View File

@@ -99,6 +99,26 @@ internal sealed class InventoryTransaction : IInventoryTransaction
_ops.Add(new GrantOp(type, detailId, num, 1, false));
return Single(type, detailId, 1);
case UserGoodsType.Item:
{
var owned = Viewer.Items.FirstOrDefault(i => i.Item.Id == (int)detailId);
int post;
if (owned is null)
{
var item = _db.Items.Find((int)detailId)
?? throw new InventoryCatalogException($"Item {detailId} not in catalog");
Viewer.Items.Add(new OwnedItemEntry { Item = item, Count = num, Viewer = Viewer });
post = num;
}
else
{
owned.Count += num;
post = owned.Count;
}
_ops.Add(new GrantOp(type, detailId, num, post, false));
return Single(type, detailId, post);
}
default:
throw new NotImplementedException(
$"UserGoodsType {type} grant lands in a subsequent task");