Exemplo n.º 1
0
        public static void YesterdaySort()
        {
            SortedDictionary<ulong, SortEntry<uint, ArenaStatistic>> sortDictionary = new SortedDictionary<ulong, SortEntry<uint, ArenaStatistic>>();
            foreach (ArenaStatistic info in ArenaStatistics.Values)
            {
                if (sortDictionary.ContainsKey(info.LastSeasonArenaPoints))
                {
                    SortEntry<uint, ArenaStatistic> entry = sortDictionary[info.LastSeasonArenaPoints];
                    entry.Values.Add(info.EntityID, info);
                }
                else
                {
                    SortEntry<uint, ArenaStatistic> entry = new SortEntry<uint, ArenaStatistic>();
                    entry.Values = new Dictionary<uint, ArenaStatistic>();
                    entry.Values.Add(info.EntityID, info);
                    sortDictionary.Add(info.LastSeasonArenaPoints, entry);
                }
            }
            SafeDictionary<uint, ArenaStatistic> toReplace = new SafeDictionary<uint, ArenaStatistic>(10000);

            uint Place = 1;
            foreach (KeyValuePair<ulong, SortEntry<uint, ArenaStatistic>> entries in sortDictionary.Reverse())
            {
                foreach (uint e in entries.Value.Values.Keys)
                {
                    if (ArenaStatistics[e].YesterdayTotal != 0)
                    {
                        ArenaStatistics[e].LastSeasonRank = Place;
                        Place++;
                        toReplace.Add(e, ArenaStatistics[e]);
                    }
                }
            }

            YesterdayArenaStatistics = toReplace;
        }
Exemplo n.º 2
0
        public static void Sort(uint updateUID)
        {
            SortedDictionary<ulong, SortEntry<uint, NobilityInformation>> sortdict = new SortedDictionary<ulong, SortEntry<uint, NobilityInformation>>();

            foreach (NobilityInformation info in Board.Values)
            {
                if (sortdict.ContainsKey(info.Donation))
                {
                    SortEntry<uint, NobilityInformation> entry = sortdict[info.Donation];
                    entry.Values.Add(info.EntityUID, info);
                }
                else
                {
                    SortEntry<uint, NobilityInformation> entry = new SortEntry<uint, NobilityInformation>();
                    entry.Values = new Dictionary<uint, NobilityInformation>();
                    entry.Values.Add(info.EntityUID, info);
                    sortdict.Add(info.Donation, entry);
                }
            }

            SafeDictionary<uint, NobilityInformation> sortedBoard = new SafeDictionary<uint, NobilityInformation>(10000);

            int Place = 0;
            foreach (KeyValuePair<ulong, SortEntry<uint, NobilityInformation>> entries in sortdict.Reverse())
            {
                foreach (KeyValuePair<uint, NobilityInformation> value in entries.Value.Values)
                {
                    Client.GameState client = null;
                    try
                    {
                        int previousPlace = value.Value.Position;
                        value.Value.Position = Place;
                        NobilityRank Rank = NobilityRank.Serf;

                        if (Place >= 50)
                        {
                            if (value.Value.Donation >= 200000000)
                            {
                                Rank = NobilityRank.Earl;
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Earl in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Earl;
                            }
                            else if (value.Value.Donation >= 100000000)
                            {
                                Rank = NobilityRank.Baron;
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Baron in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Baron;
                            }
                            else if (value.Value.Donation >= 30000000)
                            {
                                Rank = NobilityRank.Knight;
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Knight in Nobility Rank.", System.Drawing.Color.White, Message.TopLeft), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Knight;
                            }
                        }
                        else
                        {
                            if (Place < 3)
                            {
                                //Conquer_Online_Server.ServerBase.Kernel.SendWorldMessage(new Conquer_Online_Server.Network.GamePackets.Message("Congratulation! " + client.Entity.Name + "Donation To King in Nobility Rank!", System.Drawing.Color.White, 2011), Conquer_Online_Server.ServerBase.Kernel.GamePool.Values);
                                Rank = NobilityRank.King;
                                //Conquer_Online_Server.Clan.nobmas(client);
                                // ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To King/Queen in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.King;
                            }
                            else if (Place < 15)
                            {
                                Rank = NobilityRank.Prince;
                                //Conquer_Online_Server.Clan.nobmas(client);
                                // ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Prince in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
                                // Rank = NobilityRank.Prince;
                            }
                            else
                            {
                                Rank = NobilityRank.Duke;
                                //Conquer_Online_Server.Clan.nobmas(client);
                                //ServerBase.Kernel.SendWorldMessage(new Message("Congratulation! " + client.Entity.Name + "Donation To Duke in Nobility Rank.", System.Drawing.Color.White, Message.Center), ServerBase.Kernel.GamePool.Values);
                                //Rank = NobilityRank.Duke;
                            }
                        }
                        var oldRank = value.Value.Rank;
                        value.Value.Rank = Rank;
                        if (ServerBase.Kernel.GamePool.TryGetValue(value.Key, out client))
                        {
                            bool updateTheClient = false;
                            if (oldRank != Rank)
                            {
                                updateTheClient = true;
                            }
                            else
                            {
                                if (previousPlace != Place)
                                {
                                    updateTheClient = true;
                                }
                            }
                            if (updateTheClient || client.Entity.UID == updateUID)
                            {
                                NobilityInfo update = new NobilityInfo(true);
                                update.Type = NobilityInfo.Icon;
                                update.dwParam = value.Key;
                                update.UpdateString(value.Value);
                                client.SendScreen(update, true);
                                client.Entity.NobilityRank = value.Value.Rank;
                            }
                        }
                        sortedBoard.Add(value.Key, value.Value);
                        Place++;
                    }
                    catch { }
                }

            }

            Board = sortedBoard;
            lock (BoardList)
            {
                BoardList = Board.Values.ToList();
            }
        }
Exemplo n.º 3
0
        public static void Sort()
        {
            SortedDictionary<ulong, SortEntry<uint, ArenaStatistic>> sortDictionary = new SortedDictionary<ulong, SortEntry<uint, ArenaStatistic>>();
            foreach (ArenaStatistic info in ArenaStatistics.Values)
            {
                if (sortDictionary.ContainsKey(info.ArenaPoints))
                {
                    SortEntry<uint, ArenaStatistic> entry = sortDictionary[info.ArenaPoints];
                    entry.Values.Add(info.EntityID, info);
                }
                else
                {
                    SortEntry<uint, ArenaStatistic> entry = new SortEntry<uint, ArenaStatistic>();
                    entry.Values = new Dictionary<uint, ArenaStatistic>();
                    entry.Values.Add(info.EntityID, info);
                    sortDictionary.Add(info.ArenaPoints, entry);
                }
            }
            Dictionary<uint, ArenaStatistic> toReplace = new Dictionary<uint, ArenaStatistic>();
            Dictionary<uint, ArenaStatistic> addAtEnd = new Dictionary<uint, ArenaStatistic>();

            uint Place = 1;
            InArenaListCount = 0;
            foreach (KeyValuePair<ulong, SortEntry<uint, ArenaStatistic>> entries in sortDictionary.Reverse())
            {
                foreach (uint e in entries.Value.Values.Keys)
                {
                    if (ArenaStatistics[e].TodayBattles != 0)
                    {
                        ArenaStatistics[e].Rank = Place;
                        Place++;
                        InArenaListCount++;
                        toReplace.Add(e, ArenaStatistics[e]);
                    }
                    else
                    {
                        ArenaStatistics[e].Rank = 0;
                        addAtEnd.Add(e, ArenaStatistics[e]);
                    }
                }
            }
            foreach (var v in addAtEnd)
            {
                toReplace.Add(v.Key, v.Value);
            }
            ArenaStatistics = toReplace;
            ArenaStatisticsList = ArenaStatistics.Values.ToList();
        }