Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix item slot state #6878

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions nekoyume/Assets/_Scripts/Blockchain/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,15 +855,17 @@ public IObservable<ActionEvaluation<ItemEnhancement>> ItemEnhancement(
evt.AddCustomAttribute("avatar-address", States.Instance.AgentState.address.ToString());
AirbridgeUnity.TrackEvent(evt);

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<ItemEnhancement>()
.Timeout(ActionTimeout)
Expand Down Expand Up @@ -1272,13 +1274,15 @@ public IObservable<ActionEvaluation<Grinding>> Grinding(
evt.AddCustomAttribute("avatar-address", States.Instance.AgentState.address.ToString());
AirbridgeUnity.TrackEvent(evt);

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<Grinding>()
.Timeout(ActionTimeout)
Expand Down Expand Up @@ -1325,25 +1329,26 @@ public IObservable<ActionEvaluation<Synthesize>> 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
{
Equipment equipment => equipment.ItemId,
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<Synthesize>()
.Timeout(ActionTimeout)
.Where(eval => eval.Action.Id.Equals(action.Id))
Expand Down
16 changes: 16 additions & 0 deletions nekoyume/Assets/_Scripts/State/States.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ public readonly ConcurrentDictionary<int, Dictionary<BattleType, ItemSlotState>>
public ConcurrentDictionary<BattleType, RuneSlotState> CurrentRuneSlotStates { get; } = new();
public ConcurrentDictionary<BattleType, ItemSlotState> CurrentItemSlotStates { get; } = new();

public void RemoveCurrentItemSlotStates(List<Guid> 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<int, CombinationSlotState> _states = new();
Expand Down Expand Up @@ -874,5 +888,7 @@ private void SetClaimedGiftIds(List<int> claimedGiftIds)
{
ClaimedGiftIds = claimedGiftIds;
}


}
}
Loading