Revert "try to fix duplicate spare body entries"

This reverts commit 6587bb8b71.
This commit is contained in:
SELEKCJONER
2024-09-25 20:33:05 +02:00
parent 6587bb8b71
commit 2c8050a19b

View File

@@ -57,58 +57,33 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha
var pieceIds = new List<Tuple<int, int>>(); // 2D array to store characterId and pieceId as Tuple var pieceIds = new List<Tuple<int, int>>(); // 2D array to store characterId and pieceId as Tuple
// Add each character's item to user.Items if the character exists in user.Characters // Add each character's item to user.Items if the character exists in user.Characters
foreach (var characterData in selectedCharacters) foreach (var characterData in selectedCharacters)
{ {
// Check if the item for this character already exists in user.Items based on ItemType if (user.Characters.Any(c => c.Tid == characterData.id))
var existingItem = user.Items.FirstOrDefault(item => item.ItemType == characterData.piece_id); {
user.Items.Add(new ItemData()
if (existingItem != null) {
{ ItemType = characterData.piece_id, // Assuming item id corresponds to character id
// If the item exists, increment the count Csn = 0,
existingItem.Count += 1; Count = 1, // or any relevant count
Level = 0,
// Send the updated item in the response Exp = 0,
response.Items.Add(new NetUserItemData() Position = 0,
{ Corp = 0,
Tid = existingItem.ItemType, Isn = user.GenerateUniqueItemId()
Csn = existingItem.Csn, });
Count = existingItem.Count, response.Items.Add(new NetUserItemData()
Level = existingItem.Level, {
Exp = existingItem.Exp, Tid = characterData.piece_id, // Assuming item id corresponds to character id
Position = existingItem.Position, Csn = 0,
Isn = existingItem.Isn Count = 1, // or any relevant count
}); Level = 0,
} Exp = 0,
else Position = 0,
{ Isn = user.GenerateUniqueItemId()
// 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
});
}
}
// Populate the 2D array with characterId and pieceId for each selected character // Populate the 2D array with characterId and pieceId for each selected character
foreach (var characterData in selectedCharacters) foreach (var characterData in selectedCharacters)
{ {