优化商店系统

This commit is contained in:
milimoe 2025-07-19 08:35:29 +08:00
parent 1823e00669
commit c32188e0f5
Signed by: milimoe
GPG Key ID: 9554D37E4B8991D0

View File

@ -1393,7 +1393,7 @@ namespace Milimoe.FunGame.Server.Controller
{
Goods goods = store.Goods[goodsId];
int count = counts[goodsId];
if (count > goods.Stock)
if (goods.Stock != -1 && count > goods.Stock)
{
result = false;
buyResult.Add($"购买失败,原因:库存不足,当前库存为:{goods.Stock},购买数量:{count}。");
@ -1425,7 +1425,7 @@ namespace Milimoe.FunGame.Server.Controller
}
if (subResult)
{
goods.Stock -= count;
if (goods.Stock != -1) goods.Stock -= count;
totalCost += totalPrice;
ProcessStoreBuy(goods, useCredits, price, count, user);
buyResult.Add($"成功消费:{totalPrice} {currency},购买了 {count} 个 {goods.Name}。");