diff --git a/AscNet.Common/Database/Inventory.cs b/AscNet.Common/Database/Inventory.cs index 8d4b5a53..c3bf0c31 100644 --- a/AscNet.Common/Database/Inventory.cs +++ b/AscNet.Common/Database/Inventory.cs @@ -78,19 +78,19 @@ namespace AscNet.Common.Database if (item is not null && itemTable is not null) { - if (itemTable.MaxCount <= item.Count + amount && item.Count + amount >= 0) + if (item.Count + amount <= itemTable.MaxCount && item.Count + amount >= 0) { item.Count += amount; item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(); } - else if (itemTable.MaxCount <= item.Count + amount) + else if (item.Count + amount < 0) { - item.Count = itemTable.MaxCount ?? item.Count + amount; + item.Count = 0; item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(); } else { - item.Count = 0; + item.Count = itemTable.MaxCount ?? item.Count + amount; item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds(); } }