From a96dc9884f4ee276a71ed52307789f8f3e560f53 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Fri, 9 Sep 2022 14:23:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E7=BA=BF=E8=AE=B0=E5=BD=95=E5=B7=B2?= =?UTF-8?q?=E6=8C=91=E6=88=98=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/hunting/model_rank.go | 2 +- modules/mainline/api_challengeover.go | 48 +++++++++++---------------- modules/viking/api_challenge.go | 1 - modules/viking/api_challengeover.go | 22 ++++++------ modules/viking/model_rank.go | 2 +- 5 files changed, 34 insertions(+), 41 deletions(-) diff --git a/modules/hunting/model_rank.go b/modules/hunting/model_rank.go index 53a607535..d5a16dc48 100644 --- a/modules/hunting/model_rank.go +++ b/modules/hunting/model_rank.go @@ -40,7 +40,7 @@ func (this *ModelRank) ChangeUserRank(uid string, objId string, value map[string func (this *ModelRank) GetRankData(bossType int32) (data []*pb.DBHuntingRank, err error) { tmpdata := make([]*pb.DBHuntingRank, 0) data = make([]*pb.DBHuntingRank, 0) - err = this.Redis.LRange(comm.TableVikingRank, 0, -1, &tmpdata) + err = this.Redis.LRange(comm.TableVikingRankList, 0, -1, &tmpdata) if err == nil { for _, v := range tmpdata { if v.Bosstype == bossType { diff --git a/modules/mainline/api_challengeover.go b/modules/mainline/api_challengeover.go index 8788c64f9..67277e9ba 100644 --- a/modules/mainline/api_challengeover.go +++ b/modules/mainline/api_challengeover.go @@ -22,9 +22,9 @@ func (this *apiComp) ChallengeOverCheck(session comm.IUserSession, req *pb.Mainl ///挑战主线关卡 func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineChallengeOverReq) (code pb.ErrorCode, data proto.Message) { var ( - curChapter *pb.DBMainline // 当前章节信息 - bBranch bool // 当前挑战关卡是不是分支 - res []*cfg.Gameatn // 小章节奖励 + mainline *pb.DBMainline // 当前章节信息 + bBranch bool // 当前挑战关卡是不是分支 + res []*cfg.Gameatn // 小章节奖励 ) res = make([]*cfg.Gameatn, 0) @@ -33,54 +33,47 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh return // 参数校验失败直接返回 } // 校验关卡存不存在 - curChapter = this.module.modelMainline.getOneChapterInfo(session.GetUserId(), req.ChapterObj) - if curChapter == nil { + mainline = this.module.modelMainline.getOneChapterInfo(session.GetUserId(), req.ChapterObj) + if mainline == nil { code = pb.ErrorCode_MainlineNotFound return } - node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId), curChapter.Intensity) + node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId), mainline.Intensity) if node == nil { // 配置文件校验 code = pb.ErrorCode_MainlineNotFindChapter return } - if node.Route == 1 { - if node.Previoustage != curChapter.MainlineId { + for _, v := range mainline.BranchID { + if v == int32(req.MainlineId) { // 重复挑战 code = pb.ErrorCode_MainlineNotFindChapter return } - } else { - for _, v := range curChapter.BranchID { - if v == int32(req.MainlineId) { // 重复挑战 - code = pb.ErrorCode_MainlineNotFindChapter - return - } - } } res = append(res, node.Award...) - curChapter.MainlineId = int32(req.MainlineId) + mainline.MainlineId = int32(req.MainlineId) if bBranch { - curChapter.BranchID = append(curChapter.BranchID, int32(req.MainlineId)) // 记录分支关卡 + mainline.BranchID = append(mainline.BranchID, int32(req.MainlineId)) // 记录分支关卡 } - + mainline.BranchID = append(mainline.BranchID, int32(req.MainlineId)) update := map[string]interface{}{ "mainlineId": req.MainlineId, - "ChapterId": curChapter.ChapterId, - "branchID": curChapter.BranchID, + "ChapterId": mainline.ChapterId, + "branchID": mainline.BranchID, } - err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), curChapter.Id, update) + err := this.module.modelMainline.modifyMainlineData(session.GetUserId(), mainline.Id, update) if err != nil { code = pb.ErrorCode_DBError return } - newChaptConfig := this.module.modelMainline.checkNewCapter(curChapter.ChapterId+1, curChapter.Intensity, curChapter.MainlineId) + newChaptConfig := this.module.modelMainline.checkNewCapter(mainline.ChapterId+1, mainline.Intensity, mainline.MainlineId) if newChaptConfig != nil { // 如果本章节打完 则创建新的章节 _data := &pb.DBMainline{} _data.Id = primitive.NewObjectID().Hex() - _data.ChapterId = curChapter.ChapterId + 1 + _data.ChapterId = mainline.ChapterId + 1 _data.MainlineId = 0 // 第二章数据默认0 _mData := make(map[string]interface{}, 0) _data.Uid = session.GetUserId() @@ -90,15 +83,14 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh // 推送新的章节 session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data}) } else { // 切换下个难度 - - node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId+1), curChapter.Intensity) - if node == nil && curChapter.Intensity < comm.MaxMainlineIntensity { // 配置文件校验 + node := this.module.configure.GetMainlineConfigData(int32(req.MainlineId+1), mainline.Intensity) + if node == nil && mainline.Intensity < comm.MaxMainlineIntensity { // 配置文件校验 _data := &pb.DBMainline{} _data.Id = primitive.NewObjectID().Hex() _data.ChapterId = 1 // 默认第一章节 _mData := make(map[string]interface{}, 0) _data.Uid = session.GetUserId() - _data.Intensity = curChapter.Intensity + 1 // 难度+1 + _data.Intensity = mainline.Intensity + 1 // 难度+1 _mData[_data.Id] = _data this.module.modelMainline.addNewChapter(session.GetUserId(), _mData) session.SendMsg(string(this.module.GetType()), MainlineNewChapterPush, &pb.MainlineNewChapterPush{Data: _data}) @@ -109,6 +101,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MainlineCh if code != pb.ErrorCode_Success { return } - session.SendMsg(string(this.module.GetType()), MainlineChallengeOverResp, &pb.MainlineChallengeOverResp{Data: curChapter}) + session.SendMsg(string(this.module.GetType()), MainlineChallengeOverResp, &pb.MainlineChallengeOverResp{Data: mainline}) return } diff --git a/modules/viking/api_challenge.go b/modules/viking/api_challenge.go index 9e814087d..8cd3932f4 100644 --- a/modules/viking/api_challenge.go +++ b/modules/viking/api_challenge.go @@ -22,7 +22,6 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.VikingChalleng if code != pb.ErrorCode_Success { return // 参数校验失败直接返回 } - viking, err := this.module.modelViking.getVikingList(session.GetUserId()) if err != nil { code = pb.ErrorCode_VikingBoosType diff --git a/modules/viking/api_challengeover.go b/modules/viking/api_challengeover.go index 47413ab4a..c3dc8035d 100644 --- a/modules/viking/api_challengeover.go +++ b/modules/viking/api_challengeover.go @@ -64,19 +64,21 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal } viking.Boss[req.BossType] += 1 mapData["Boss"] = viking.Boss - // viking.ChallengeTime[req.BossType<<16+req.Difficulty] = 0 // todo 耗时 - // mapData["challengeTime"] = viking.ChallengeTime - sz := make([]*pb.LineUp, 5) - for i, v := range req.Report.Info.Redflist[0].Team { - if v != nil { - sz[i] = &pb.LineUp{ - Cid: v.HeroID, - Star: v.Star, - Lv: v.Lv, + + if req.Report != nil && len(req.Report.Info.Redflist) > 0 { + sz := make([]*pb.LineUp, 5) + for i, v := range req.Report.Info.Redflist[0].Team { + if v != nil { + sz[i] = &pb.LineUp{ + Cid: v.HeroID, + Star: v.Star, + Lv: v.Lv, + } } } + + this.module.modulerank.updateVikingRankList(session, req.Difficulty, req.BossType, req.Report.Info.Redflist[0].Leadpos, sz) } - this.module.modulerank.updateVikingRankList(session, req.Difficulty, req.BossType, req.Report.Info.Redflist[0].Leadpos, sz) } // 耗时校验 当前战斗胜利时间消耗小于之前刷新数据 diff --git a/modules/viking/model_rank.go b/modules/viking/model_rank.go index 23eb239d1..f99da0c4b 100644 --- a/modules/viking/model_rank.go +++ b/modules/viking/model_rank.go @@ -48,7 +48,7 @@ func (this *ModelRank) ChangeUserRank(uid string, objId string, value map[string func (this *ModelRank) GetRankData(bossType int32) (data []*pb.DBVikingRank, err error) { tmpdata := make([]*pb.DBVikingRank, 0) data = make([]*pb.DBVikingRank, 0) - err = this.Redis.LRange(comm.TableVikingRank, 0, -1, &tmpdata) + err = this.Redis.LRange(comm.TableVikingRankList, 0, -1, &tmpdata) if err == nil { for _, v := range tmpdata { if v.Bosstype == bossType {