airobot/busi/mfantasy.go

83 lines
1.9 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{}
)
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
}
}
Sleep(time.Second*0, time.Second*1)
if code = ai.SendMsg("gm", "cmd", &pb.GMCmdReq{
Cmod: "bingo:moon,1",
}, &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 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
}