From f6ef3264950596ac58c0f49f987ebdddea13e492 Mon Sep 17 00:00:00 2001 From: CUU_rooooo! <67186678+vatebur@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:40:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(mcfish):=20=E9=B1=BC=E7=AB=BFNumber?= =?UTF-8?q?=E5=A4=A7=E4=BA=8E1=EF=BC=8C=E5=90=88=E6=88=90=E6=97=B6?= =?UTF-8?q?=E5=B0=91=E9=B1=BC=E7=AB=BF=E7=9A=84=E6=83=85=E5=86=B5=20(#947)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 合成鱼竿未考虑鱼竿articles.Number>1的情况。 如果要修复这个问题,需要重构这块代码 所以梭哈功能直接按照原有思路,生成多个Number=1的鱼竿。 --- plugin/mcfish/pole.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugin/mcfish/pole.go b/plugin/mcfish/pole.go index 3b4e1319..0b89cdb0 100644 --- a/plugin/mcfish/pole.go +++ b/plugin/mcfish/pole.go @@ -383,7 +383,7 @@ func init() { }) } list := []int{0, 1, 2} - // 可以用于合成的鱼竿数量(取3的倍数) + // 可以用于合成的鱼竿数量(取3的倍数),note:此处未对article.Number>1的情况做处理 upgradeNum := (len(articles) / 3) * 3 check := false if len(articles) > 3 { @@ -485,17 +485,22 @@ func init() { Duration: time.Now().Unix(), Type: "pole", Name: thingName, - Number: upgradeNum / 3, + Number: 1, Other: attribute, } - err = dbdata.updateUserThingInfo(uid, newthing) - if err != nil { - ctx.SendChain(message.Text("[ERROR at pole.go.12]:", err)) - return + // 代码未对article.Number>1的情况做处理,直接生成多个Number=1的鱼竿 + for i := 0; i < upgradeNum/3; i++ { + // 使用时间戳作为主键,增加固定值避免主键冲突 + newthing.Duration += int64(i * 10) + err = dbdata.updateUserThingInfo(uid, newthing) + if err != nil { + ctx.SendChain(message.Text("[ERROR at pole.go.12]:", err)) + return + } } ctx.Send( message.ReplyWithMessage(ctx.Event.MessageID, - message.Text("成功合成", upgradeNum/3, "个", thingName, "\n属性: ", attribute), + message.Text("成功合成:", upgradeNum/3, "个", thingName, "\n属性: ", attribute), ), ) })