using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Sog; using Google.Protobuf.WellKnownTypes; namespace Rank { public static class RankUtils { public static RealmRankInfo GetRealmRankInfo(int realmId) { WorldRankData rankData = RankServerUtils.GetRankData(); if (rankData.AllRank.ContainsKey(realmId)) { return rankData.AllRank[realmId]; } return null; } public static RankDataOne GetCreateWorldRankDataOne(int realmId, int rankId) { WorldRankData rankData = RankServerUtils.GetRankData(); RankDataOne oneRank = null; if (!rankData.AllRank.ContainsKey(realmId)) { return oneRank; } if (!rankData.AllRank[realmId].m_rankMap.ContainsKey(rankId)) { oneRank = new RankDataOne(realmId, rankId); rankData.AllRank[realmId].m_rankMap.Add(rankId, oneRank); } else { oneRank = rankData.AllRank[realmId].m_rankMap[rankId]; } return oneRank; } public static RankDataOne GetGlobalRank( int rankId) { WorldRankData rankData = RankServerUtils.GetRankData(); RankDataOne oneRank = null; if (!rankData.GlobalRank.ContainsKey(rankId)) { return null; } oneRank = rankData.GlobalRank[rankId].rankOne; return oneRank; } public static RankDataOne GetCreateGlobalRank(int rankId) { WorldRankData rankData = RankServerUtils.GetRankData(); RankDataOne oneRank = null; oneRank = rankData.GlobalRank[rankId].rankOne; if(oneRank == null) { rankData.GlobalRank[rankId].rankOne = new RankDataOne(0, rankId); oneRank = rankData.GlobalRank[rankId].rankOne; } return oneRank; } public static RankDataOne GetRankDataOne(int realmId, int rankId) { RankServerData serverData = ServerDataObjMgr.GetDataObj(RankDataObjType.RankServerData); if (serverData.m_RankData.TryGetRankDataOne(out RankDataOne oneData, realmId, rankId)) { return oneData; } return null; } public static bool CheckLoadRankDataSuccess(int realmId) { foreach (var rankDesc in RankConfigDescMgr.Instance.ItemTable.Values) { if (rankDesc.type != RankType.Single) continue; RankDataOne rankOne = GetRankDataOne(realmId, rankDesc.rankId); if (rankOne == null) { return false; } if (!rankOne.CheckSuccessLoad()) { return false; } } return true; } public static bool CheckLoadGlobalRankDataSuccess() { foreach (var rankDesc in RankConfigDescMgr.Instance.ItemTable.Values) { if (rankDesc.type != RankType.All) continue; RankDataOne rankOne = GetGlobalRank(rankDesc.rankId); if (rankOne == null) { return false; } if (!rankOne.CheckSuccessLoad()) { return false; } } return true; } } }