diff --git a/modules/mline/api_challenge.go b/modules/mline/api_challenge.go index 2b3c8637e..89293270a 100644 --- a/modules/mline/api_challenge.go +++ b/modules/mline/api_challenge.go @@ -42,39 +42,33 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge } } if curChapter == nil { // 校验是不是新的数据 - if stageConf.Previoustage == 0 { // 创建一条新的章节数据 - chapter := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验 - bCheck := false - if chapter == 0 { - bCheck = true - } else { - for _, v := range list { - if chapter == v.ChapterId { // 有上一章节数据 - if _, ok := v.Star[stageConf.Previoustage]; ok { - bCheck = true - } - break - } - } - } + preStage := this.module.configure.GetPreMainChapter(req.StageId) // 新章节数据校验 + preStageConf := this.module.configure.GetMainStageConf(preStage) + if stageConf == nil { // 配置文件校验 + code = pb.ErrorCode_MainlineNotFindChapter + return + } - if bCheck { - newData := &pb.DBMline{ - Id: primitive.NewObjectID().Hex(), - Uid: session.GetUserId(), - CType: stageConf.Episodetype, - ChapterId: stageConf.Chapterid, - StageId: stageConf.Id, - Star: map[int32]int32{}, - Award: map[int32]bool{}, - Ps: map[int32]int32{}, + for _, v := range list { + if preStageConf.CaptainId == v.ChapterId { // 有上一章节数据 + if _, ok := v.Star[v.StageId]; ok { + newData := &pb.DBMline{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + CType: stageConf.Episodetype, + ChapterId: stageConf.Chapterid, + StageId: stageConf.Id, + Star: map[int32]int32{}, + Award: map[int32]bool{}, + Ps: map[int32]int32{}, + } + this.module.modelMline.addNewChapter(session.GetUserId(), newData) + break } - this.module.modelMline.addNewChapter(session.GetUserId(), newData) - } else { - code = pb.ErrorCode_MainlineNotFindChapter - return } } + code = pb.ErrorCode_MainlineNotFindChapter + return } if v, ok := curChapter.Ps[req.StageId]; ok && v > 0 { @@ -109,9 +103,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.MlineChallenge this.module.modelMline.modifyMlineData(session.GetUserId(), curChapter.Id, map[string]interface{}{ "ps": curChapter.Ps, }) - } - code, record := this.module.battle.CreatePveBattle(session, &pb.BattlePVEReq{ Ptype: pb.PlayType_mainline, Title: "", diff --git a/modules/mline/comp_configure.go b/modules/mline/comp_configure.go index 3c7208525..b71511bbc 100644 --- a/modules/mline/comp_configure.go +++ b/modules/mline/comp_configure.go @@ -73,20 +73,13 @@ func (this *configureComp) GetMainStageConf(id int32) (data *cfg.GameMainStageDa return } -// 获取上一章节信息 -func (this *configureComp) GetPreMainChapter(id int32) (stageID int32) { - if v, err := this.GetConfigure(game_mainchapter); err == nil { - if configure, ok := v.(*cfg.GameMainChapter); ok { - for index, v1 := range configure.GetDataList() { - if v1.Id == id { - if index > 0 { - data := configure.GetDataList()[index-1] - if v1.ChapterType != data.ChapterType { // 章节类型必须一致 - stageID = data.Id - } - } else { // 第一章节 - stageID = 0 - } +// 获取上一关卡信息 +func (this *configureComp) GetPreMainChapter(stageId int32) (preStageID int32) { + if v, err := this.GetConfigure(game_mainstage); err == nil { + if configure, ok := v.(*cfg.GameMainStage); ok { + for _, v1 := range configure.GetDataList() { + if v1.Previoustage == stageId { + preStageID = v1.Id break } }