diff --git a/comm/const.go b/comm/const.go index 4b8ec3805..587847b64 100644 --- a/comm/const.go +++ b/comm/const.go @@ -698,3 +698,8 @@ const ( PrivilegeType9 //武馆每日最大练功时间 PrivilegeType10 //铁匠铺每日最大锻造时间 ) +const ( + MainStarType1 = 1 //成功通关 + MainStarType2 = 1 //死亡人数不超过{0}人 + MainStarType3 = 1 //不超过{0}回合通关 +) diff --git a/modules/mline/api_challengeover.go b/modules/mline/api_challengeover.go index 54005bb41..b9948bdf5 100644 --- a/modules/mline/api_challengeover.go +++ b/modules/mline/api_challengeover.go @@ -28,6 +28,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall first bool // 判断是否是首通 update map[string]interface{} rsp *pb.MlineChallengeOverResp + star int32 // 评星 ) rsp = &pb.MlineChallengeOverResp{} update = make(map[string]interface{}) @@ -53,7 +54,6 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall return } // 校验通过 - code, isWin = this.module.battle.CheckBattleReport(session, req.Report) if code != pb.ErrorCode_Success { return @@ -71,10 +71,33 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.MlineChall code = pb.ErrorCode_BattleNoWin return } + // 评星规则 + if len(stageConf.Star) != len(stageConf.StarType) || len(stageConf.Star) != len(stageConf.StarValue) || len(stageConf.StarValue) != len(stageConf.StarType) { + this.module.Errorf("配置错误, 参数数量不一致,StageId: %d", req.StageId) + code = pb.ErrorCode_ConfigNoFound + return + } + for i, v := range stageConf.StarType { + if v == comm.MainStarType1 { + star += stageConf.Star[i] + } else if v == comm.MainStarType2 { + if req.Report.Death <= stageConf.StarValue[i] { + star += stageConf.Star[i] + } + } else if v == comm.MainStarType3 { + if req.Report.Round <= stageConf.StarValue[i] { + star += stageConf.Star[i] + } + } + } // 判断是不是首通 if _, ok := curChapter.Star[req.StageId]; !ok { first = true - curChapter.Star[req.StageId] = 1 + curChapter.Star[req.StageId] = star // 星级赋值 + update["star"] = curChapter.Star + } + if curChapter.Star[req.StageId] > star { // 给最高星 + curChapter.Star[req.StageId] = star update["star"] = curChapter.Star } curChapter.Ps[req.StageId] = 0 // 清空预扣体力值