上传机器人

This commit is contained in:
liwei1dao 2023-09-08 15:57:57 +08:00
parent 05c56d6e00
commit 147a02d25c
9 changed files with 169 additions and 45 deletions

View File

@ -1,21 +1,25 @@
机器人总数: 1 机器人总数: 1
成功数量: 1 成功数量: 1
失败数量: 0 失败数量: 0
消息总吞吐量: 47 消息总吞吐量: 79
---消息压测详情---------------------------------------------------------------------------------------------------- ---消息压测详情----------------------------------------------------------------------------------------------------
消息名:wtask.battlefinish 请求次数:2 耗时最小:5 ms 耗时最大:6 ms 平均耗时:5.50 ms 中位耗时:5.50 ms 消息名:gm.cmd 请求次数:2 耗时最小:0 ms 耗时最大:5 ms 平均耗时:2.50 ms 中位耗时:2.50 ms
消息名:sys.funcgetlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 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.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 消息名:chat.send 请求次数:10 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.10 ms 中位耗时:0.00 ms
消息名:wtask.battlestart 请求次数:2 耗时最小:3 ms 耗时最大:5 ms 平均耗时:4.00 ms 中位耗时:4.00 ms 消息名:hero.talentlist 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms
消息名:gm.cmd 请求次数:2 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.50 ms 中位耗时:0.50 ms 消息名:equipment.getlist 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms
消息名:wtask.finish 请求次数:5 耗时最小:6 ms 耗时最大:16 ms 平均耗时:9.40 ms 中位耗时:8.00 ms 消息名:user.login 请求次数:1 耗时最小:982 ms 耗时最大:982 ms 平均耗时:982.00ms 中位耗时:982.00ms
消息名:chat.send 请求次数:10 耗时最小:0 ms 耗时最大:3 ms 平均耗时:1.10 ms 中位耗时:1.00 ms 消息名:viking.challenge 请求次数:10 耗时最小:0 ms 耗时最大:1 ms 平均耗时:0.70 ms 中位耗时:1.00 ms
消息名:shop.getlist 请求次数:10 耗时最小:1 ms 耗时最大:12 ms 平均耗时:2.70 ms 中位耗时:2.00 ms 消息名:items.getlist 请求次数:1 耗时最小:6 ms 耗时最大:6 ms 平均耗时:6.00 ms 中位耗时:6.00 ms
消息名:hero.list 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms 消息名:horoscope.info 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms
消息名:hero.talentlist 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms 消息名:sys.funcgetlist 请求次数:1 耗时最小:3 ms 耗时最大:3 ms 平均耗时:3.00 ms 中位耗时:3.00 ms
消息名:equipment.getlist 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms 消息名:arena.matche 请求次数:10 耗时最小:3 ms 耗时最大:6 ms 平均耗时:3.80 ms 中位耗时:3.50 ms
消息名:items.getlist 请求次数:1 耗时最小:1 ms 耗时最大:1 ms 平均耗时:1.00 ms 中位耗时:1.00 ms 消息名:user.create 请求次数:1 耗时最小:2 ms 耗时最大:2 ms 平均耗时:2.00 ms 中位耗时:2.00 ms
消息名:user.login 请求次数:1 耗时最小:827 ms 耗时最大:827 ms 平均耗时:827.00ms 中位耗时:827.00ms 消息名:hero.list 请求次数:1 耗时最小:14 ms 耗时最大:14 ms 平均耗时:14.00ms 中位耗时:14.00ms
消息名:user.create 请求次数:1 耗时最小:6 ms 耗时最大:6 ms 平均耗时:6.00 ms 中位耗时:6.00 ms 消息名:arena.challenge 请求次数:10 耗时最小:1 ms 耗时最大:6 ms 平均耗时:2.80 ms 中位耗时:2.50 ms
消息名:wtask.accept 请求次数:6 耗时最小:1 ms 耗时最大:4 ms 平均耗时:3.33 ms 中位耗时:4.00 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

View File

@ -30,6 +30,8 @@ const (
game_playerlv = "game_playerlv.json" game_playerlv = "game_playerlv.json"
hero_awaken = "game_heroawaken.json" hero_awaken = "game_heroawaken.json"
game_horoscope = "game_horoscope.json" //星阵图
) )
type configureComp struct { 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(hero_talent, cfg.NewGameHeroTalent, nil)
configure.RegisterConfigure(game_playerlv, cfg.NewGamePlayerlv, nil) configure.RegisterConfigure(game_playerlv, cfg.NewGamePlayerlv, nil)
configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, nil) // 觉醒 configure.RegisterConfigure(hero_awaken, cfg.NewGameHeroAwaken, nil) // 觉醒
configure.RegisterConfigure(game_horoscope, cfg.NewGameHoroscope, nil)
return return
} }

View File

@ -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)) err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return 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 return
} }
@ -60,7 +57,10 @@ func (this *ModuleRobot_Arena) DoPipeline(robot IRobot) (err error) {
player *pb.ArenaPlayer player *pb.ArenaPlayer
resp proto.Message 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) heromodule = robot.GetModule(comm.ModuleHero).(*ModuleRobot_Hero)
heros = heromodule.getbattlehero() heros = heromodule.getbattlehero()
for _, v := range this.players { for _, v := range this.players {
@ -83,7 +83,7 @@ func (this *ModuleRobot_Arena) DoPipeline(robot IRobot) (err error) {
Aiintegral: player.Integral, Aiintegral: player.Integral,
Ainame: player.Name, Ainame: player.Name,
Report: &pb.BattleReport{ Report: &pb.BattleReport{
Info: resp.(*pb.MainlineChallengeResp).Info, Info: resp.(*pb.ArenaChallengeResp).Info,
WinSide: 1, WinSide: 1,
}}); errdata != nil { }}); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))

View File

@ -24,11 +24,6 @@ func (this *ModuleRobot_GM) Receive(robot IRobot, stype string, message proto.Me
return return
} }
func (this *ModuleRobot_GM) OncePipeline(robot IRobot) (err error) { func (this *ModuleRobot_GM) OncePipeline(robot IRobot) (err error) {
return
}
//机器人执行流
func (this *ModuleRobot_GM) DoPipeline(robot IRobot) (err error) {
var ( var (
errdata *pb.ErrorData errdata *pb.ErrorData
) )
@ -43,6 +38,12 @@ func (this *ModuleRobot_GM) DoPipeline(robot IRobot) (err error) {
return 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) { func (this *ModuleRobot_GM) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {

View File

@ -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
}
}

View File

@ -39,11 +39,6 @@ func (this *ModuleRobot_Item) Receive(robot IRobot, stype string, message proto.
return return
} }
func (this *ModuleRobot_Item) OncePipeline(robot IRobot) (err error) { func (this *ModuleRobot_Item) OncePipeline(robot IRobot) (err error) {
return
}
//机器人执行流
func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) {
var ( var (
errdata *pb.ErrorData errdata *pb.ErrorData
) )
@ -54,6 +49,12 @@ func (this *ModuleRobot_Item) DoPipeline(robot IRobot) (err error) {
return 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) { func (this *ModuleRobot_Item) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
var ( var (

View File

@ -31,6 +31,15 @@ func (this *ModuleRobot_Shop) Receive(robot IRobot, stype string, message proto.
return return
} }
func (this *ModuleRobot_Shop) OncePipeline(robot IRobot) (err error) { 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 return
} }
@ -41,13 +50,19 @@ func (this *ModuleRobot_Shop) DoPipeline(robot IRobot) (err error) {
usermodule *ModuleRobot_User usermodule *ModuleRobot_User
) )
usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User) usermodule = robot.GetModule(comm.ModuleUser).(*ModuleRobot_User)
if _, errdata = robot.SendMessage("shop", "getlist", &pb.ShopGetListReq{ for _, v := range this.goods[pb.ShopType_GoldShop] {
SType: pb.ShopType_DiamondShop, 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 { }); errdata != nil {
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message)) err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
return return
} }
break
}
}
for _, v := range this.goods[pb.ShopType_DiamondShop] { for _, v := range this.goods[pb.ShopType_DiamondShop] {
if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) { if v.LeftBuyNum > 0 && usermodule.user.Diamond >= int64(v.Consume[0].N) {
if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{ if _, errdata = robot.SendMessage("shop", "buy", &pb.ShopBuyReq{

View File

@ -34,11 +34,6 @@ func (this *ModuleRobot_User) Receive(robot IRobot, stype string, message proto.
return return
} }
func (this *ModuleRobot_User) OncePipeline(robot IRobot) (err error) { func (this *ModuleRobot_User) OncePipeline(robot IRobot) (err error) {
return
}
//机器人执行流
func (this *ModuleRobot_User) DoPipeline(robot IRobot) (err error) {
var ( var (
errdata *pb.ErrorData errdata *pb.ErrorData
) )
@ -67,6 +62,12 @@ func (this *ModuleRobot_User) DoPipeline(robot IRobot) (err error) {
return 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) { func (this *ModuleRobot_User) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {

View File

@ -69,7 +69,7 @@ func (this *Robot) Init(addr string, client IClient) (err error) {
this.modules[comm.ModuleViking] = new(ModuleRobot_Viking) this.modules[comm.ModuleViking] = new(ModuleRobot_Viking)
this.modules[comm.ModuleChat] = new(ModuleRobot_Chat) this.modules[comm.ModuleChat] = new(ModuleRobot_Chat)
this.modules[comm.ModuleShop] = new(ModuleRobot_Shop) this.modules[comm.ModuleShop] = new(ModuleRobot_Shop)
this.modules[comm.ModuleHoroscope] = new(ModuleRobot_Horoscope)
for _, v := range this.modules { for _, v := range this.modules {
v.Init() v.Init()
} }
@ -248,6 +248,13 @@ func (this *Robot) run() {
module IModuleRobot module IModuleRobot
err error 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 { for this.cycle {
this.cycle = false this.cycle = false
@ -256,9 +263,10 @@ func (this *Robot) run() {
module = this.modules[core.M_Modules(v.Module)] module = this.modules[core.M_Modules(v.Module)]
if err = module.DoPipeline(this); err != nil { if err = module.DoPipeline(this); err != nil {
if this.debug { 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 { if !v.ErrNotStop {
log.Debug("[机器人 退出循环]")
break break
} }
} }