airobot/busi/mfantasy.go
2022-12-15 18:00:59 +08:00

99 lines
2.3 KiB
Go

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{}
)
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
}
Sleep(time.Second*0, time.Second*1)
if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{
Cmod: "bingo:moon,25001",
}, &pb.GMCmdResp{}); code != pb.ErrorCode_Success {
ai.Stop()
}
Sleep(time.Second*0, time.Second*1)
if code = ai.SendMsg("moonfantasy", "getlist", &pb.MoonfantasyGetListReq{}, mflist); code != pb.ErrorCode_Success {
ai.Stop()
}
Sleep(time.Second*0, time.Second*1)
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 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)
}
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
}