Closed KuDikan closed 1 week ago
TryRemoveItem
里未判断是否为 null
这样子的话,如果count<=0会有问题。
这样子的话,如果count<=0会有问题。
没理解,详细说明一下呢?
数据库没有物品时物品数量应该被当成 0,与有物品但数量为 0 时的处理结果一致。
数据库有物品但数量为0的情况下消耗的数量(count
)小于等于 0 时也是成功的(甚至能不减反增)。
所以没有物品时不应该直接 return false
, 这样就不能0元购了!
理解了,所以解决方案应当是限制消耗数量最小为1
me.cqp.luohuaming.iKun.PublicInfos\Models\InventoryItem.cs
: 当数据库没有某物品时,查询返回的结果为null