上传压测场景
This commit is contained in:
parent
21c0de8ca0
commit
062c4ac374
@ -1,6 +1,8 @@
|
|||||||
package busi
|
package busi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"legu.airobot/lib"
|
"legu.airobot/lib"
|
||||||
"legu.airobot/pb"
|
"legu.airobot/pb"
|
||||||
)
|
)
|
||||||
@ -22,18 +24,57 @@ func (f *ArenaScene) Info() lib.SceneInfo {
|
|||||||
|
|
||||||
func (f *ArenaScene) Run(ai lib.IRobot) (err error) {
|
func (f *ArenaScene) Run(ai lib.IRobot) (err error) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
matche *pb.ArenaMatcheResp = &pb.ArenaMatcheResp{}
|
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 {
|
if code = ai.SendMsg("arena", "matche", &pb.ArenaMatcheReq{}, matche); code != pb.ErrorCode_Success {
|
||||||
ai.Stop()
|
ai.Stop()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if code = ai.SendMsg("arena", "challenge", &pb.ArenaChallengeReq{}, &pb.ArenaChallengeResp{}); code != pb.ErrorCode_Success {
|
for _, v := range matche.Players {
|
||||||
ai.Stop()
|
if code = ai.SendMsg("arena", "challenge", &pb.ArenaChallengeReq{
|
||||||
return
|
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
|
return
|
||||||
}
|
}
|
||||||
|
28
busi/chat.go
28
busi/chat.go
@ -1,6 +1,8 @@
|
|||||||
package busi
|
package busi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"legu.airobot/lib"
|
"legu.airobot/lib"
|
||||||
"legu.airobot/pb"
|
"legu.airobot/pb"
|
||||||
)
|
)
|
||||||
@ -22,14 +24,38 @@ func (f *ChatScene) Info() lib.SceneInfo {
|
|||||||
|
|
||||||
func (f *ChatScene) Run(ai lib.IRobot) (err error) {
|
func (f *ChatScene) Run(ai lib.IRobot) (err error) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
|
userlogin *pb.UserLoginResp
|
||||||
)
|
)
|
||||||
|
//世界聊天
|
||||||
if code = ai.SendMsg("chat", "send", &pb.ChatSendReq{
|
if code = ai.SendMsg("chat", "send", &pb.ChatSendReq{
|
||||||
Channel: pb.ChatChannel_World,
|
Channel: pb.ChatChannel_World,
|
||||||
|
Ctype: pb.ChatType_Text,
|
||||||
Content: "hello! are you good?",
|
Content: "hello! are you good?",
|
||||||
}, &pb.ChatSendResp{}); code != pb.ErrorCode_Success {
|
}, &pb.ChatSendResp{}); code != pb.ErrorCode_Success {
|
||||||
ai.Stop()
|
ai.Stop()
|
||||||
return
|
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
|
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 {
|
for _, v := range shops.Goods {
|
||||||
if v.LeftBuyNum > 0 {
|
if v.LeftBuyNum > 0 {
|
||||||
code = ai.SendMsg("shop", "buy", &pb.ChatSendReq{
|
ai.SendMsg("shop", "buy", &pb.ChatSendReq{
|
||||||
Channel: pb.ChatChannel_World,
|
Channel: pb.ChatChannel_World,
|
||||||
Content: "hello! are you good?",
|
Content: "hello! are you good?",
|
||||||
}, shops)
|
}, shops)
|
||||||
|
1
main.go
1
main.go
@ -30,6 +30,7 @@ func init() {
|
|||||||
registerScenes(
|
registerScenes(
|
||||||
&busi.LoginScene{},
|
&busi.LoginScene{},
|
||||||
&busi.CreateUserScene{},
|
&busi.CreateUserScene{},
|
||||||
|
&busi.ResMgrScene{},
|
||||||
&busi.FriendScene{},
|
&busi.FriendScene{},
|
||||||
&busi.SociatyScene{},
|
&busi.SociatyScene{},
|
||||||
&busi.HeroScene{},
|
&busi.HeroScene{},
|
||||||
|
Loading…
Reference in New Issue
Block a user