diff --git a/nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs b/nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs index 5b54c453bd..643e573fe8 100644 --- a/nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs +++ b/nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs @@ -788,15 +788,17 @@ public IObservable> ItemEnhancement( ["AgentAddress"] = States.Instance.AgentState.address.ToString() }, true); + var materialEquipmentGuids = materialEquipments.Select((matEquipment) => matEquipment.NonFungibleId).ToList(); var action = new ItemEnhancement { itemId = baseEquipment.NonFungibleId, - materialIds = materialEquipments.Select((matEquipment) => matEquipment.NonFungibleId).ToList(), + materialIds = materialEquipmentGuids, avatarAddress = avatarAddress, slotIndex = slotIndex, hammers = hammers }; ProcessAction(action); + States.Instance.RemoveCurrentItemSlotStates(materialEquipmentGuids); return _agent.ActionRenderer.EveryRender() .Timeout(ActionTimeout) @@ -1178,13 +1180,15 @@ public IObservable> Grinding( ["AgentAddress"] = States.Instance.AgentState.address.ToString() }, true); + var equipmentGuids = equipmentList.Select(i => i.ItemId).ToList(); var action = new Grinding { AvatarAddress = avatarAddress, - EquipmentIds = equipmentList.Select(i => i.ItemId).ToList(), + EquipmentIds = equipmentGuids, ChargeAp = chargeAp }; ProcessAction(action); + States.Instance.RemoveCurrentItemSlotStates(equipmentGuids); return _agent.ActionRenderer.EveryRender() .Timeout(ActionTimeout) @@ -1231,11 +1235,7 @@ public IObservable> Synthesize( } // TODO: If need sentry or airBridge trace, add it. - - var action = new Synthesize - { - AvatarAddress = avatarAddress, - MaterialIds = itemBaseList.Select(i => + var materialGuids = itemBaseList.Select(i => { return i switch { @@ -1243,13 +1243,18 @@ public IObservable> Synthesize( Costume costume => costume.ItemId, _ => throw new InvalidCastException(), }; - }).ToList(), + }).ToList(); + var action = new Synthesize + { + AvatarAddress = avatarAddress, + MaterialIds = materialGuids, ChargeAp = chargeAp, MaterialGradeId = (int)grade, MaterialItemSubTypeId = (int)itemSubType, }; ProcessAction(action); - + States.Instance.RemoveCurrentItemSlotStates(materialGuids); + return _agent.ActionRenderer.EveryRender() .Timeout(ActionTimeout) .Where(eval => eval.Action.Id.Equals(action.Id)) diff --git a/nekoyume/Assets/_Scripts/State/States.cs b/nekoyume/Assets/_Scripts/State/States.cs index fd135ad23d..5ab365c07e 100644 --- a/nekoyume/Assets/_Scripts/State/States.cs +++ b/nekoyume/Assets/_Scripts/State/States.cs @@ -78,6 +78,20 @@ public readonly ConcurrentDictionary> public ConcurrentDictionary CurrentRuneSlotStates { get; } = new(); public ConcurrentDictionary CurrentItemSlotStates { get; } = new(); + public void RemoveCurrentItemSlotStates(List removeItems) + { + // removeItems에 있는 아이템을 CurrentItemSlotStates에서 제거합니다. + foreach (var item in removeItems) + { + foreach (var battleType in CurrentItemSlotStates.Keys.ToList()) + { + var itemSlotState = CurrentItemSlotStates[battleType]; + itemSlotState.Equipments.Remove(item); + itemSlotState.Costumes.Remove(item); + } + } + } + private class Workshop { private readonly ConcurrentDictionary _states = new(); @@ -874,5 +888,7 @@ private void SetClaimedGiftIds(List claimedGiftIds) { ClaimedGiftIds = claimedGiftIds; } + + } }