59 lines
1.5 KiB
Go
59 lines
1.5 KiB
Go
package autoBattle
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) AutoOverCheck(session comm.IUserSession, req *pb.BattleAutoOverReq) (code pb.ErrorCode) {
|
|
if req.Ptype == pb.PlayType_null || req.Report == nil {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
if req.Report.Info == nil {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
func (this *apiComp) AutoOver(session comm.IUserSession, req *pb.BattleAutoOverReq) (code pb.ErrorCode, data proto.Message) {
|
|
var (
|
|
autoBattle *pb.DBAutoBattle
|
|
atno []*pb.UserAtno
|
|
)
|
|
if code = this.AutoOverCheck(session, req); code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
list, err := this.module.modelAutoBattle.getAutoBattleList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
for _, v := range list {
|
|
if v.Ptype == req.Ptype { // 有正在自动战斗的数据
|
|
autoBattle = v
|
|
}
|
|
}
|
|
if autoBattle == nil {
|
|
code = pb.ErrorCode_AutoBattleNoData
|
|
return
|
|
}
|
|
// 分析战报 数据
|
|
if req.Ptype == pb.PlayType_viking {
|
|
if code, atno = this.viking.AutoBattleOver(session, autoBattle.BossId, autoBattle.Difficulty, req.Report, autoBattle); code != pb.ErrorCode_Success {
|
|
session.SendMsg(string(this.module.GetType()), "autoover", &pb.BattleAutoOverPush{
|
|
Success: false,
|
|
})
|
|
return
|
|
}
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "autoover", &pb.BattleAutoOverResp{
|
|
Asset: atno,
|
|
})
|
|
return
|
|
}
|