bool cbFuncRankingTotal(List <UserRankingTotal> rankingList) { if (null == rankingList || rankingList.Count == 0) { return(false); } // self UserRanking ur = new UserRanking(); var cache = new ShareCacheStruct <UserRankingTotal>(); UserRankingTotal selfURT = new UserRankingTotal(); UserRankingTotal findURT = cache.FindKey(requestPack.UserID); int selfPos = rankingList.FindIndex((o) => { if (o.UserID == requestPack.UserID) { return(true); } return(false); }); if (findURT == null) { selfURT.UserID = requestPack.UserID; selfURT.Total = -1; } else { selfURT.UserID = findURT.UserID; selfURT.Total = findURT.Total; } selfPos = formatPos(selfPos); responsePack.ItemsExScore.Add(new RankData() { pos = selfPos, UserName = selfPos + "," + selfURT.Total, Score = selfURT.Total, UserID = selfURT.UserID }); int maxSend = GameConfigMgr.Instance().getInt("rank_send_num_total", 10); var personCache = new PersonalCacheStruct <GameUser>(); var person = personCache.FindKey(selfURT.UserID.ToString()); for (int i = 0; i < rankingList.Count; ++i) { if (i >= maxSend) { break; } person = personCache.FindKey(rankingList[i].UserID.ToString()); if (null == person) { continue; } responsePack.ItemsExScore.Add(new RankData() { pos = formatPos(i), UserName = person.NickName, Score = rankingList[i].Total, UserID = rankingList[i].UserID }); } return(true); }
static bool addRankingReward(List <UserRanking> rankingList) { if (null == rankingList) { ConsoleLog.showErrorInfo(135, "addRankingReward:Error"); TraceLog.WriteError("Error : addRankingReward"); return(false); } int scoreNum = GameConfigMgr.Instance().getInt("rankclear_scoreNum", 20); int DemoNum = GameConfigMgr.Instance().getInt("rankclear_dimondNum", 10000); int max = Math.Max(scoreNum, DemoNum); // get Score accounding to Ranking var totalCache = new ShareCacheStruct <UserRankingTotal>(); var personCache = new PersonalCacheStruct <GameUser>(); for (int i = 0; i < rankingList.Count; ++i) { if (i < DemoNum) { UserRanking ur = rankingList[i]; int score = getScore(i); UserRankingTotal urt = totalCache.FindKey(ur.UserID); if (null == urt) { UserRankingTotal newUrt = new UserRankingTotal(); newUrt.UserID = ur.UserID; newUrt.Total = score; totalCache.Add(newUrt); } else { urt.ModifyLocked(() => { urt.Total += score; }); } } int UserId = rankingList[i].UserID; GameUser gu = personCache.FindKey(UserId.ToString()); if (i < DemoNum) { if (null != gu) { gu.ModifyLocked(() => { gu.Diamond += getDiamond(i); gu.theTotal += getScore(i); }); } } if (null != gu) { gu.ModifyLocked(() => { gu.preRanking = i + 1; }); } } return(true); }