قديم 2019-08-08, 09:24 AM
المشاركة #2  
Tefa
  • غير متواجد
افتراضي رد: مشكلة في رانك الدونشين
Nobility.cs


كود:
using System;
using System.Linq;
using System.Collections.Generic;
using KhaledMohamed.Network.GamePackets;
using System.IO;


namespace 
KhaledMohamed.Game.ConquerStructures
{
    public class 
Nobility KhaledMohamed.Network.Writer
    
{
        public static 
ulong MaxDonation 0;
        public static 
ulong MaxDonation1 0;
        public static 
ulong MaxDonation2 0;
        public static 
SafeDictionary<uintNobilityInformationBoard = new SafeDictionary<uintNobilityInformation>(10000);
        public static List<
NobilityInformationBoardList = new List<NobilityInformation>(10000);
        public static 
void Handle(NobilityInfo informationClient.GameState client)
        {
            switch (
information.Type)
            {
                case 
NobilityInfo.Donate:
                    {
                        if (
client.Trade.InTrade)
                            return;

                        
ulong silvers information.dwParam;
                        
bool newDonator false;
                        
client.NobilityInformation.Gender = (byte)(client.Entity.Body 10);
                        if (
client.NobilityInformation.Donation == 0)
                            
newDonator true;
                        if (
information.MoneyType == 1)
                        {
                            
ulong cps silvers 1;
                            if (
client.Entity.ConquerPoints >= cps && client.PokerPlayer == null)
                            {
                                
client.Entity.ConquerPoints -= (uint)cps;
                                
client.NobilityInformation.Donation += silvers;
                            }
                        }
                        else
                        {
                            if (
client.Entity.Money >= silvers && client.PokerPlayer == null)
                            {
                                
client.Entity.Money -= (ulong)silvers;
                                
client.NobilityInformation.Donation += silvers;
                            }
                        }

                        if (!
Board.ContainsKey(client.Entity.UID) && client.NobilityInformation.Donation == silvers && newDonator)
                        {
                            
Board.Add(client.Entity.UIDclient.NobilityInformation);
                            try
                            {
                                
Database.NobilityTable.InsertNobilityInformation(client.NobilityInformation);
                            }
                            catch
                            {
                                
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                            }
                        }
                        else
                        {
                            
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                        }
                        
Sort(client.Entity.UID);
                        break;
                    }
                case 
NobilityInfo.List:
                    {
                        
byte[] packet = new byte[600 8];
                        
WriteUInt16(6000packet);
                        
WriteUInt16(20642packet);
                        
WriteUInt16(24packet);
                        
WriteUInt16(510packet);
                        
WriteUInt16(1012packet);
                        
int offset 120;
                        for (
int i = (int)(information.wParam1 10); information.wParam1 10 10 && BoardList.Counti++)
                        {
                            var 
nob BoardList[i];
                            
WriteUInt32(nob.EntityUIDoffsetpacket);
                            
offset += 4;
                            if (
Kernel.GamePool.ContainsKey(nob.EntityUID))
                            {
                                
WriteUInt32(1offsetpacket);
                                
offset += 4;
                                
WriteUInt32(nob.Meshoffsetpacket);
                                
offset += 4;
                            }
                            else
                            {
                                
offset += 8;
                            }
                            
WriteString(nob.Nameoffsetpacket);
                            
offset += 20;
                            
WriteUInt64(nob.Donationoffsetpacket);
                            
offset += 8;
                            
WriteUInt32((uint)nob.Rankoffsetpacket);
                            
offset += 4;
                            
WriteUInt32((uint)ioffsetpacket);
                            
offset += 4;
                        }
                        
client.Send(packet);

                        
information.Type NobilityInfo.NextRank;
                        
ulong value 0;
                        
information.dwParam2 0;
                        
lock (BoardList)
                        {
                            if (
client.NobilityInformation.Rank == NobilityRank.Prince)
                                
value = (ulong)(BoardList[02].Donation client.NobilityInformation.Donation 1);
                            if (
client.NobilityInformation.Rank == NobilityRank.Duke)
                               
value = (ulong)(BoardList[14].Donation client.NobilityInformation.Donation 1);

                        }
                        
Network.Writer.WriteUInt64(value8information.ToArray());
                        
information.dwParam3 60;
                        
information.dwParam4 uint.MaxValue;
                        
client.Send(information);
                        break;
                    }
            }
        }
        public static 
void Donate(ulong silversClient.GameState client)
        {
            
bool newDonator false;
            
client.NobilityInformation.Gender = (byte)(client.Entity.Body 10);
            if (
client.NobilityInformation.Donation == 0)
                
newDonator true;

            
client.NobilityInformation.Donation += silvers;

            if (!
Board.ContainsKey(client.Entity.UID) && client.NobilityInformation.Donation == silvers && newDonator)
            {
                
Board.Add(client.Entity.UIDclient.NobilityInformation);
                try
                {
                    
Database.NobilityTable.InsertNobilityInformation(client.NobilityInformation);
                }
                catch
                {
                    
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
                }
            }
            else
            {
                
Database.NobilityTable.UpdateNobilityInformation(client.NobilityInformation);
            }
            
Sort(client.Entity.UID);
        }
        public static 
void Sort(uint updateUID)
        {
            
SafeDictionary<uintNobilityInformationsortedBoard = new SafeDictionary<uintNobilityInformation>();

            
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 >= CPanal.Duke)
                    {
                        if (
Program.Nobility == true)
                        {
                            
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 if (
entry.Donation == 1)
                            {
                                
Rank NobilityRank.King;
                            }
                        }  
                    }
                    else
                    {
                        if (
Program.Nobility == true)
                        {
                                
Rank NobilityRank.King;
                        }
                        else
                        {
                            if (
Place CPanal.king)//serverrank 
                            
{
                                
Rank NobilityRank.King;
                            }
                            else if (
Place CPanal.prince)
                            {
                                
Rank NobilityRank.Prince;
                            }
                            else if (
Place CPanal.Duke && Place CPanal.lastDuke)
                            {
                                
Rank NobilityRank.Duke;
                            }
                        }
                    }  
                    var 
oldRank entry.Rank;
                    
entry.Rank Rank;
                    if (
Kernel.GamePool.TryGetValue(entry.EntityUIDout 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."System.Drawing.Color.WhiteMessage.Center), Program.Values);
                            }
                            if (
Rank == NobilityRank.Prince)
                            {
                                
Kernel.SendWorldMessage(new Message("Congratulation! " client.Entity.Name " has the Prince title."System.Drawing.Color.WhiteMessage.Center), Program.Values);
                            }
                            if (
Rank == NobilityRank.King)
                            {
                                
Kernel.SendWorldMessage(new Message("Congratulation! " client.Entity.Name " has become the new King/Queen."System.Drawing.Color.WhiteMessage.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(updatetrue);
                            
client.Entity.NobilityRank entry.Rank;
                        }
                    }
                    
sortedBoard.Add(entry.EntityUIDentry);
                    
Place++;
                }
                catch { }
            }
            
Board sortedBoard;
            
lock (BoardList)
                
BoardList Board.Values.ToList();
        }

        public static 
void Delet(Client.GameState client)
        {
            if (
Game.ConquerStructures.Nobility.Board.ContainsKey(client.Entity.UID))
            {
                
Game.ConquerStructures.Nobility.Board.Remove(client.Entity.UID);
                
Game.ConquerStructures.Nobility.Sort(0);
                foreach (var 
clients in Program.GamePool)
                {
                    if (
Game.ConquerStructures.Nobility.Board.ContainsKey(clients.Entity.UID))
                        
Game.ConquerStructures.Nobility.Sort(client.Entity.UID);
                }
                
Database.MySqlCommand cmd = new Database.MySqlCommand(Database.MySqlCommandType.DELETE).Delete("nobility""EntityUID"client.Entity.UID);
                
cmd.Execute();
            }
        }
    } 

    public class 
NobilityInformation
    
{
        public 
string Name;
        public 
uint EntityUID;
        public 
uint Mesh;
        public 
ulong Donation;
        public 
byte Gender;
        public 
int Position;
        public 
NobilityRank Rank;
        public 
bool king;
        public 
DateTime KingDays;
    }

    public 
enum NobilityRank byte
    
{
        
Serf 0,
        
Knight 1,
        
Baron 3,
        
Earl 5,
        
Duke 7,
        
Prince 9,
        
King 12
    
}


CPanal.cs
بدل دول بالي عندك

كود:
 //Rank\\
                    
king 2,  //عدد الكنجات
              
prince CPanal.king//عدد البرنسات عدل علي رقم 10
              
Duke CPanal.prince,//عدد الدوقات
              
lastDuke CPanal.Duke,
               
Earl ,//عدد الايرلات
               
Baron 0,
             
Knight 0



العلامات المرجعية



الذين يشاهدون محتوى الموضوع الآن : 1 ( الأعضاء 0 والزوار 1)
 

الانتقال السريع



الساعة الآن 03:15 AM

Powered by vBulletin® Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.