Files
bl/modules/player/controller/robot/egg.go
xinian 58f0f98262
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
fix: 修复扭蛋参数检查逻辑错误
2026-03-27 18:02:08 +08:00

68 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package robot
import (
"blazing/common/data/xmlres"
base "blazing/modules/base/service"
config "blazing/modules/config/service"
"blazing/modules/player/model"
"blazing/modules/player/service"
"strings"
"github.com/gogf/gf/v2/util/gconv"
"github.com/gogf/gf/v2/util/grand"
zero "github.com/wdvxdr1123/ZeroBot"
"github.com/wdvxdr1123/ZeroBot/message"
)
func init() {
zero.OnCommand("扭蛋").
Handle(func(ctx *zero.Ctx) {
msgs := strings.Fields(ctx.Event.Message.String())
if len(msgs) > 1 {
count := gconv.Int(msgs[1])
if count > 10 {
count = 10
}
user := base.NewBaseSysUserService().GetQQ(ctx.Event.Sender.ID)
if user == nil {
ctx.Send("未绑定请个人中心复制token发给机器人")
return
}
itemservice := service.NewItemService(uint32(user.ID))
havs := itemservice.CheakItem(400501)
if havs < int64(count) {
ctx.Send("扭蛋币不足,当前扭蛋币数量:" + gconv.String(havs))
return
}
var buf strings.Builder
buf.WriteString("当前扭蛋币数量:" + gconv.String(havs))
if grand.Meet(int(count), 100) {
r := config.NewPetRewardService().GetEgg()
newPet := model.GenPetInfo(int(r.MonID), int(r.DV), int(r.Nature), int(r.Effect), int(r.Lv), nil, 0)
if grand.Meet(1, 500) {
newPet.RandomByWeightShiny()
}
service.NewPetService(uint32(user.ID)).PetAdd(newPet, 0)
buf.WriteString("恭喜你获得" + xmlres.PetMAP[int(newPet.ID)].DefName + "\n")
}
items := config.NewItemService().GetEgg(int(count))
for _, item := range items {
itemservice.UPDATE(uint32(item.ItemId), int(item.ItemCnt))
buf.WriteString("恭喜你获得" + xmlres.ItemsMAP[int(item.ItemId)].Name + ":" + gconv.String(item.ItemCnt) + "\n")
}
itemservice.UPDATE(400501, int(-count))
ctx.SendChain(message.At(ctx.Event.Sender.ID), message.Reply(ctx.Event.MessageID), message.Text(buf.String()))
}
})
}