diff --git a/busi/arena.go b/busi/arena.go index 6b3f982..3af5dde 100644 --- a/busi/arena.go +++ b/busi/arena.go @@ -60,23 +60,25 @@ func (f *ArenaScene) Run(ai lib.IRobot) (err error) { return } Sleep(time.Second*3, 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, - Incmd: make([]*pb.BattleCmd, 0), - Outcmd: make([]*pb.BattleCmd, 0), - Completetask: []int32{}, - }, - }, &pb.ArenaChallengeRewardResp{}); code != pb.ErrorCode_Success { - ai.Stop() - return + if challenge.Code == pb.ErrorCode_Success { + 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, + Incmd: make([]*pb.BattleCmd, 0), + Outcmd: make([]*pb.BattleCmd, 0), + Completetask: []int32{}, + }, + }, &pb.ArenaChallengeRewardResp{}); code != pb.ErrorCode_Success { + ai.Stop() + return + } + Sleep(time.Second*1, time.Second*3) } - Sleep(time.Second*1, time.Second*3) break } return diff --git a/busi/mfantasy.go b/busi/mfantasy.go index 7a6811e..ee198b4 100644 --- a/busi/mfantasy.go +++ b/busi/mfantasy.go @@ -30,19 +30,17 @@ func (f *MfantasyScene) Run(ai lib.IRobot) (err error) { battlereq *pb.MoonfantasyBattleResp = &pb.MoonfantasyBattleResp{} ) - if herolist := ai.Get("hero.list"); herolist == nil { + f.AddHero(ai, "25001") // 加阿宝 + Sleep(time.Second*0, time.Second*1) + herolistreq := &pb.HeroListReq{} + herolistresp := &pb.HeroListResp{} + if code = ai.SendMsg("hero", "list", herolistreq, herolistresp); code != pb.ErrorCode_Success { ai.Stop() return - } else { - herolistrsp = herolist.(*pb.HeroListResp) - if herolistrsp.List == nil || len(herolistrsp.List) == 0 { - ai.Stop() - return - } } Sleep(time.Second*0, time.Second*1) if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{ - Cmod: "bingo:moon,1", + Cmod: "bingo:moon,25001", }, &pb.GMCmdResp{}); code != pb.ErrorCode_Success { ai.Stop() } @@ -62,21 +60,39 @@ func (f *MfantasyScene) Run(ai lib.IRobot) (err error) { 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, - Incmd: make([]*pb.BattleCmd, 0), - Outcmd: make([]*pb.BattleCmd, 0), - Completetask: []int32{}, - }, - }, &pb.MoonfantasyReceiveResp{}); code != pb.ErrorCode_Success { - ai.Stop() - return + if battlereq.Code == pb.ErrorCode_Success { + if code = ai.SendMsg("moonfantasy", "receive", &pb.MoonfantasyReceiveReq{ + Report: &pb.BattleReport{ + Info: battlereq.Info, + Costtime: 1, + Incmd: make([]*pb.BattleCmd, 0), + Outcmd: make([]*pb.BattleCmd, 0), + Completetask: []int32{}, + }, + }, &pb.MoonfantasyReceiveResp{}); code != pb.ErrorCode_Success { + ai.Stop() + return + } + Sleep(time.Second, time.Second*3) } - Sleep(time.Second, time.Second*3) break } - return } + +// 加英雄 +func (f *MfantasyScene) AddHero(robot lib.IRobot, cid string) error { + var ( + code pb.ErrorCode + ) + req := &pb.GMCmdReq{ + Cmod: "bingo:hero," + cid + ",1", + } + rsp := &pb.GMCmdResp{} + code = robot.SendMsg("gm", "cmd", req, rsp) + if code != pb.ErrorCode_Success { + return nil + } + + return nil +}