diff --git a/busi/arena.go b/busi/arena.go index 475e250..461b2a6 100644 --- a/busi/arena.go +++ b/busi/arena.go @@ -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 } diff --git a/busi/chat.go b/busi/chat.go index 8425750..c2556a5 100644 --- a/busi/chat.go +++ b/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 } diff --git a/busi/resmgr.go b/busi/resmgr.go new file mode 100644 index 0000000..75e285d --- /dev/null +++ b/busi/resmgr.go @@ -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 +} diff --git a/busi/shop.go b/busi/shop.go index c7e94fa..3b9f67e 100644 --- a/busi/shop.go +++ b/busi/shop.go @@ -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) diff --git a/main.go b/main.go index 0234696..109e908 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ func init() { registerScenes( &busi.LoginScene{}, &busi.CreateUserScene{}, + &busi.ResMgrScene{}, &busi.FriendScene{}, &busi.SociatyScene{}, &busi.HeroScene{},