diff --git a/bin/robot001.txt b/bin/robot001.txt index e1ff0ccec..6def53335 100644 --- a/bin/robot001.txt +++ b/bin/robot001.txt @@ -1,21 +1,25 @@ 机器人总数: 1 成功数量: 1 失败数量: 0 -消息总吞吐量: 47 +消息总吞吐量: 79 ---消息压测详情---------------------------------------------------------------------------------------------------- -消息名:wtask.battlefinish 请求次数:2 耗时最小:5 ms 耗时最大:6 ms 平均耗时:5.50 ms 中位耗时:5.50 ms -消息名:sys.funcgetlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms +消息名:gm.cmd 请求次数:2 耗时最小:0 ms 耗时最大:5 ms 平均耗时:2.50 ms 中位耗时:2.50 ms +消息名:hero.drawcard 请求次数:1 耗时最小:76 ms 耗时最大:76 ms 平均耗时:76.00ms 中位耗时:76.00ms 消息名:wtask.info 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms -消息名:wtask.completecondi 请求次数:2 耗时最小:2 ms 耗时最大:4 ms 平均耗时:3.00 ms 中位耗时:3.00 ms -消息名:wtask.battlestart 请求次数:2 耗时最小:3 ms 耗时最大:5 ms 平均耗时:4.00 ms 中位耗时:4.00 ms -消息名:gm.cmd 请求次数:2 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.50 ms 中位耗时:0.50 ms -消息名:wtask.finish 请求次数:5 耗时最小:6 ms 耗时最大:16 ms 平均耗时:9.40 ms 中位耗时:8.00 ms -消息名:chat.send 请求次数:10 耗时最小:0 ms 耗时最大:3 ms 平均耗时:1.10 ms 中位耗时:1.00 ms -消息名:shop.getlist 请求次数:10 耗时最小:1 ms 耗时最大:12 ms 平均耗时:2.70 ms 中位耗时:2.00 ms -消息名:hero.list 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms -消息名:hero.talentlist 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms -消息名:equipment.getlist 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms -消息名:items.getlist 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms -消息名:user.login 请求次数:1 耗时最小:827 ms 耗时最大:827 ms 平均耗时:827.00ms 中位耗时:827.00ms -消息名:user.create 请求次数:1 耗时最小:6 ms 耗时最大:6 ms 平均耗时:6.00 ms 中位耗时:6.00 ms -消息名:wtask.accept 请求次数:6 耗时最小:1 ms 耗时最大:4 ms 平均耗时:3.33 ms 中位耗时:4.00 ms +消息名:chat.send 请求次数:10 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.10 ms 中位耗时:0.00 ms +消息名:hero.talentlist 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms +消息名:equipment.getlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms +消息名:user.login 请求次数:1 耗时最小:982 ms 耗时最大:982 ms 平均耗时:982.00ms 中位耗时:982.00ms +消息名:viking.challenge 请求次数:10 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.70 ms 中位耗时:1.00 ms +消息名:items.getlist 请求次数:1 耗时最小:6 ms 耗时最大:6 ms 平均耗时:6.00 ms 中位耗时:6.00 ms +消息名:horoscope.info 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms +消息名:sys.funcgetlist 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms +消息名:arena.matche 请求次数:10 耗时最小:3 ms 耗时最大:6 ms 平均耗时:3.80 ms 中位耗时:3.50 ms +消息名:user.create 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms +消息名:hero.list 请求次数:1 耗时最小:14 ms 耗时最大:14 ms 平均耗时:14.00ms 中位耗时:14.00ms +消息名:arena.challenge 请求次数:10 耗时最小:1 ms 耗时最大:6 ms 平均耗时:2.80 ms 中位耗时:2.50 ms +消息名:arena.challengeover 请求次数:5 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.20 ms 中位耗时:0.00 ms +消息名:viking.getlist 请求次数:10 耗时最小:0 ms 耗时最大:0 ms 平均耗时:0.00 ms 中位耗时:0.00 ms +消息名:shop.buy 请求次数:10 耗时最小:2 ms 耗时最大:5 ms 平均耗时:2.40 ms 中位耗时:2.00 ms +消息名:arena.info 请求次数:1 耗时最小:18 ms 耗时最大:18 ms 平均耗时:18.00ms 中位耗时:18.00ms +消息名:shop.getlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms diff --git a/modules/robot/configure.go b/modules/robot/configure.go index 1f1e43969..8d351d5f2 100644 --- a/modules/robot/configure.go +++ b/modules/robot/configure.go @@ -30,6 +30,8 @@ const ( game_playerlv = "game_playerlv.json" hero_awaken = "game_heroawaken.json" + + game_horoscope = "game_horoscope.json" //星阵图 ) type configureComp struct { @@ -51,6 +53,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp configure.RegisterConfigure(hero_talent, cfg.NewGameHeroTalent, nil) configure.RegisterConfigure(game_playerlv, cfg.NewGamePlayerlv, nil) configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, nil) // 觉醒 + configure.RegisterConfigure(game_horoscope, cfg.NewGameHoroscope, nil) return } diff --git a/modules/robot/modulerobot_arena.go b/modules/robot/modulerobot_arena.go index 124c1b75c..d19fa4fb4 100644 --- a/modules/robot/modulerobot_arena.go +++ b/modules/robot/modulerobot_arena.go @@ -44,10 +44,7 @@ func (this *ModuleRobot_Arena) OncePipeline(robot IRobot) (err error) { err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) return } - if _, errdata = robot.SendMessage("arena", "matche", &pb.ArenaMatcheReq{}); errdata != nil { - err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) - return - } + return } @@ -60,7 +57,10 @@ func (this *ModuleRobot_Arena) DoPipeline(robot IRobot) (err error) { player *pb.ArenaPlayer resp proto.Message ) - + if _, errdata = robot.SendMessage("arena", "matche", &pb.ArenaMatcheReq{}); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } heromodule = robot.GetModule(comm.ModuleHero).(*ModuleRobot_Hero) heros = heromodule.getbattlehero() for _, v := range this.players { @@ -83,7 +83,7 @@ func (this *ModuleRobot_Arena) DoPipeline(robot IRobot) (err error) { Aiintegral: player.Integral, Ainame: player.Name, Report: &pb.BattleReport{ - Info: resp.(*pb.MainlineChallengeResp).Info, + Info: resp.(*pb.ArenaChallengeResp).Info, WinSide: 1, }}); errdata != nil { err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) diff --git a/modules/robot/modulerobot_gm.go b/modules/robot/modulerobot_gm.go index 59ed39b96..443d6c90c 100644 --- a/modules/robot/modulerobot_gm.go +++ b/modules/robot/modulerobot_gm.go @@ -24,11 +24,6 @@ func (this *ModuleRobot_GM) Receive(robot IRobot, stype string, message proto.Me return } func (this *ModuleRobot_GM) OncePipeline(robot IRobot) (err error) { - return -} - -//机器人执行流 -func (this *ModuleRobot_GM) DoPipeline(robot IRobot) (err error) { var ( errdata *pb.ErrorData ) @@ -43,6 +38,12 @@ func (this *ModuleRobot_GM) DoPipeline(robot IRobot) (err error) { return } +//机器人执行流 +func (this *ModuleRobot_GM) DoPipeline(robot IRobot) (err error) { + + return +} + //做任务 func (this *ModuleRobot_GM) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { diff --git a/modules/robot/modulerobot_horoscope.go b/modules/robot/modulerobot_horoscope.go new file mode 100644 index 000000000..599b889df --- /dev/null +++ b/modules/robot/modulerobot_horoscope.go @@ -0,0 +1,91 @@ +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_Horoscope struct { + Info *pb.DBHoroscope +} + +func (this *ModuleRobot_Horoscope) Init() (err error) { + + return +} + +//接收到消息 +func (this *ModuleRobot_Horoscope) Receive(robot IRobot, stype string, message proto.Message) (err error) { + switch stype { + case "info": + resp := message.(*pb.HoroscopeInfoResp) + this.Info = resp.Info + break + } + return +} + +func (this *ModuleRobot_Horoscope) OncePipeline(robot IRobot) (err error) { + var ( + errdata *pb.ErrorData + ) + if _, errdata = robot.SendMessage("horoscope", "info", &pb.HoroscopeInfoReq{}); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + + return +} + +//机器人执行流 +func (this *ModuleRobot_Horoscope) DoPipeline(robot IRobot) (err error) { + var ( + errdata *pb.ErrorData + conf *cfg.GameHoroscopeData + ) + if conf, err = this.findcanupnode(); err != nil { + return + } + if _, errdata = robot.SendMessage("horoscope", "upgrade", &pb.HoroscopeUpgradeReq{Nid: conf.Id}); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + return +} + +//做任务 +func (this *ModuleRobot_Horoscope) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { + + return +} + +func (this *ModuleRobot_Horoscope) findcanupnode() (conf *cfg.GameHoroscopeData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = configure.GetConfigure(game_horoscope); err != nil { + return + } else { + for _, v := range v.(*cfg.GameHoroscope).GetDataList() { + ok = true + for _, v := range v.Front { + if _, ok = this.Info.Nodes[v]; !ok { + break + } + } + if ok { + conf = v + return + } + } + err = fmt.Errorf("no fund") + return + } +} diff --git a/modules/robot/modulerobot_item.go b/modules/robot/modulerobot_item.go index 1bf2a13c5..409df4ae6 100644 --- a/modules/robot/modulerobot_item.go +++ b/modules/robot/modulerobot_item.go @@ -39,11 +39,6 @@ func (this *ModuleRobot_Item) Receive(robot IRobot, stype string, message proto. return } func (this *ModuleRobot_Item) OncePipeline(robot IRobot) (err error) { - return -} - -//机器人执行流 -func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) { var ( errdata *pb.ErrorData ) @@ -54,6 +49,12 @@ func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) { return } +//机器人执行流 +func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) { + + return +} + //做任务 func (this *ModuleRobot_Item) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { var ( diff --git a/modules/robot/modulerobot_shop.go b/modules/robot/modulerobot_shop.go index 92dec3086..6c0377608 100644 --- a/modules/robot/modulerobot_shop.go +++ b/modules/robot/modulerobot_shop.go @@ -31,6 +31,15 @@ func (this *ModuleRobot_Shop) Receive(robot IRobot, stype string, message proto. return } func (this *ModuleRobot_Shop) OncePipeline(robot IRobot) (err error) { + var ( + errdata *pb.ErrorData + ) + if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{ + SType: pb.ShopType_DiamondShop, + }); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } return } @@ -41,13 +50,19 @@ func (this *ModuleRobot_Shop) DoPipeline(robot IRobot) (err error) { usermodule *ModuleRobot_User ) usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User) - if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{ - SType: pb.ShopType_DiamondShop, - }); errdata != nil { - err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) - return + for _, v := range this.goods[pb.ShopType_GoldShop] { + if v.LeftBuyNum > 0 && usermodule.user.Gold >= int64(v.Consume[0].N) { + if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{ + ShopType: pb.ShopType_GoldShop, + Gid: v.Gid, + BuyNum: 1, + }); errdata != nil { + err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) + return + } + break + } } - for _, v := range this.goods[pb.ShopType_DiamondShop] { if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) { if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{ diff --git a/modules/robot/modulerobot_user.go b/modules/robot/modulerobot_user.go index dc95cb1f8..1ede310d5 100644 --- a/modules/robot/modulerobot_user.go +++ b/modules/robot/modulerobot_user.go @@ -34,11 +34,6 @@ func (this *ModuleRobot_User) Receive(robot IRobot, stype string, message proto. return } func (this *ModuleRobot_User) OncePipeline(robot IRobot) (err error) { - return -} - -//机器人执行流 -func (this *ModuleRobot_User) DoPipeline(robot IRobot) (err error) { var ( errdata *pb.ErrorData ) @@ -67,6 +62,12 @@ func (this *ModuleRobot_User) DoPipeline(robot IRobot) (err error) { return } +//机器人执行流 +func (this *ModuleRobot_User) DoPipeline(robot IRobot) (err error) { + + return +} + //做任务 func (this *ModuleRobot_User) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) { diff --git a/modules/robot/robot.go b/modules/robot/robot.go index b2334bb32..2f4682db9 100644 --- a/modules/robot/robot.go +++ b/modules/robot/robot.go @@ -69,7 +69,7 @@ func (this *Robot) Init(addr string, client IClient) (err error) { this.modules[comm.ModuleViking] = new(ModuleRobot_Viking) this.modules[comm.ModuleChat] = new(ModuleRobot_Chat) this.modules[comm.ModuleShop] = new(ModuleRobot_Shop) - + this.modules[comm.ModuleHoroscope] = new(ModuleRobot_Horoscope) for _, v := range this.modules { v.Init() } @@ -248,6 +248,13 @@ func (this *Robot) run() { module IModuleRobot err error ) + for _, v := range this.pipeline { + module = this.modules[core.M_Modules(v.Module)] + if err = module.OncePipeline(this); err != nil { + log.Error("[机器人 初始执行错误]", log.Field{Key: "Account", Value: this.account}, log.Field{Key: "module", Value: v}, log.Field{Key: "err", Value: err.Error()}) + break + } + } for this.cycle { this.cycle = false @@ -256,9 +263,10 @@ func (this *Robot) run() { module = this.modules[core.M_Modules(v.Module)] if err = module.DoPipeline(this); err != nil { if this.debug { - log.Debug("[机器人 执行异常]", log.Field{Key: "Account", Value: this.account}, log.Field{Key: "module", Value: v}, log.Field{Key: "err", Value: err.Error()}) + log.Error("[机器人 执行异常]", log.Field{Key: "Account", Value: this.account}, log.Field{Key: "module", Value: v}, log.Field{Key: "err", Value: err.Error()}) } if !v.ErrNotStop { + log.Debug("[机器人 退出循环]") break } }