diff --git a/busi/arena.go b/busi/arena.go index 461b2a6..fb3dd75 100644 --- a/busi/arena.go +++ b/busi/arena.go @@ -58,7 +58,7 @@ func (f *ArenaScene) Run(ai lib.IRobot) (err error) { ai.Stop() return } - time.Sleep(time.Second * 5) + Sleep(time.Second*3, time.Second*5) if code = ai.SendMsg("arena", "challengereward", &pb.ArenaChallengeRewardReq{ Iswin: true, Isai: v.Isai, @@ -74,7 +74,7 @@ func (f *ArenaScene) Run(ai lib.IRobot) (err error) { ai.Stop() return } - time.Sleep(time.Second * 2) + Sleep(time.Second*1, time.Second*3) } return } diff --git a/busi/chat.go b/busi/chat.go index c2556a5..fec5d69 100644 --- a/busi/chat.go +++ b/busi/chat.go @@ -51,7 +51,7 @@ func (f *ChatScene) Run(ai lib.IRobot) (err error) { ai.Stop() return } - time.Sleep(time.Second * 1) + Sleep(time.Second*1, time.Second*3) } } diff --git a/busi/core.go b/busi/core.go new file mode 100644 index 0000000..5ac8668 --- /dev/null +++ b/busi/core.go @@ -0,0 +1,12 @@ +package busi + +import ( + "math/rand" + "time" +) + +func Sleep(min, max time.Duration) { + ulit := int64(max - min) + t := time.Duration(rand.Int63n(ulit)) + min + time.Sleep(t) +} diff --git a/busi/mfantasy.go b/busi/mfantasy.go new file mode 100644 index 0000000..6cd36fc --- /dev/null +++ b/busi/mfantasy.go @@ -0,0 +1,80 @@ +package busi + +import ( + "time" + + "legu.airobot/lib" + "legu.airobot/pb" +) + +//竞技场场景 + +var _ lib.IScene = (*MfantasyScene)(nil) + +type MfantasyScene struct { + lib.Action +} + +func (f *MfantasyScene) Info() lib.SceneInfo { + return lib.SceneInfo{ + Name: "秘境", + Desc: "秘境测试", + } +} + +func (f *MfantasyScene) Run(ai lib.IRobot) (err error) { + var ( + code pb.ErrorCode + herolistrsp *pb.HeroListResp + mflist *pb.MoonfantasyGetListResp = &pb.MoonfantasyGetListResp{} + battlereq *pb.MoonfantasyBattleResp = &pb.MoonfantasyBattleResp{} + ) + + 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("gm", "cmd", &pb.GMCmdReq{ + Cmod: "bingo:moon,1", + }, &pb.GMCmdResp{}); code != pb.ErrorCode_Success { + ai.Stop() + } + + if code = ai.SendMsg("moonfantasy", "getlist", &pb.MoonfantasyGetListReq{}, mflist); code != pb.ErrorCode_Success { + ai.Stop() + } + + for _, v := range mflist.Dfantasys { + if code = ai.SendMsg("moonfantasy", "battle", &pb.MoonfantasyBattleReq{ + Mid: v.Monster, + Battle: &pb.BattleFormation{ + Leadpos: 0, + Format: []string{herolistrsp.List[0].Id}, + }, + }, battlereq); code != pb.ErrorCode_Success { + ai.Stop() + } + Sleep(time.Second*3, time.Second*5) + if code = ai.SendMsg("moonfantasy", "receive", &pb.MoonfantasyReceiveReq{ + Report: &pb.BattleReport{ + Info: battlereq.Info, + Costtime: 1, + Process: []byte{123}, + Completetask: []int32{}, + }, + }, &pb.MoonfantasyReceiveResp{}); code != pb.ErrorCode_Success { + ai.Stop() + return + } + Sleep(time.Second, time.Second*3) + } + + return +}