Skip to content

Commit

Permalink
Merge pull request #3046 from planetarium/bugfix/claim-items
Browse files Browse the repository at this point in the history
fix duplicate guid NonFungibleItem in Claimitems
  • Loading branch information
tyrosine1153 authored Nov 26, 2024
2 parents f2c372e + f900e40 commit ea61bd0
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions Lib9c/Action/ClaimItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,31 +127,30 @@ public override IWorld Execute(IActionContext context)
{
(bool tradable, int itemId) = Currencies.ParseItemCurrency(tokenCurrency);
states = states.BurnAsset(context, context.Signer, fungibleAssetValue);
var item = itemSheet[itemId] switch
{
MaterialItemSheet.Row materialRow => tradable
? ItemFactory.CreateTradableMaterial(materialRow)
: ItemFactory.CreateMaterial(materialRow),
var itemRow => ItemFactory.CreateItem(itemRow, random)
};

// FIXME: This is an implementation bug in the Inventory class,
// but we'll deal with it temporarily here.
// If Pluggable AEV ever becomes a reality,
// it's only right that this is fixed in Inventory.
var itemRow = itemSheet[itemId];
var itemCount = (int)fungibleAssetValue.RawValue;
if (item is INonFungibleItem)
if (itemRow is MaterialItemSheet.Row materialRow)
{
foreach (var _ in Enumerable.Range(0, itemCount))
{
avatarState.inventory.AddItem(item, 1);
}
var item = tradable
? ItemFactory.CreateTradableMaterial(materialRow)
: ItemFactory.CreateMaterial(materialRow);
avatarState.inventory.AddItem(item, itemCount);
}
else
{
avatarState.inventory.AddItem(item, itemCount);
foreach (var _ in Enumerable.Range(0, itemCount))
{
var item = ItemFactory.CreateItem(itemRow, random);
avatarState.inventory.AddItem(item);
}
}
items.Add((item.Id, itemCount));

items.Add((itemRow.Id, itemCount));
}
}

Expand Down

0 comments on commit ea61bd0

Please sign in to comment.