95 lines
2.5 KiB
Go
95 lines
2.5 KiB
Go
package mainline
|
|
|
|
import (
|
|
"go_dreamfactory/comm"
|
|
"go_dreamfactory/pb"
|
|
cfg "go_dreamfactory/sys/configure/structs"
|
|
)
|
|
|
|
// 参数校验
|
|
func (this *apiComp) BoosChallengeCheck(session comm.IUserSession, req *pb.MainlineBoosChallengeReq) (errdata *pb.ErrorData) {
|
|
if req.Boosid == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
// /挑战主线关卡
|
|
func (this *apiComp) BoosChallenge(session comm.IUserSession, req *pb.MainlineBoosChallengeReq) (errdata *pb.ErrorData) {
|
|
var (
|
|
info *pb.DBMainline // 当前章节信息
|
|
conf *cfg.GameMainBossData // 当前章节数据
|
|
err error
|
|
)
|
|
|
|
if errdata = this.BoosChallengeCheck(session, req); errdata != nil {
|
|
return // 参数校验失败直接返回
|
|
}
|
|
|
|
if conf, err = this.module.configure.getGameMainBossData(req.Boosid); err != nil { // 配置文件校验
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_MainlineNotFindChapter,
|
|
Title: pb.ErrorCode_MainlineNotFindChapter.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
if info, err = this.module.modelMline.getMainlineData(session.GetUserId()); err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Title: pb.ErrorCode_DBError.ToString(),
|
|
Message: err.Error(),
|
|
}
|
|
return
|
|
}
|
|
//不是当前章节
|
|
if conf.MonsterChapter != info.Currbooschapter {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "boos is no Currbooschapter",
|
|
}
|
|
return
|
|
}
|
|
|
|
//未解锁
|
|
if info.Chapterboos[conf.MonsterChapter]+1 < conf.MonsterStrength {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Title: pb.ErrorCode_ReqParameterError.ToString(),
|
|
Message: "boos is unlock",
|
|
}
|
|
return
|
|
}
|
|
|
|
errdata, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{
|
|
Rulesid: conf.Battlereadyid,
|
|
Ptype: pb.PlayType_mainline,
|
|
Title: "",
|
|
Format: req.Battle,
|
|
Mformat: conf.FormatList,
|
|
})
|
|
if errdata != nil {
|
|
return
|
|
}
|
|
session.SendMsg(string(this.module.GetType()), "challenge", &pb.MainlineBoosChallengeResp{
|
|
Info: &pb.BattleInfo{
|
|
Id: record.Id,
|
|
Title: record.Title,
|
|
Rulesid: conf.Battlereadyid,
|
|
Btype: record.Btype,
|
|
Ptype: record.Ptype,
|
|
RedCompId: record.RedCompId,
|
|
Redflist: record.Redflist,
|
|
BlueCompId: record.BlueCompId,
|
|
Buleflist: record.Buleflist,
|
|
Tasks: record.Tasks,
|
|
},
|
|
Boosid: req.Boosid,
|
|
})
|
|
return
|
|
}
|