Skip to content

Commit

Permalink
Change order of remove item
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-doobu committed Nov 27, 2024
1 parent cfaad72 commit 4d11831
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions Lib9c/Action/Synthesize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ public override IWorld Execute(IActionContext context)
throw new InvalidOperationException("ItemSubType is not set.");
}

// Unequip items (if necessary)
foreach (var materialEquipment in materialEquipments)
{
materialEquipment.Unequip();
}
foreach (var materialCostume in materialCostumes)
{
materialCostume.Unequip();
}

// Remove materials from inventory
foreach (var materialId in MaterialIds)
{
if (!avatarState.inventory.RemoveNonFungibleItem(materialId))
{
throw new NotEnoughMaterialException(
$"{addressesHex} Aborted as the material item ({materialId}) does not exist in inventory."
);
}
}

var synthesizeSheet = sheets.GetSheet<SynthesizeSheet>();
var random = context.GetRandom();
var synthesizedItems = new List<ItemBase>();
Expand Down Expand Up @@ -179,27 +200,6 @@ public override IWorld Execute(IActionContext context)
}
}

// Unequip items (if necessary)
foreach (var materialEquipment in materialEquipments)
{
materialEquipment.Unequip();
}
foreach (var materialCostume in materialCostumes)
{
materialCostume.Unequip();
}

// Remove materials from inventory
foreach (var materialId in MaterialIds)
{
if (!avatarState.inventory.RemoveNonFungibleItem(materialId))
{
throw new NotEnoughMaterialException(
$"{addressesHex} Aborted as the material item ({materialId}) does not exist in inventory."
);
}
}

// Add synthesized items to inventory
foreach (var item in synthesizedItems)
{
Expand Down

0 comments on commit 4d11831

Please sign in to comment.