上传压测场景
This commit is contained in:
parent
21c0de8ca0
commit
062c4ac374
@ -1,6 +1,8 @@
|
||||
package busi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"legu.airobot/lib"
|
||||
"legu.airobot/pb"
|
||||
)
|
||||
@ -22,18 +24,57 @@ func (f *ArenaScene) Info() lib.SceneInfo {
|
||||
|
||||
func (f *ArenaScene) Run(ai lib.IRobot) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
matche *pb.ArenaMatcheResp = &pb.ArenaMatcheResp{}
|
||||
code pb.ErrorCode
|
||||
matche *pb.ArenaMatcheResp = &pb.ArenaMatcheResp{}
|
||||
challenge *pb.ArenaChallengeResp = &pb.ArenaChallengeResp{}
|
||||
herolistrsp *pb.HeroListResp
|
||||
)
|
||||
if herolist := ai.Get("hero.list"); herolist == nil {
|
||||
ai.Stop()
|
||||
return
|
||||
} else {
|
||||
herolistrsp = herolist.(*pb.HeroListResp)
|
||||
if herolistrsp.List == nil || len(herolistrsp.List) == 0 {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if code = ai.SendMsg("arena", "matche", &pb.ArenaMatcheReq{}, matche); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
|
||||
if code = ai.SendMsg("arena", "challenge", &pb.ArenaChallengeReq{}, &pb.ArenaChallengeResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
for _, v := range matche.Players {
|
||||
if code = ai.SendMsg("arena", "challenge", &pb.ArenaChallengeReq{
|
||||
Playerid: v.Uid,
|
||||
Isai: v.Isai,
|
||||
MformatId: v.Mformatid,
|
||||
Battle: &pb.BattleFormation{
|
||||
Leadpos: 0,
|
||||
Format: []string{herolistrsp.List[0].Id},
|
||||
},
|
||||
}, challenge); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 5)
|
||||
if code = ai.SendMsg("arena", "challengereward", &pb.ArenaChallengeRewardReq{
|
||||
Iswin: true,
|
||||
Isai: v.Isai,
|
||||
Aiintegral: v.Integral,
|
||||
Ainame: v.Name,
|
||||
Report: &pb.BattleReport{
|
||||
Info: challenge.Info,
|
||||
Costtime: 1,
|
||||
Process: []byte{123},
|
||||
Completetask: []int32{},
|
||||
},
|
||||
}, challenge); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 2)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
28
busi/chat.go
28
busi/chat.go
@ -1,6 +1,8 @@
|
||||
package busi
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"legu.airobot/lib"
|
||||
"legu.airobot/pb"
|
||||
)
|
||||
@ -22,14 +24,38 @@ func (f *ChatScene) Info() lib.SceneInfo {
|
||||
|
||||
func (f *ChatScene) Run(ai lib.IRobot) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
code pb.ErrorCode
|
||||
userlogin *pb.UserLoginResp
|
||||
)
|
||||
//世界聊天
|
||||
if code = ai.SendMsg("chat", "send", &pb.ChatSendReq{
|
||||
Channel: pb.ChatChannel_World,
|
||||
Ctype: pb.ChatType_Text,
|
||||
Content: "hello! are you good?",
|
||||
}, &pb.ChatSendResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 1)
|
||||
|
||||
//工会聊天
|
||||
if resp := ai.Get("user.login"); resp != nil {
|
||||
userlogin = resp.(*pb.UserLoginResp)
|
||||
if userlogin.Ex.SociatyId != "" {
|
||||
if code = ai.SendMsg("chat", "send", &pb.ChatSendReq{
|
||||
Channel: pb.ChatChannel_Union,
|
||||
TargetId: userlogin.Ex.SociatyId,
|
||||
Ctype: pb.ChatType_Text,
|
||||
Content: "hello! are you good?",
|
||||
}, &pb.ChatSendResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
}
|
||||
|
||||
//好友列表
|
||||
|
||||
return
|
||||
}
|
||||
|
48
busi/resmgr.go
Normal file
48
busi/resmgr.go
Normal file
@ -0,0 +1,48 @@
|
||||
package busi
|
||||
|
||||
import (
|
||||
"legu.airobot/lib"
|
||||
"legu.airobot/pb"
|
||||
)
|
||||
|
||||
//商店场景
|
||||
|
||||
var _ lib.IScene = (*ResMgrScene)(nil)
|
||||
|
||||
type ResMgrScene struct {
|
||||
lib.Action
|
||||
}
|
||||
|
||||
func (f *ResMgrScene) Info() lib.SceneInfo {
|
||||
return lib.SceneInfo{
|
||||
Name: "资源添加和管理",
|
||||
Desc: "添加资源同事保存资源数据到本地 提供其他压测工具使用",
|
||||
}
|
||||
}
|
||||
|
||||
func (f *ResMgrScene) Run(ai lib.IRobot) (err error) {
|
||||
var (
|
||||
code pb.ErrorCode
|
||||
)
|
||||
if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{
|
||||
Cmod: "bingo:Iamyoudad",
|
||||
}, &pb.GMCmdResp{}); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
}
|
||||
herolistreq := &pb.HeroListReq{}
|
||||
herolistresp := &pb.HeroListResp{}
|
||||
if code = ai.SendMsg("hero", "list", herolistreq, herolistresp); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
ai.Store("hero.list", herolistresp)
|
||||
|
||||
itemlistreq := &pb.ItemsGetlistReq{}
|
||||
itemlistresp := &pb.ItemsGetlistResp{}
|
||||
if code = ai.SendMsg("item", "list", itemlistreq, itemlistresp); code != pb.ErrorCode_Success {
|
||||
ai.Stop()
|
||||
return
|
||||
}
|
||||
ai.Store("item.list", itemlistresp)
|
||||
return nil
|
||||
}
|
@ -42,7 +42,7 @@ func (f *ShopScene) Run(ai lib.IRobot) (err error) {
|
||||
}
|
||||
for _, v := range shops.Goods {
|
||||
if v.LeftBuyNum > 0 {
|
||||
code = ai.SendMsg("shop", "buy", &pb.ChatSendReq{
|
||||
ai.SendMsg("shop", "buy", &pb.ChatSendReq{
|
||||
Channel: pb.ChatChannel_World,
|
||||
Content: "hello! are you good?",
|
||||
}, shops)
|
||||
|
Loading…
Reference in New Issue
Block a user