上传压测工具补充
This commit is contained in:
parent
6413ad7375
commit
b71fe15cc3
@ -14,6 +14,7 @@ import (
|
||||
type ModuleRobot_Arena struct {
|
||||
Info *pb.DBArenaUser
|
||||
players []*pb.ArenaPlayer
|
||||
index int32
|
||||
}
|
||||
|
||||
func (this *ModuleRobot_Arena) Init() (err error) {
|
||||
@ -44,6 +45,13 @@ func (this *ModuleRobot_Arena) OncePipeline(robot IRobot) (err error) {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
if this.players == nil || this.index >= int32(len(this.players)) {
|
||||
if _, errdata = robot.SendMessage("arena", "matche", &pb.ArenaMatcheReq{}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
this.index = 0
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
@ -57,17 +65,12 @@ 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 {
|
||||
player = v
|
||||
break
|
||||
}
|
||||
player = this.players[this.index]
|
||||
this.index++
|
||||
if player == nil {
|
||||
return
|
||||
}
|
||||
|
93
modules/robot/modulerobot_friend.go
Normal file
93
modules/robot/modulerobot_friend.go
Normal file
@ -0,0 +1,93 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
//用户模块 机器人
|
||||
type ModuleRobot_Friend struct {
|
||||
friend *pb.DBFriend
|
||||
applylist []*pb.FriendBase
|
||||
}
|
||||
|
||||
func (this *ModuleRobot_Friend) Init() (err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//接收到消息
|
||||
func (this *ModuleRobot_Friend) Receive(robot IRobot, stype string, message proto.Message) (err error) {
|
||||
switch stype {
|
||||
case "list":
|
||||
resp := message.(*pb.FriendListResp)
|
||||
this.friend = resp.Friend
|
||||
break
|
||||
case "applylist":
|
||||
resp := message.(*pb.FriendApplyListResp)
|
||||
this.applylist = resp.List
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *ModuleRobot_Friend) OncePipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
if _, errdata = robot.SendMessage("friend", "list", &pb.FriendListReq{}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//机器人执行流
|
||||
func (this *ModuleRobot_Friend) DoPipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
resp protoreflect.ProtoMessage
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
if _, errdata = robot.SendMessage("friend", "applylist", &pb.FriendApplyListReq{}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
if this.applylist != nil && len(this.applylist) > 0 {
|
||||
friendIds := make([]string, 0)
|
||||
for _, v := range this.applylist {
|
||||
friendIds = append(friendIds, v.UserId)
|
||||
}
|
||||
if _, errdata = robot.SendMessage("friend", "agree", &pb.FriendAgreeReq{
|
||||
FriendIds: friendIds,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if resp, errdata = robot.SendMessage("friend", "randlist", &pb.FriendRandlistReq{}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
for _, v := range resp.(*pb.FriendRandlistResp).List {
|
||||
if _, errdata = robot.SendMessage("friend", "agree", &pb.FriendApplyReq{
|
||||
FriendId: v.UserId,
|
||||
}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//做任务
|
||||
func (this *ModuleRobot_Friend) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
|
||||
|
||||
return
|
||||
}
|
59
modules/robot/modulerobot_passon.go
Normal file
59
modules/robot/modulerobot_passon.go
Normal file
@ -0,0 +1,59 @@
|
||||
package robot
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
//用户模块 机器人
|
||||
type ModuleRobot_Passon struct {
|
||||
info *pb.DBPasson
|
||||
applylist []*pb.FriendBase
|
||||
}
|
||||
|
||||
func (this *ModuleRobot_Passon) Init() (err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//接收到消息
|
||||
func (this *ModuleRobot_Passon) Receive(robot IRobot, stype string, message proto.Message) (err error) {
|
||||
switch stype {
|
||||
case "info":
|
||||
resp := message.(*pb.PassonInfoResp)
|
||||
this.info = resp.Info
|
||||
break
|
||||
case "applylist":
|
||||
resp := message.(*pb.FriendApplyListResp)
|
||||
this.applylist = resp.List
|
||||
break
|
||||
}
|
||||
return
|
||||
}
|
||||
func (this *ModuleRobot_Passon) OncePipeline(robot IRobot) (err error) {
|
||||
var (
|
||||
errdata *pb.ErrorData
|
||||
)
|
||||
if _, errdata = robot.SendMessage("passon", "info", &pb.PassonInfoReq{}); errdata != nil {
|
||||
err = errors.New(fmt.Sprintf("code:%d message:%s", errdata.Code, errdata.Message))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//机器人执行流
|
||||
func (this *ModuleRobot_Passon) DoPipeline(robot IRobot) (err error) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
//做任务
|
||||
func (this *ModuleRobot_Passon) DoTask(robot IRobot, taskconf *cfg.GameWorldTaskData, condconf *cfg.GameBuriedCondiData) (err error) {
|
||||
|
||||
return
|
||||
}
|
@ -83,6 +83,8 @@ func (this *Robot) Init(addr string, client IClient) (err error) {
|
||||
this.modules[comm.ModuleHoroscope] = new(ModuleRobot_Horoscope)
|
||||
this.modules[comm.ModuleCombat] = new(ModuleRobot_Combat)
|
||||
this.modules[comm.ModuleSmithy] = new(ModuleRobot_Smithy)
|
||||
this.modules[comm.ModuleFriend] = new(ModuleRobot_Friend)
|
||||
this.modules[comm.ModulePasson] = new(ModuleRobot_Passon)
|
||||
|
||||
for _, v := range this.modules {
|
||||
v.Init()
|
||||
|
Loading…
Reference in New Issue
Block a user