fix: two bugs in mcifsh (#1029)

1. 修复商品数量大于250时,商品价格浮动区间数值异常
2. 修复出售限制未生效的问题。(时间未更新)
This commit is contained in:
vatebur 2024-10-14 13:09:43 +08:00 committed by GitHub
parent 78d156395b
commit b9bea7dff7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -593,8 +593,8 @@ func (sql *fishdb) refreshStroeInfo() (ok bool, err error) {
thingInfo := store{}
_ = sql.db.Find("store", &thingInfo, "where Name = '"+name+"'")
if thingInfo.Number > 150 {
// 通货膨胀
thing.Discount = (1000 - 5*(thingInfo.Number-150)) / 10
// 商品贬值,价格区间 -50%到0%
thing.Discount = 50 + rand.Intn(50)
}
err = sql.db.Insert("stroeDiscount", &thing)
if err != nil {
@ -826,6 +826,10 @@ func (sql *fishdb) selectCanSalesFishFor(uid int64, sales int) int {
if time.Now().Day() != time.Unix(userInfo.Duration, 0).Day() {
userInfo.Duration = time.Now().Unix()
userInfo.SalesFish = 0
err := sql.db.Insert("buff", &userInfo)
if err != nil {
return residue
}
}
maxSales := 100 - userInfo.SalesFish
if maxSales < 0 {