feat(inventory): GrantAsync handles Item branch
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user