From 2c8050a19b1c6f886525bb15959e4fbdde45331d Mon Sep 17 00:00:00 2001 From: SELEKCJONER Date: Wed, 25 Sep 2024 20:33:05 +0200 Subject: [PATCH] Revert "try to fix duplicate spare body entries" This reverts commit 6587bb8b7176c733e5fc66407951e14e7103a04c. --- EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs | 79 +++++++------------- 1 file changed, 27 insertions(+), 52 deletions(-) diff --git a/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs b/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs index 44b7304..cc9225f 100644 --- a/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs +++ b/EpinelPS/LobbyServer/Msgs/Gacha/ExecGacha.cs @@ -57,58 +57,33 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha var pieceIds = new List>(); // 2D array to store characterId and pieceId as Tuple // Add each character's item to user.Items if the character exists in user.Characters - foreach (var characterData in selectedCharacters) - { - // Check if the item for this character already exists in user.Items based on ItemType - var existingItem = user.Items.FirstOrDefault(item => item.ItemType == characterData.piece_id); - - if (existingItem != null) - { - // If the item exists, increment the count - existingItem.Count += 1; - - // Send the updated item in the response - response.Items.Add(new NetUserItemData() - { - Tid = existingItem.ItemType, - Csn = existingItem.Csn, - Count = existingItem.Count, - Level = existingItem.Level, - Exp = existingItem.Exp, - Position = existingItem.Position, - Isn = existingItem.Isn - }); - } - else - { - // If the item does not exist, create a new item entry - var newItem = new ItemData() - { - ItemType = characterData.piece_id, - Csn = 0, - Count = 1, // or any relevant count - Level = 0, - Exp = 0, - Position = 0, - Corp = 0, - Isn = user.GenerateUniqueItemId() - }; - user.Items.Add(newItem); - - // Add the new item to response - response.Items.Add(new NetUserItemData() - { - Tid = newItem.ItemType, - Csn = newItem.Csn, - Count = newItem.Count, - Level = newItem.Level, - Exp = newItem.Exp, - Position = newItem.Position, - Isn = newItem.Isn - }); - } - } - + foreach (var characterData in selectedCharacters) + { + if (user.Characters.Any(c => c.Tid == characterData.id)) + { + user.Items.Add(new ItemData() + { + ItemType = characterData.piece_id, // Assuming item id corresponds to character id + Csn = 0, + Count = 1, // or any relevant count + Level = 0, + Exp = 0, + Position = 0, + Corp = 0, + Isn = user.GenerateUniqueItemId() + }); + response.Items.Add(new NetUserItemData() + { + Tid = characterData.piece_id, // Assuming item id corresponds to character id + Csn = 0, + Count = 1, // or any relevant count + Level = 0, + Exp = 0, + Position = 0, + Isn = user.GenerateUniqueItemId() + }); + } + } // Populate the 2D array with characterId and pieceId for each selected character foreach (var characterData in selectedCharacters) {