diff --git a/modules/pagoda/api_racechallengeover.go b/modules/pagoda/api_racechallengeover.go index f8a7f5c66..86964256d 100644 --- a/modules/pagoda/api_racechallengeover.go +++ b/modules/pagoda/api_racechallengeover.go @@ -27,9 +27,11 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda err error atno []*pb.UserAtno // 通关奖励 award []*cfg.Gameatn + res []*cfg.Gameatn changExp map[string]int32 costTime int32 // 耗时 new bool // 是否首次挑战 + fresh bool // 刷新记录 ) changExp = make(map[string]int32, 0) mapData = make(map[string]interface{}, 0) @@ -88,22 +90,6 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda list.Battlecount += 1 mapData["data"] = list.Data mapData["battlecount"] = list.Battlecount - - if new { - if conf.Floors == 1 { // 写数据 - this.module.modelRacePagoda.addCrossPagodaRace(session.GetUserId(), list) - } else { - this.module.modelRacePagoda.ModifyCrossPagodaRaceData(session.GetUserId(), mapData) - } - var score int32 - score = 10000*list.Maxfloor + (10000 - costTime) - // 校验是否刷新记录 - if list.Data[conf.Floors].Consttime > costTime { // 小于之前的时间 入榜 - this.module.modelRacePagoda.SetRacePagodaRankList(score, session.GetUserId()) - } - award = append(award, conf.KeyReward...) // 首通奖励 - } - if err = this.module.modelRacePagoda.ModifyPagodaRaceData(session.GetUserId(), mapData); err != nil { errdata = &pb.ErrorData{ Code: pb.ErrorCode_DBError, @@ -111,6 +97,42 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda Message: err.Error(), } } + if list.Data[conf.Floors].Consttime > costTime { + list.Data[conf.Floors].Consttime = costTime + fresh = true + } + var score int32 + score = 10000*list.Maxfloor + (10000 - costTime) + szLine := make([]*pb.LineUp, 0) + var Leadpos int32 + if req.Report != nil && req.Report.Info != nil && len(req.Report.Info.Redflist) > 0 { + Leadpos = req.Report.Info.Redflist[0].Leadpos + for _, v := range req.Report.Info.Redflist[0].Team { + if v != nil { + szLine = append(szLine, &pb.LineUp{ + Cid: v.HeroID, + Star: v.Star, + Lv: v.Lv, + }) + } + } + } + list.Data[conf.Floors].Line = &pb.LineData{ + Leadpos: Leadpos, + Line: szLine, + } + if new { + if conf.Floors == 1 { // 写数据 + this.module.modelRacePagoda.addCrossPagodaRace(session.GetUserId(), list) + } + res = append(res, conf.KeyReward...) // 首通奖励 + } + // 校验是否刷新记录 + if fresh || new { + this.module.modelRacePagoda.SetRacePagodaRankList(score, session.GetUserId()) + mapData["data"] = list.Data + this.module.modelRacePagoda.ModifyCrossPagodaRaceData(session.GetUserId(), mapData) + } if conf.Exp > 0 { var heroObjs []string @@ -124,8 +146,9 @@ func (this *apiComp) ChallengeRaceOver(session comm.IUserSession, req *pb.Pagoda if changExp, award, errdata = this.module.ModuleHero.AddHerosExp(session, heroObjs, conf.Exp); errdata != nil { return } + res = append(res, award...) } - award = append(award, conf.Reward...) + res = append(res, conf.Reward...) // 通关奖励 if errdata, atno = this.module.DispenseAtno(session, award, true); errdata != nil { return