optimize(mcfish): 限制鱼贩的垄断 (#992)

This commit is contained in:
方柳煜
2024-10-05 20:10:30 +08:00
committed by GitHub
parent f3a841fc60
commit 95451f96d8
2 changed files with 84 additions and 13 deletions

View File

@@ -85,6 +85,18 @@ func init() {
if number == 0 || strings.Contains(thingName, "竿") {
number = 1
}
if checkIsFish(thingName) {
residue, err := dbdata.checkCanSalesFishFor(uid, number)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:", err))
return
}
if residue <= 0 {
ctx.SendChain(message.Text("今天你已经超出了鱼交易数量上限,明天再来买鱼吧"))
return
}
number = residue
}
articles, err := dbdata.getUserThingInfo(uid, thingName)
if err != nil {
ctx.SendChain(message.Text("[ERROR at store.go.5]:", err))
@@ -157,7 +169,9 @@ func init() {
maintenance, _ := strconv.Atoi(poleInfo[1])
induceLevel, _ := strconv.Atoi(poleInfo[2])
favorLevel, _ := strconv.Atoi(poleInfo[3])
pice = (priceList[thingName] - (durationList[thingName] - durable) - maintenance*2 + induceLevel*600 + favorLevel*1800) * discountList[thingName] / 100
pice = (priceList[thingName] - (durationList[thingName] - durable) - maintenance*2 +
induceLevel*600*discountList["诱钓"]/100 +
favorLevel*1800*discountList["海之眷顾"]/100) * discountList[thingName] / 100
} else {
pice = priceList[thingName] * discountList[thingName] / 100
}
@@ -399,7 +413,7 @@ func init() {
return
}
if buytimes <= 0 {
ctx.SendChain(message.Text("出售次数已达到上限,明天再来购买吧"))
ctx.SendChain(message.Text("购买次数已达到上限,明天再来购买吧"))
return
}
thingName := ctx.State["regex_matched"].([]string)[1]
@@ -407,6 +421,18 @@ func init() {
if number == 0 {
number = 1
}
if checkIsFish(thingName) {
residue, err := dbdata.checkCanSalesFishFor(uid, number)
if err != nil {
ctx.SendChain(message.Text("[ERROR]:", err))
return
}
if residue <= 0 {
ctx.SendChain(message.Text("今天你已经超出了鱼交易数量上限,明天再来买鱼吧"))
return
}
number = residue
}
thingInfos, err := dbdata.getStoreThingInfo(thingName)
if err != nil {
ctx.SendChain(message.Text("[ERROR at store.go.11]:", err))
@@ -448,7 +474,9 @@ func init() {
maintenance, _ := strconv.Atoi(poleInfo[1])
induceLevel, _ := strconv.Atoi(poleInfo[2])
favorLevel, _ := strconv.Atoi(poleInfo[3])
thingPice := (priceList[info.Name] - (durationList[info.Name] - durable) - maintenance*2 + induceLevel*600 + favorLevel*1800) * discountList[info.Name] / 100
thingPice := (priceList[info.Name] - (durationList[info.Name] - durable) - maintenance*2 +
induceLevel*600*discountList["诱钓"]/100 +
favorLevel*1800*discountList["海之眷顾"]/100) * discountList[info.Name] / 100
pice = append(pice, thingPice)
} else {
thingPice := priceList[info.Name] * discountList[info.Name] / 100