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

@@ -59,32 +59,11 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha
// 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);
if (existingItem != null)
{ {
// If the item exists, increment the count user.Items.Add(new ItemData()
existingItem.Count += 1;
// Send the updated item in the response
response.Items.Add(new NetUserItemData()
{ {
Tid = existingItem.ItemType, ItemType = characterData.piece_id, // Assuming item id corresponds to character id
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, Csn = 0,
Count = 1, // or any relevant count Count = 1, // or any relevant count
Level = 0, Level = 0,
@@ -92,23 +71,19 @@ namespace EpinelPS.LobbyServer.Msgs.Gacha
Position = 0, Position = 0,
Corp = 0, Corp = 0,
Isn = user.GenerateUniqueItemId() Isn = user.GenerateUniqueItemId()
}; });
user.Items.Add(newItem);
// Add the new item to response
response.Items.Add(new NetUserItemData() response.Items.Add(new NetUserItemData()
{ {
Tid = newItem.ItemType, Tid = characterData.piece_id, // Assuming item id corresponds to character id
Csn = newItem.Csn, Csn = 0,
Count = newItem.Count, Count = 1, // or any relevant count
Level = newItem.Level, Level = 0,
Exp = newItem.Exp, Exp = 0,
Position = newItem.Position, Position = 0,
Isn = newItem.Isn Isn = user.GenerateUniqueItemId()
}); });
} }
} }
// 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)
{ {