forked from PGR/ascnet
might or might not fix negative item issue
This commit is contained in:
parent
9fe8270817
commit
0e36d06214
|
@ -76,11 +76,24 @@ namespace AscNet.Common.Database
|
|||
Item? item = Items.FirstOrDefault(x => x.Id == itemId);
|
||||
ItemTable? itemTable = TableReaderV2.Parse<ItemTable>().Find(x => x.Id == itemId);
|
||||
|
||||
if (item is not null && itemTable is not null && itemTable.MaxCount <= item.Count + amount)
|
||||
if (item is not null && itemTable is not null)
|
||||
{
|
||||
if (itemTable.MaxCount <= item.Count + amount && item.Count + amount >= 0)
|
||||
{
|
||||
item.Count += amount;
|
||||
item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
}
|
||||
else if (itemTable.MaxCount <= item.Count + amount)
|
||||
{
|
||||
item.Count = itemTable.MaxCount ?? item.Count + amount;
|
||||
item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Count = 0;
|
||||
item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
item = new Item()
|
||||
|
|
Loading…
Reference in New Issue