65 lines
1.4 KiB
Go
65 lines
1.4 KiB
Go
package robot
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"go_dreamfactory/pb"
|
|
"go_dreamfactory/sys/configure"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//用户模块 机器人
|
|
type ModuleRobot_Combat struct {
|
|
}
|
|
|
|
func (this *ModuleRobot_Combat) Init() (err error) {
|
|
|
|
return
|
|
}
|
|
|
|
//接收到消息
|
|
func (this *ModuleRobot_Combat) Receive(robot IRobot, stype string, message proto.Message) (err error) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *ModuleRobot_Combat) OncePipeline(robot IRobot) (err error) {
|
|
var (
|
|
errdata *pb.ErrorData
|
|
conf *cfg.GameCombatLevelData
|
|
)
|
|
conf = this.GetCombatLevelData()[0]
|
|
if _, errdata = robot.SendMessage("combat", "ask", &pb.CombatAskReq{Level: conf.Id}); errdata != nil {
|
|
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
//机器人执行流
|
|
func (this *ModuleRobot_Combat) DoPipeline(robot IRobot) (err error) {
|
|
|
|
return
|
|
}
|
|
|
|
//做任务
|
|
func (this *ModuleRobot_Combat) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
|
|
|
|
return
|
|
}
|
|
|
|
func (this *ModuleRobot_Combat) GetCombatLevelData() (data []*cfg.GameCombatLevelData) {
|
|
data = make([]*cfg.GameCombatLevelData, 0)
|
|
if v, err := configure.GetConfigure(game_combatlevel); err == nil {
|
|
if _configure, ok := v.(*cfg.GameCombatLevel); ok {
|
|
for _, v := range _configure.GetDataList() {
|
|
data = append(data, v)
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|