81 lines
2.2 KiB
Go
81 lines
2.2 KiB
Go
package pagoda
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
//参数校验
|
|
func (this *apiComp) ChallengeCheck(session comm.IUserSession, req *pb.PagodaChallengeReq) (code pb.ErrorCode) {
|
|
if req.LevelID <= 0 && req.PagodaType != 0 {
|
|
code = pb.ErrorCode_ReqParameterError
|
|
return
|
|
}
|
|
return
|
|
}
|
|
|
|
///挑战主线关卡
|
|
func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PagodaChallengeReq) (code pb.ErrorCode, data proto.Message) {
|
|
code = this.ChallengeCheck(session, req)
|
|
if code != pb.ErrorCode_Success {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
// 校验是不是通关了普通塔
|
|
expand, err := this.module.ModuleUser.GetUserExpand(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_DBError
|
|
return
|
|
}
|
|
conf := this.module.configure.GetPagodaConfigData(req.PagodaType, req.LevelID)
|
|
if conf == nil {
|
|
code = pb.ErrorCode_PagodaNotFound
|
|
return
|
|
}
|
|
if !expand.CompletePagoda {
|
|
pagoda, err := this.module.modelPagoda.getPagodaList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_PagodaNotFound
|
|
return
|
|
}
|
|
if pagoda.Type != conf.PagodaType || conf.LayerNum-1 != pagoda.PagodaId {
|
|
code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配
|
|
return
|
|
}
|
|
|
|
} else {
|
|
// 塔数据校验
|
|
seasonPagoda, err := this.module.modelSeasonPagoda.getSeasonPagodaList(session.GetUserId())
|
|
if err != nil {
|
|
code = pb.ErrorCode_PagodaNotFound
|
|
return
|
|
}
|
|
if seasonPagoda.Type != req.PagodaType || conf.LayerNum-1 != seasonPagoda.PagodaId {
|
|
code = pb.ErrorCode_PagodaLevlErr // 挑战关卡数据不匹配
|
|
return
|
|
}
|
|
}
|
|
code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
|
Ptype: pb.PlayType_moonfantasy,
|
|
Title: "",
|
|
Leadpos: req.Leadpos,
|
|
Teamids: req.Teamids,
|
|
Mformat: conf.MonsterId,
|
|
})
|
|
if code != pb.ErrorCode_Success {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), PagodaChallengeResp, &pb.PagodaChallengeResp{Info: &pb.BattleInfo{
|
|
Id: record.Id,
|
|
Title: record.Title,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
}})
|
|
return
|
|
}
|