lt пре 1 година
родитељ
комит
bf86cb0245
1 измењених фајлова са 47 додато и 48 уклоњено
  1. 47 48
      RO_Server_Trunk-branch_0.1.39/roserver/rank/model/rank_competition.go

+ 47 - 48
RO_Server_Trunk-branch_0.1.39/roserver/rank/model/rank_competition.go

@@ -10,15 +10,15 @@ import (
 	"strconv"
 )
 
-//排名前5玩家uid列表
+// 排名前5玩家uid列表
 const (
 	COMPETITION_TOP_5 = 5
 )
 
 const LoadTop3TimeGap = 2 * 1000
 
-//赛季玩家处理
-//动态维护推出进度列表,启动时从数据库中进行加载
+// 赛季玩家处理
+// 动态维护推出进度列表,启动时从数据库中进行加载
 type competitionRankInfo struct {
 	uid        uint64
 	mapId      int32  //地图进度
@@ -40,7 +40,7 @@ type CompetitionManager struct {
 
 	//偶像季临时缓存
 	loadTimeStamp uint64
-	top3VoteRank []*top3IdolRank
+	top3VoteRank  []*top3IdolRank
 }
 
 func newCompetitionManager() *CompetitionManager {
@@ -53,7 +53,7 @@ func newCompetitionManager() *CompetitionManager {
 	return mag
 }
 
-//获取排名所在的宝箱档位(赛季所有信息)
+// 获取排名所在的宝箱档位(赛季所有信息)
 func (this *CompetitionManager) getCompetitionSection(compId, beginSubId, subIdNum int32, uid uint64, isNow bool) (int32, int32, []*serverproto.CompetitionRewardInfo, int32, int32, uint32) {
 	convertData, ok := model.ConvertCompTypeList[compId]
 	if !ok {
@@ -111,14 +111,14 @@ func (this *CompetitionManager) getCompetitionSection(compId, beginSubId, subIdN
 			convertData.CompetitionType == int32(model.CompetitionType_Idol) {
 			curSelfRank, curTotalCount, curScore = GetRankByKeyUid(prefixStr, uid, compId)
 			/*
-			//特殊队列中未找到,在正常队列中查找
-			curSelfRank, curTotalCount, curScore = GetRankByKeyUid(prefixStr+":sp", uid)
-			if curTotalCount <= 0 {
-				curSelfRank, curTotalCount, curScore = GetRankByKeyUid(prefixStr, uid)
-			} else {
-				bSpecial = true
-			}
-			 */
+				//特殊队列中未找到,在正常队列中查找
+				curSelfRank, curTotalCount, curScore = GetRankByKeyUid(prefixStr+":sp", uid)
+				if curTotalCount <= 0 {
+					curSelfRank, curTotalCount, curScore = GetRankByKeyUid(prefixStr, uid)
+				} else {
+					bSpecial = true
+				}
+			*/
 		}
 	}
 
@@ -152,7 +152,7 @@ func (this *CompetitionManager) getCompetitionSection(compId, beginSubId, subIdN
 
 		tempSelfRank, err2 := service.GetRedis().ZRevRank(tmpPrefixStr, keyStr).Result()
 		if err2 != nil {
-			util.ErrorF("getCompetitionSection selfRank err:%v %v", err2, uid)
+			util.InfoF("getCompetitionSection selfRank err:%v %v", err2, uid)
 			//return 0, convertData.LastConditionId
 			continue
 		}
@@ -198,7 +198,7 @@ func (this *CompetitionManager) getCompetitionSection(compId, beginSubId, subIdN
 
 //获取某一周期奖励
 
-//更新积分赛季排名(上交道具时获得的积分)
+// 更新积分赛季排名(上交道具时获得的积分)
 func (this *CompetitionManager) UpdateRankByScore(competitionId int32, uid uint64, score int32,
 	ackMsg *serverproto.SSCompetitionUpdateScoreAck) {
 	convertData, ok := model.ConvertCompTypeList[competitionId]
@@ -244,7 +244,7 @@ func (this *CompetitionManager) UpdateRankByScore(competitionId int32, uid uint6
 	ackMsg.LastComScore = lastScore
 }
 
-//return 总分
+// return 总分
 func (this *CompetitionManager) GetIdolTotalScore(uid uint64, score, competitionId int32) int32 {
 	roundStr := strconv.Itoa(int(competitionId))
 	keyStr := model.CompetitionIdolScoreRankPrefix + roundStr
@@ -271,8 +271,8 @@ func (this *CompetitionManager) GetIdolTotalScore(uid uint64, score, competition
 func (this *CompetitionManager) Update(ms uint64) {
 }
 
-//赛季结算
-//榜中,未参加选拔季的玩家属于最后档奖励处理
+// 赛季结算
+// 榜中,未参加选拔季的玩家属于最后档奖励处理
 func (this *CompetitionManager) CompetitionFinish(msg *serverproto.SSCompetitionRewardReq, ssAckMsg *serverproto.SSCompetitionRewardAck) {
 	switch model.CompetitionType(msg.CompetitionType) {
 	case model.CompetitionType_ZhaoMu:
@@ -319,7 +319,7 @@ func (this *CompetitionManager) CompetitionFinish(msg *serverproto.SSCompetition
 	}
 }
 
-//获取对应赛季信息
+// 获取对应赛季信息
 func (this *CompetitionManager) GetCompetitionData(uid uint64, competitionId, subIdNum int32, isNowCompetition bool,
 	competitionType model.CompetitionType, ackMsg *serverproto.SSGetCompetitionDataAck) {
 	ackMsg.Error = int32(serverproto.ErrorCode_ERROR_OK)
@@ -358,7 +358,7 @@ func (this *CompetitionManager) GetCompetitionData(uid uint64, competitionId, su
 	}
 }
 
-func (this *CompetitionManager)GetIdolSeasonData(compId int32, ackMsg *serverproto.SSGetCompetitionDataAck) {
+func (this *CompetitionManager) GetIdolSeasonData(compId int32, ackMsg *serverproto.SSGetCompetitionDataAck) {
 	if ackMsg == nil {
 		return
 	}
@@ -382,10 +382,10 @@ func (this *CompetitionManager)GetIdolSeasonData(compId int32, ackMsg *serverpro
 	}
 }
 
-func (this *CompetitionManager)CheckRefreshTop3Data(compId int32) {
+func (this *CompetitionManager) CheckRefreshTop3Data(compId int32) {
 	//如果当前没有缓存,或者当前缓存时间到期//更新
 	curTime := util.GetCurrentTime()
-	if  this.loadTimeStamp == 0 || (this.loadTimeStamp != 0 &&  this.loadTimeStamp + LoadTop3TimeGap < curTime){
+	if this.loadTimeStamp == 0 || (this.loadTimeStamp != 0 && this.loadTimeStamp+LoadTop3TimeGap < curTime) {
 		this.top3VoteRank = this.top3VoteRank[0:0]
 		this.RefreshPlayerDetailData(compId)
 
@@ -393,8 +393,8 @@ func (this *CompetitionManager)CheckRefreshTop3Data(compId int32) {
 	}
 }
 
-//重新加载缓存
-func (this *CompetitionManager)RefreshPlayerDetailData(compId int32) {
+// 重新加载缓存
+func (this *CompetitionManager) RefreshPlayerDetailData(compId int32) {
 	roundStr := strconv.Itoa(int(compId))
 	keyStr := model.CompetitionIdolScoreRankPrefix + roundStr
 	topListWithScore, err3 := service.GetRedis().ZRevRangeWithScores(keyStr, 0, 2).Result()
@@ -442,7 +442,7 @@ func (this *CompetitionManager) LoadTop3Detail(uid uint64, detail *serverproto.P
 	util.InfoF("[LoadTop3Detail] load role data success uid=%v", uid)
 }
 
-//获取历史赛季奖励
+// 获取历史赛季奖励
 func (this *CompetitionManager) GetHistoryCompetitionReward(uid uint64, SCompetitionId, SCompetitionSubId, ECompetitionId, ECompetitionSubId int32,
 	ssAckMsg *serverproto.SSCompetitionRewardHistoryAck) {
 	if uid <= 0 {
@@ -511,8 +511,8 @@ func (this *CompetitionManager) GetHistoryCompetitionReward(uid uint64, SCompeti
 	}
 }
 
-//uid 给idolUid 投了总共 score 票
-func (this *CompetitionManager)FansVoteChange(idolUid, uid uint64, score int32, competitionId int32) int32 {
+// uid 给idolUid 投了总共 score 票
+func (this *CompetitionManager) FansVoteChange(idolUid, uid uint64, score int32, competitionId int32) int32 {
 	curTime := util.GetCurrentTime()
 
 	roundStr := strconv.Itoa(int(competitionId))
@@ -583,7 +583,7 @@ func (this *CompetitionManager)FansVoteChange(idolUid, uid uint64, score int32,
 	return totalTicket
 }
 
-func (this *CompetitionManager)GetVoteDetail(competitionId int32, ntfMsg *serverproto.SSCompetitionOnVoteNtf) {
+func (this *CompetitionManager) GetVoteDetail(competitionId int32, ntfMsg *serverproto.SSCompetitionOnVoteNtf) {
 	if ntfMsg == nil {
 		return
 	}
@@ -600,7 +600,7 @@ func (this *CompetitionManager)GetVoteDetail(competitionId int32, ntfMsg *server
 	ntfMsg.VoteTarget.Rank = rank
 }
 
-func (this *CompetitionManager)GetIdolVoteData(idolUid uint64, competitionId int32) (serverproto.ErrorCode, int32, int32) {
+func (this *CompetitionManager) GetIdolVoteData(idolUid uint64, competitionId int32) (serverproto.ErrorCode, int32, int32) {
 	field := strconv.FormatUint(idolUid, 10)
 	roundStr := strconv.Itoa(int(competitionId))
 	keyStr := model.CompetitionIdolScoreRankPrefix + roundStr
@@ -613,7 +613,7 @@ func (this *CompetitionManager)GetIdolVoteData(idolUid uint64, competitionId int
 				if rankUid == idolUid {
 					_, _, score := getIdolValByRankScore(topListWithScore[index].Score)
 
-					return serverproto.ErrorCode_ERROR_OK, int32(score), int32(selfRank+1)
+					return serverproto.ErrorCode_ERROR_OK, int32(score), int32(selfRank + 1)
 				}
 			}
 		} else {
@@ -623,13 +623,12 @@ func (this *CompetitionManager)GetIdolVoteData(idolUid uint64, competitionId int
 	return serverproto.ErrorCode_ERROR_FAIL, 0, 0
 }
 
-
-func (this *CompetitionManager)GetVoteRank(page, competitionId int32, ackMsg *serverproto.SSCompetitionVoteRankAck) serverproto.ErrorCode {
+func (this *CompetitionManager) GetVoteRank(page, competitionId int32, ackMsg *serverproto.SSCompetitionVoteRankAck) serverproto.ErrorCode {
 	if ackMsg == nil {
 		return serverproto.ErrorCode_ERROR_FAIL
 	}
 	//todo wangzhaocan 后续改5页
-	if page <  1 || page > 2 {
+	if page < 1 || page > 2 {
 		ackMsg.IsEnd = true
 		return serverproto.ErrorCode_ERROR_OK
 	}
@@ -660,7 +659,7 @@ func (this *CompetitionManager)GetVoteRank(page, competitionId int32, ackMsg *se
 	} else {
 		curCount, err := service.GetRedis().ZCard(keyStr).Result()
 		if err == nil {
-			if int32(curCount) <= endRank + 1 {
+			if int32(curCount) <= endRank+1 {
 				ackMsg.IsEnd = true
 			}
 		}
@@ -668,8 +667,8 @@ func (this *CompetitionManager)GetVoteRank(page, competitionId int32, ackMsg *se
 	return serverproto.ErrorCode_ERROR_OK
 }
 
-//获取自己的粉丝榜
-func (this *CompetitionManager)GetSelfFansInfo(uid uint64, competitionId int32, ackMsg *serverproto.SSCompetitionSelfFansInfoAck) serverproto.ErrorCode {
+// 获取自己的粉丝榜
+func (this *CompetitionManager) GetSelfFansInfo(uid uint64, competitionId int32, ackMsg *serverproto.SSCompetitionSelfFansInfoAck) serverproto.ErrorCode {
 	roundStr := strconv.Itoa(int(competitionId))
 	keyStr := model.CompetitionIdolFansVotePrefix + roundStr
 	fieldStr := strconv.FormatUint(uint64(uid), 10)
@@ -712,20 +711,20 @@ func (this *CompetitionManager)GetSelfFansInfo(uid uint64, competitionId int32,
 			Rank:  int32(rank),
 			Score: data.TicketCount,
 		})
-		if len(ackMsg.FanList) >= 10 {	//只取前十名
+		if len(ackMsg.FanList) >= 10 { //只取前十名
 			break
 		}
 	}
 	return serverproto.ErrorCode_ERROR_OK
 }
 
-func (this *CompetitionManager)GetSingleFansRewardData(idolUid uint64, competitionId int32) (serverproto.ErrorCode, int32) {
+func (this *CompetitionManager) GetSingleFansRewardData(idolUid uint64, competitionId int32) (serverproto.ErrorCode, int32) {
 	bRet, score := this.GetFansRewardData(idolUid, competitionId)
 	return bRet, score
 }
 
-//赛季结束,发送在线馈赠奖励,做临时缓存机制,再最后一批玩家发送请求结束。清空缓存
-func (this *CompetitionManager)GetAllFansReward(msg *serverproto.SSCompetitionFansGetAllRewardReq, ackMsg *serverproto.SSCompetitionFansGetAllRewardAck){
+// 赛季结束,发送在线馈赠奖励,做临时缓存机制,再最后一批玩家发送请求结束。清空缓存
+func (this *CompetitionManager) GetAllFansReward(msg *serverproto.SSCompetitionFansGetAllRewardReq, ackMsg *serverproto.SSCompetitionFansGetAllRewardAck) {
 	if msg == nil || ackMsg == nil {
 		return
 	}
@@ -761,7 +760,7 @@ func (this *CompetitionManager)GetAllFansReward(msg *serverproto.SSCompetitionFa
 	}
 }
 
-func (this *CompetitionManager)GetFansRewardData(idolUid uint64, competitionId int32) (serverproto.ErrorCode, int32) {
+func (this *CompetitionManager) GetFansRewardData(idolUid uint64, competitionId int32) (serverproto.ErrorCode, int32) {
 
 	field := strconv.FormatUint(idolUid, 10)
 	roundStr := strconv.Itoa(int(competitionId))
@@ -784,9 +783,9 @@ func (this *CompetitionManager)GetFansRewardData(idolUid uint64, competitionId i
 	return serverproto.ErrorCode_ERROR_FAIL, 0
 }
 
-//page (1-5)
-func (this *CompetitionManager)GetFansRewardRankInfo(page int32, compId int32, ackMsg *serverproto.SSCompetitionFansRewardRankAck) serverproto.ErrorCode {
-	if page <  1 || page > 5 {
+// page (1-5)
+func (this *CompetitionManager) GetFansRewardRankInfo(page int32, compId int32, ackMsg *serverproto.SSCompetitionFansRewardRankAck) serverproto.ErrorCode {
+	if page < 1 || page > 5 {
 		return serverproto.ErrorCode_ERROR_FAIL
 	}
 	startRank := (page - 1) * 10
@@ -814,7 +813,7 @@ func (this *CompetitionManager)GetFansRewardRankInfo(page int32, compId int32, a
 	} else {
 		curCount, err := service.GetRedis().ZCard(keyStr).Result()
 		if err == nil {
-			if int32(curCount) <= endRank + 1 {
+			if int32(curCount) <= endRank+1 {
 				ackMsg.IsEnd = true
 			}
 		}
@@ -822,7 +821,7 @@ func (this *CompetitionManager)GetFansRewardRankInfo(page int32, compId int32, a
 	return serverproto.ErrorCode_ERROR_OK
 }
 
-func (this *CompetitionManager)AddIdolBoxScore(uid uint64, score int32, compId int32) {
+func (this *CompetitionManager) AddIdolBoxScore(uid uint64, score int32, compId int32) {
 	if score <= 0 {
 		return
 	}
@@ -845,7 +844,7 @@ func (this *CompetitionManager)AddIdolBoxScore(uid uint64, score int32, compId i
 	util.InfoF("[AddIdolBoxScore] add box score success uid:%v, score:%v", uid, score)
 }
 
-func (this *CompetitionManager)GetIdolRankData(idolUid uint64, compId int32, ackMsg *serverproto.SSCompetitionGetPlayerVoteRankAck) serverproto.ErrorCode {
+func (this *CompetitionManager) GetIdolRankData(idolUid uint64, compId int32, ackMsg *serverproto.SSCompetitionGetPlayerVoteRankAck) serverproto.ErrorCode {
 	ackMsg.IdolRankData = &serverproto.FansRankData{
 		Uid: idolUid,
 	}
@@ -857,4 +856,4 @@ func (this *CompetitionManager)GetIdolRankData(idolUid uint64, compId int32, ack
 		ackMsg.IdolRankData.Rank = rank
 	}
 	return err
-}
+}