go_dreamfactory/modules/robot/modulerobot_smithy.go
2023-09-08 15:11:30 +08:00

83 lines
1.9 KiB
Go

package robot
import (
"errors"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
)
//用户模块 机器人
type ModuleRobot_Smithy struct {
smithy *pb.DBStove
}
func (this *ModuleRobot_Smithy) Init() (err error) {
this.smithy = &pb.DBStove{
Id: "",
Uid: "",
Lv: 0,
Data: map[int32]*pb.Mastery{},
Skill: map[int32]int32{},
Forge: map[int32]int32{},
Temperature: 0,
RecoveTime: 0,
Hit: map[int32]int32{},
}
return
}
//接收到消息
func (this *ModuleRobot_Smithy) Receive(robot IRobot, stype string, message proto.Message) (err error) {
switch stype {
case "list":
resp := message.(*pb.SmithyGetStoveInfoResp)
this.smithy = resp.Data
break
}
return
}
func (this *ModuleRobot_Smithy) OncePipeline(robot IRobot) (err error) {
return
}
//机器人执行流
func (this *ModuleRobot_Smithy) DoPipeline(robot IRobot) (err error) {
var (
errdata *pb.ErrorData
)
if _, errdata = robot.SendMessage("smithy", "getstoveinfo", &pb.SmithyGetStoveInfoReq{}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
return
}
//做任务
func (this *ModuleRobot_Smithy) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
var (
errdata *pb.ErrorData
)
switch comm.TaskType(condconf.Type) {
case comm.Rtype51:
// 在铁匠铺中获得xx件xx星装备
if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "drawcard",
&pb.SmithyForgeEquipReq{
ReelId: condconf.Filter[0],
Lava: 0,
Quality: 0,
SuiteId: 0,
Position: 0,
Hit: map[int32]int32{},
Count: 1,
}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return
}
}
return
}