void OnRequestRaidRankingReceived(ClientPeer peer, OperationRequest operationRequest, SendParameters sendParameters) { var workRankingList = MongoHelper.RaidRankingCollection.GetAllSorting( ).GetAwaiter( ); workRankingList.OnCompleted(() => { var rankingDataList = workRankingList.GetResult( ); if (rankingDataList == null || rankingDataList.Count == 0) { RaidRankingData data = CreateRaidRankingData(peer); var workRankingAdd = MongoHelper.RaidRankingCollection.Add(data).GetAwaiter( ); workRankingAdd.OnCompleted(() => { RankingEvent.OnUpdateRaidRanking(peer, data, null, new List <RaidRankingData> { data }); BossEvent.OnUpdateRaidBoss(peer, 16); }); return; } // TODO : 보스 디졌는지 안디졌는지 확인 var myRankingData = rankingDataList.Find(x => x.Key.Equals(peer.Id)); var lastHitData = rankingDataList.Find(x => x.LastHit == true); if (myRankingData == null) { myRankingData = CreateRaidRankingData(peer); var workRankingAdd = MongoHelper.RaidRankingCollection.Add(myRankingData).GetAwaiter( ); workRankingAdd.OnCompleted(() => { rankingDataList.Add(myRankingData); RankingEvent.OnUpdateRaidRanking(peer, myRankingData, lastHitData, rankingDataList); BossEvent.OnUpdateRaidBoss(peer, 16); }); } else { RankingEvent.OnUpdateRaidRanking(peer, myRankingData, lastHitData, rankingDataList); BossEvent.OnUpdateRaidBoss(peer, 16); } }); }
void ResetRaid() { TheLordServer.Log.Info("레이드 보스 리셋 시작"); var bossData = TheLordServer.Instance.bossDataList[0]; var sheet = TheLordTable.Instance.CharacterTable.CharacterInfoSheet; var record = BaseTable.Get(sheet, "index", RaidBossIndex); bossData.HP = (int)(float)record["hp"]; bossData.CreateTime += bossRemainTime; var workRankingList = MongoHelper.RaidRankingCollection.GetAllSorting( ).GetAwaiter( ); workRankingList.OnCompleted(() => { var result = workRankingList.GetResult( ); var lastHitPlayer = result.Find(x => x.LastHit == true); if (lastHitPlayer != null) { lastHitPlayer.Tier = (int)TierType.God; } const int legend = 1; const int Master = 3; const int Diamond = 5; const int Platinum = 10; const int Gold = 20; const int Silver = 40; const int Bronze = 80; const int Iron = 200; for (int i = 0; i < result.Count; ++i) { if (result[i].Score <= 0) { } else if (i < legend) { result[i].Tier = (int)TierType.Lengend > result[i].Tier ? (int)TierType.Lengend : result[i].Tier; } else if (i < Master) { result[i].Tier = (int)TierType.Master > result[i].Tier ? (int)TierType.Master : result[i].Tier; } else if (i < Diamond) { result[i].Tier = (int)TierType.Diamond > result[i].Tier ? (int)TierType.Diamond : result[i].Tier; } else if (i < Platinum) { result[i].Tier = (int)TierType.Platinum > result[i].Tier ? (int)TierType.Platinum : result[i].Tier; } else if (i < Gold) { result[i].Tier = (int)TierType.Gold > result[i].Tier ? (int)TierType.Gold : result[i].Tier; } else if (i < Silver) { result[i].Tier = (int)TierType.Silver > result[i].Tier ? (int)TierType.Silver : result[i].Tier; } else if (i < Bronze) { result[i].Tier = (int)TierType.Bronze > result[i].Tier ? (int)TierType.Bronze : result[i].Tier; } else if (i < Iron) { result[i].Tier = (int)TierType.Iron > result[i].Tier ? (int)TierType.Iron : result[i].Tier; } else { if (result[i].Score > 0) { result[i].Tier = (int)TierType.Challanger > result[i].Tier ? (int)TierType.Challanger : result[i].Tier; } } result[i].Score = 0; result[i].LastHit = false; var workUpdateRankingScore = MongoHelper.RaidRankingCollection.Update(result[i]).GetAwaiter( ); workUpdateRankingScore.OnCompleted(() => { }); } foreach (var client in TheLordServer.Instance.PeerList) { if (client.userAgent.UserData == null) { continue; } var myRanking = result.Find(x => x.Key == client.Id); if (client.userAgent.UserAssetData != null) { client.userAgent.UserAssetData.Tier = myRanking.Tier; } RankingEvent.OnUpdateRaidRanking(client, myRanking, null, result); BossEvent.OnUpdateRaidBoss(client, 16); } }); UpdateBoss( ); }