From 7bb8a962affa23f6ebe52053728bdb0bd2106a9a Mon Sep 17 00:00:00 2001 From: rfi Date: Wed, 17 Jan 2024 22:54:02 +0700 Subject: [PATCH] another Inventory.Do fix --- AscNet.Common/Database/Inventory.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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(); } }