Hellobaka / KunBot

代号:鲲
Apache License 2.0
2 stars 2 forks source link

获取物品数量时出错 #8

Closed KuDikan closed 1 week ago

KuDikan commented 1 week ago

me.cqp.luohuaming.iKun.PublicInfos\Models\InventoryItem.cs : 当数据库没有某物品时,查询返回的结果为 null

KuDikan commented 1 week ago

TryRemoveItem 里未判断是否为 null

KuDikan commented 1 week ago

这样子的话,如果count<=0会有问题。

Hellobaka commented 1 week ago

这样子的话,如果count<=0会有问题。

没理解,详细说明一下呢?

KuDikan commented 1 week ago

数据库没有物品时物品数量应该被当成 0,与有物品但数量为 0 时的处理结果一致。 数据库有物品但数量为0的情况下消耗的数量(count)小于等于 0 时也是成功的(甚至能不减反增)。

所以没有物品时不应该直接 return false, 这样就不能0元购了!

Hellobaka commented 1 week ago

理解了,所以解决方案应当是限制消耗数量最小为1