might or might not fix negative item issue
This commit is contained in:
parent
9fe8270817
commit
0e36d06214
|
@ -76,10 +76,23 @@ namespace AscNet.Common.Database
|
||||||
Item? item = Items.FirstOrDefault(x => x.Id == itemId);
|
Item? item = Items.FirstOrDefault(x => x.Id == itemId);
|
||||||
ItemTable? itemTable = TableReaderV2.Parse<ItemTable>().Find(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)
|
||||||
{
|
{
|
||||||
item.Count += amount;
|
if (itemTable.MaxCount <= item.Count + amount && item.Count + amount >= 0)
|
||||||
item.RefreshTime = DateTimeOffset.Now.ToUnixTimeSeconds();
|
{
|
||||||
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue