From 4d11831fd4c35cbec4a8828b0cd0961b734494cd Mon Sep 17 00:00:00 2001 From: eugene-hong <58686228+eugene-doobu@users.noreply.github.com> Date: Wed, 27 Nov 2024 11:55:26 +0900 Subject: [PATCH] Change order of remove item --- Lib9c/Action/Synthesize.cs | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Lib9c/Action/Synthesize.cs b/Lib9c/Action/Synthesize.cs index ff48dc203c..e272a6319a 100644 --- a/Lib9c/Action/Synthesize.cs +++ b/Lib9c/Action/Synthesize.cs @@ -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(); var random = context.GetRandom(); var synthesizedItems = new List(); @@ -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) {