上传机器人代码
This commit is contained in:
parent
255bcb30e7
commit
ff2243d413
@ -10,12 +10,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
gameWorldTask = "game_worldtask.json"
|
gameWorldTask = "game_worldtask.json"
|
||||||
gameWorldtaskBattle = "game_worldbattle.json"
|
gameWorldtaskBattle = "game_worldbattle.json"
|
||||||
game_buriedcondi = "game_buriedcondi.json"
|
game_buriedcondi = "game_buriedcondi.json"
|
||||||
game_mainstage = "game_mainstage.json" //主线表
|
game_mainstage = "game_mainstage.json" //主线表
|
||||||
game_equip = "game_equip.json" //装备信息表
|
game_equip = "game_equip.json" //装备信息表
|
||||||
equip_intensify = "game_equipintensify.json" //装备等级消耗表
|
game_equipintensify = "game_equipintensify.json" //装备等级消耗表
|
||||||
|
game_equipenchanting = "game_equipenchanting.json" //装备附魔
|
||||||
// gameWorldAll = "game_worldall.json"
|
// gameWorldAll = "game_worldall.json"
|
||||||
// gameburiedCond = "game_buriedcondi.json"
|
// gameburiedCond = "game_buriedcondi.json"
|
||||||
// gamerdtasknpc = "game_rdtasknpc.json"
|
// gamerdtasknpc = "game_rdtasknpc.json"
|
||||||
@ -38,7 +39,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, nil)
|
configure.RegisterConfigure(game_buriedcondi, cfg.NewGameBuriedCondi, nil)
|
||||||
configure.RegisterConfigure(game_mainstage, cfg.NewGameMainStage, nil)
|
configure.RegisterConfigure(game_mainstage, cfg.NewGameMainStage, nil)
|
||||||
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, nil)
|
configure.RegisterConfigure(game_equip, cfg.NewGameEquip, nil)
|
||||||
configure.RegisterConfigure(equip_intensify, cfg.NewGameEquipIntensify, nil)
|
configure.RegisterConfigure(game_equipintensify, cfg.NewGameEquipIntensify, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,11 @@ func (this *ModuleRobot_Equipment) DoTask(robot IRobot, taskconf *cfg.GameWorldT
|
|||||||
err = errors.New(errdata.Message)
|
err = errors.New(errdata.Message)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
case comm.Rtype94: //附魔
|
||||||
|
if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "equipment", "ench", &pb.EquipmentEnchReq{}); errdata != nil {
|
||||||
|
err = errors.New(errdata.Message)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -174,13 +179,12 @@ func (this *ModuleRobot_Equipment) getGameEquipData(cid string) (conf *cfg.GameE
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 读取条件任务id配置
|
// 读取条件任务id配置
|
||||||
// 获取武器等级消耗表
|
|
||||||
func (this *ModuleRobot_Equipment) getEquipmentMaxIntensifyConfigure(etype, star int32) (conf *cfg.GameEquipIntensifyData, err error) {
|
func (this *ModuleRobot_Equipment) getEquipmentMaxIntensifyConfigure(etype, star int32) (conf *cfg.GameEquipIntensifyData, err error) {
|
||||||
var (
|
var (
|
||||||
v interface{}
|
v interface{}
|
||||||
lv int32
|
lv int32
|
||||||
)
|
)
|
||||||
if v, err = configure.GetConfigure(equip_intensify); err != nil {
|
if v, err = configure.GetConfigure(game_equipintensify); err != nil {
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
for _, v1 := range v.(*cfg.GameEquipIntensify).GetDataList() {
|
for _, v1 := range v.(*cfg.GameEquipIntensify).GetDataList() {
|
||||||
@ -196,3 +200,16 @@ func (this *ModuleRobot_Equipment) getEquipmentMaxIntensifyConfigure(etype, star
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取附魔数据
|
||||||
|
func (this *ModuleRobot_Equipment) getEquipenchantings() (confs []*cfg.GameEquipEnchantingData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
)
|
||||||
|
if v, err = configure.GetConfigure(game_equipenchanting); err != nil {
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
confs = v.(*cfg.GameEquipEnchanting).GetDataList()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
66
modules/robot/modulerobot_item.go
Normal file
66
modules/robot/modulerobot_item.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package robot
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
//用户模块 机器人
|
||||||
|
type ModuleRobot_Item struct {
|
||||||
|
items map[string]*pb.DB_UserItemData
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *ModuleRobot_Item) Init() (err error) {
|
||||||
|
this.items = make(map[string]*pb.DB_UserItemData)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//接收到消息
|
||||||
|
func (this *ModuleRobot_Item) Receive(robot IRobot, stype string, message proto.Message) (err error) {
|
||||||
|
switch stype {
|
||||||
|
case "list":
|
||||||
|
resp := message.(*pb.ItemsGetlistResp)
|
||||||
|
for _, v := range resp.Grids {
|
||||||
|
this.items[v.GridId] = v
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "change":
|
||||||
|
resp := message.(*pb.ItemsChangePush)
|
||||||
|
for _, v := range resp.Grids {
|
||||||
|
this.items[v.GridId] = v
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//机器人执行流
|
||||||
|
func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) {
|
||||||
|
var (
|
||||||
|
errdata *pb.ErrorData
|
||||||
|
)
|
||||||
|
if _, errdata = robot.SendMessage("item", "list", &pb.ItemsGetlistReq{}); errdata != nil {
|
||||||
|
err = errors.New(errdata.Message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//做任务
|
||||||
|
func (this *ModuleRobot_Item) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
|
||||||
|
var (
|
||||||
|
errdata *pb.ErrorData
|
||||||
|
)
|
||||||
|
switch comm.TaskType(condconf.Type) {
|
||||||
|
case comm.Rtype14:
|
||||||
|
if _, errdata = robot.SendTaskMessage(taskconf.Key, condconf.Id, "hero", "drawcard", &pb.HeroDrawCardReq{DrawType: 2, DrawCount: 1, Consume: 0}); errdata != nil {
|
||||||
|
err = errors.New(errdata.Message)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
@ -129,7 +129,7 @@ locp:
|
|||||||
module = comm.ModulePractice
|
module = comm.ModulePractice
|
||||||
case comm.Rtype61:
|
case comm.Rtype61:
|
||||||
module = comm.ModuleMainline
|
module = comm.ModuleMainline
|
||||||
case comm.Rtype5:
|
case comm.Rtype5, comm.Rtype92, comm.Rtype94, comm.Rtype96:
|
||||||
module = comm.ModuleEquipment
|
module = comm.ModuleEquipment
|
||||||
default:
|
default:
|
||||||
log.Error("[Robot DoTask]", log.Field{Key: "ctype", Value: cconf.Type}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: "Not Achieved !"})
|
log.Error("[Robot DoTask]", log.Field{Key: "ctype", Value: cconf.Type}, log.Field{Key: "conld", Value: cconf.Id}, log.Field{Key: "err", Value: "Not Achieved !"})
|
||||||
|
@ -47,6 +47,7 @@ func (this *Robot) Init(addr string, client IClient) (err error) {
|
|||||||
this.modules[comm.ModuleSys] = new(ModuleRobot_Sys)
|
this.modules[comm.ModuleSys] = new(ModuleRobot_Sys)
|
||||||
this.modules[comm.ModuleHero] = new(ModuleRobot_Hero)
|
this.modules[comm.ModuleHero] = new(ModuleRobot_Hero)
|
||||||
this.modules[comm.ModuleEquipment] = new(ModuleRobot_Equipment)
|
this.modules[comm.ModuleEquipment] = new(ModuleRobot_Equipment)
|
||||||
|
this.modules[comm.ModuleItems] = new(ModuleRobot_Item)
|
||||||
this.modules[comm.ModuleWtask] = new(ModuleRobot_WTask)
|
this.modules[comm.ModuleWtask] = new(ModuleRobot_WTask)
|
||||||
this.modules[comm.ModulePractice] = new(ModuleRobot_Practice)
|
this.modules[comm.ModulePractice] = new(ModuleRobot_Practice)
|
||||||
this.modules[comm.ModuleMainline] = new(ModuleRobot_MainLine)
|
this.modules[comm.ModuleMainline] = new(ModuleRobot_MainLine)
|
||||||
|
Loading…
Reference in New Issue
Block a user