عرض مشاركة واحدة
احصائياتى

الردود
4

المشاهدات
4684
تفاعلات العضو
 
QR تعريفي
QR Code
Tefa

Tefa is on a distinguished road

    غير متواجد

المشاركات
2,515

+التقييم
0.95

تاريخ التسجيل
Jul 2019

الاقامة

نظام التشغيل

رقم العضوية
358
2019-09-16, 03:42 PM
المشاركة 1 
#1  
افتراضي حل مشكله الحساب نازل وواخد رتبه في الدونشين


االسلام عليكم ورحمة الله وبركاته
في بعض السورسات ممكن حساب جديد يكون نازل وتلقيه واخد ايرل او كنج او برنس
الحل

Nobility.cs
سيرش
اقفله من سالب و حط ده مكانه

كود:
 public static void Sort(uint updateUID)
        {
            
SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>();

            
int Place = 0;
            foreach (
NobilityInformation entry in Board.Values.OrderByDescending((p) => p.Donation))
            {
                
Client.GameState client = null;
                try
                {
                    
int previousPlace = entry.Position;
                    
entry.Position = Place;
                    
NobilityRank Rank = NobilityRank.Serf;

                    if (
Place >= 50)
                    {
                        if (
entry.Donation == 1)
                        {
                            
Rank = NobilityRank.King;
                        }
                        else
                        {
                            if (
entry.Donation >= 200000000)
                            {
                                
Rank = NobilityRank.Earl;
                            }
                            else if (
entry.Donation >= 100000000)
                            {
                                
Rank = NobilityRank.Baron;
                            }
                            else if (
entry.Donation >= 30000000)
                            {
                                
Rank = NobilityRank.Knight;
                            }
                            else 
                            {
                                
Rank = NobilityRank.Serf;
                            }
                        }

                    }
                    else
                    {
                        if (
entry.Donation == 1)
                        {
                            
Rank = NobilityRank.King;
                        }
                        else
                        {
                            if (
Place < 2)//serverrank 
                            
{
                                
Rank = NobilityRank.King;
                            }
                            else if (
Place < 24)
                            {
                                
Rank = NobilityRank.Prince;
                            }
                            else
                            {
                                
Rank = NobilityRank.Duke;
                            }
                        }
                    }
                    var 
oldRank = entry.Rank;
                    
entry.Rank = Rank;
                    if (
Kernel.GamePool.TryGetValue(entry.EntityUID, out client))
                    {
                        
bool updateTheClient = false;
                        if (
oldRank != Rank)
                        {
                            
updateTheClient = true;

                            if (
Rank == NobilityRank.Duke)
                            {
                                
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Duke title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
                            }
                            if (
Rank == NobilityRank.Prince)
                            {
                                
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has the Prince title in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
                            }
                            if (
Rank == NobilityRank.King)
                            {
                                
Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + " has become the new King/Queen in Frozen||Hell.", System.Drawing.Color.White, Message.Center), Program.Values);
                            }

                        }
                        else
                        {
                            if (
previousPlace != Place)
                            {
                                
updateTheClient = true;
                            }
                        }
                        if (
updateTheClient || client.Entity.UID == updateUID)
                        {
                            
NobilityInfo update = new NobilityInfo(true);
                            
update.Type = NobilityInfo.Icon;
                            
update.dwParam = entry.EntityUID;
                            
update.UpdateString(entry);
                            
client.SendScreen(update, true);
                            
client.Entity.NobilityRank = entry.Rank;
                        }
                    }
                    
sortedBoard.Add(entry.EntityUID, entry);
                    
Place++;
                }
                catch { }
            }
            
Board = sortedBoard;
            
lock (BoardList)
                
BoardList = Board.Values.ToList();
        }