public static void Handle(byte[] Data, Client.GameState Client)
        {
            QuestInfoPacket info = new QuestInfoPacket(8);
            ushort num = BitConverter.ToUInt16(Data, 4);
            if (num == 3)
            {
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("heroquests").Where("hero", Client.Entity.UID).And("quest", 0xb71b2);
                PhoenixProject.Database.MySqlReader reader = new PhoenixProject.Database.MySqlReader(cmd);
                if (Client != null)
                {
                    info.Type = 3;
                    while (reader.Read())
                    {
                        info.AddQuest(reader.ReadUInt32("quest"), (QuestCompleteTypes)((ushort)reader.ReadUInt32("completeflag")));
                        HeroQuest quest2 = new HeroQuest
                        {
                            Identifier = reader.ReadUInt32("quest"),
                            DailyFinishes =  reader.ReadUInt32("dailyfinishes"),
                            CompleteFlag = (QuestCompleteTypes)((ushort) reader.ReadUInt32("completeflag"))
                        };
                        DateTime time3 = new DateTime(0x7b2, 1, 1);
                        quest2.CompleteTime = time3.ToLocalTime().AddSeconds(reader.ReadUInt32("completetime"));

                       // quest2.CompleteTime = new DateTime().FromUnix(Convert.ToUInt32(reader["completetime"]));
                        quest2.Step = reader.ReadUInt32("step");
                        HeroQuest quest = quest2;
                        Client.Quests.GetOrAdd(quest.Identifier, quest);
                    }
                    reader.Close();
                    reader.Dispose();
                }
                Client.Send((byte[])info);
                if (Client != null)
                {
                    cmd.Select("killtargets").Where("hero", Client.Entity.UID);
                    while (reader.Read())
                    {
                        QuestQuery query = new QuestQuery
                        {
                            Identifier = reader.ReadUInt32("quest"),
                            Unknown2 = reader.ReadUInt32("count")
                        };
                        Client.Send((byte[])query);
                    }
                    reader.Close();
                    reader.Dispose();
                }
            }
            else
            {
                Console.WriteLine("Unhandled QuestInfo (1134) Type "+num+"");
            }
        }
 public static void Flowers(GameState client)
 {
     client.Entity.Flowers = new Flowers();
     if (!FlowerSystemTable.Exists(client.Entity.UID))
     {
         FlowerSystemTable.Insert(client);
     }
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
     cmd.Select("flowers").Where("id", (long)((ulong)client.Entity.UID));
     MySqlReader r = new MySqlReader(cmd);
     if (r.Read())
     {
         client.Entity.Flowers.id = client.Entity.UID;
         client.Entity.Flowers.RedRoses2day = 0u;
         client.Entity.Flowers.Lilies2day = 0u;
         client.Entity.Flowers.Tulips2day = 0u;
         client.Entity.Flowers.Orchads2day = 0u;
         client.Entity.Flowers.RedRoses = r.ReadUInt32("redroses");
         client.Entity.Flowers.Lilies = r.ReadUInt32("lilies");
         client.Entity.Flowers.Tulips = r.ReadUInt32("tulips");
         client.Entity.Flowers.Orchads = r.ReadUInt32("orchads");
     }
     r.Close();
     r.Dispose();
 }
        public static void LoadClaimableItems(Client.GameState client)
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("claimitems").Where("GainerUID", client.Entity.UID);
            MySqlReader r = new MySqlReader(cmd);
            while (r.Read())
            {
                DetainedItem item = new DetainedItem(true);
                item.ItemUID = r.ReadUInt32("ItemUID");
                item.UID = item.ItemUID;
                item.Page = (byte)DetainedItem.ClaimPage;
                item.Item = ConquerItemTable.LoadItem(item.ItemUID);
                item.ConquerPointsCost = r.ReadUInt32("ConquerPointsCost");
                item.OwnerUID = r.ReadUInt32("OwnerUID");
                item.GainerName = r.ReadString("GainerName");
                item.GainerUID = r.ReadUInt32("GainerUID");
                item.OwnerName = r.ReadString("OwnerName");
                item.Date = DateTime.FromBinary(r.ReadInt64("Date"));
                item.DaysLeft = (uint)(TimeSpan.FromTicks(DateTime.Now.Ticks).Days - TimeSpan.FromTicks(item.Date.Ticks).Days);
                if (item.OwnerUID == 500)
                {
                    item.MakeItReadyToClaim();
                    item.GainerUID = r.ReadUInt32("GainerUID");
                    item.OwnerUID = r.ReadUInt32("OwnerUID");
                }
                client.ClaimableItem.Add(item.UID, item);
            }
            r.Close();
            r.Dispose();

            /*ClaimItemCollection items = new ClaimItemCollection();
            items.LoadAndCloseReader(ClaimItem.FetchByParameter("GainerUID", client.Entity.UID));
            for (int x = 0; x < items.Count; x++)
            {
                DetainedItem item = new DetainedItem(true);
                item.ItemUID = items[x].ItemUID;
                item.UID = item.ItemUID - 1;
                item.Page = (byte)DetainedItem.ClaimPage;
                item.Item = ConquerItemTable.LoadItem(item.ItemUID);
                item.ConquerPointsCost = items[x].ConquerPointsCost;
                item.OwnerUID = items[x].OwnerUID;
                item.GainerName = items[x].GainerName;
                item.GainerUID = items[x].GainerUID;
                item.OwnerName = items[x].OwnerName;
                item.Date = DateTime.FromBinary((long)items[x].DateX);
                item.DaysLeft = (uint)(TimeSpan.FromTicks(DateTime.Now.Ticks).Days - TimeSpan.FromTicks(item.Date.Ticks).Days);
                if (item.OwnerUID == 500)
                {
                    item.MakeItReadyToClaim();
                    item.GainerUID = items[x].GainerUID;
                    item.OwnerUID = items[x].OwnerUID;
                }
                client.ClaimableItem.Add(item.UID, item);
            }*/
        }
        /* public static void save(Entity Entity, Statement.SubClass SubClass)
        {

             MySqlCommand Command = new MySqlCommand(MySqlCommandType.UPDATE);
            Command.Update("subclasses")
                .Set("phase", SubClass.Phase)
                .Set("level", SubClass.Level)
                .Where("id", Entity.UID)
                .And("uid", SubClass.ID)
                .Execute();

        }*/
        public static bool Contains(Entity Entity, byte id)
        {
            bool Return = false;
            MySqlCommand Command = new MySqlCommand(MySqlCommandType.SELECT);
            Command.Select("subclasses").Where("id", Entity.UID).And("uid", id);
            PhoenixProject.Database.MySqlReader Reader = new PhoenixProject.Database.MySqlReader(Command);
            if (Reader.Read())
            {
                if (Reader.ReadByte("uid") == id)
                    Return = true;
            }

            return Return;
        }
        public static void LoadArsenal(PhoenixProject.Game.ConquerStructures.Society.Guild Syn)
        {
            Syn.Arsenal = new Arsenal((ushort)Syn.ID);
            MySqlCommand Command = new MySqlCommand(MySqlCommandType.SELECT);
            Command.Select("pt_arsenal").Where("syn_id", Syn.ID).Execute();
            MySqlReader Reader = new MySqlReader(Command);
            while (Reader.Read())
            {
                PhoenixProject.Game.Features.Arsenal_State Arsenal = new PhoenixProject.Game.Features.Arsenal_State();
                Arsenal.ID = (PhoenixProject.Game.Features.Arsenal_ID)Reader.ReadByte("arsenal_id");
                Arsenal.Unlocked = (Reader.ReadByte("arsenal_unlocked") == 1);
                Arsenal.Donation = Reader.ReadUInt32("arsenal_donation");

                if (!Syn.Arsenal.Arsenals.ContainsKey(Arsenal.ID))
                    Syn.Arsenal.Arsenals.Add(Arsenal.ID, Arsenal);
            }
            if (Syn.Arsenal.Arsenals.Count > 0)
            {
                Command = new MySqlCommand(MySqlCommandType.SELECT);
                Command.Select("pt_arsenal_inscribed").Where("syn_id", Syn.ID).Execute();
                Reader = new MySqlReader(Command);
                while (Reader.Read())
                {
                    uint OWNER = Reader.ReadUInt32("uid");
                    string Name = Reader.ReadString("name");
                    uint UID = Reader.ReadUInt32("iten_id");
                    PhoenixProject.Game.Features.Arsenal_ID ID = (PhoenixProject.Game.Features.Arsenal_ID)Reader.ReadByte("iten_atype");
                    if (Syn.Arsenal.Arsenals.ContainsKey(ID))
                    {
                        if (!Syn.Arsenal.Arsenals[ID].Inscribed.ContainsKey(UID))
                        {
                            Syn.Arsenal.Arsenals[ID].Inscribed.Add(UID, new PhoenixProject.Game.Features.Arsenal_Client() { UID = OWNER, Name = Name, iUID = UID });
                        }
                    }
                }
            }
            foreach (PhoenixProject.Game.Features.Arsenal_State astate in Syn.Arsenal.Arsenals.Values)
            {
                foreach (PhoenixProject.Game.Features.Arsenal_Client ac in astate.Inscribed.Values)
                {
                    if (ac.Item == null)
                    {
                        ac.Item = ConquerItemTable.LoadItem(ac.iUID);
                    }
                }
            }
            Reader.Close();
        }
 public static void Load(Client.GameState client)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
      cmd.Select("reincarnation").Where("uid", client.Entity.UID);
     MySqlReader r = new MySqlReader(cmd);
     while (r.Read())
     {
         ReincarnateInfo info = new ReincarnateInfo();
         info.UID = r.ReadUInt32("uid");
         info.Level = r.ReadByte("level");
         info.Experience = r.ReadUInt64("experience");
         if (!ServerBase.Kernel.ReincarnatedCharacters.ContainsKey(info.UID))
             ServerBase.Kernel.ReincarnatedCharacters.Add(info.UID, info);
     }
     r.Close();
     r.Dispose();
 }
        public static void Load()
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("arena");
            MySqlReader reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                Network.GamePackets.ArenaStatistic stat = new Network.GamePackets.ArenaStatistic(true);
                stat.EntityID = reader.ReadUInt32("EntityID");
                stat.Name = reader.ReadString("EntityName");
                stat.LastSeasonRank = reader.ReadUInt32("LastSeasonRank");
                stat.LastSeasonArenaPoints = reader.ReadUInt32("LastSeasonArenaPoints");
                stat.ArenaPoints = reader.ReadUInt32("ArenaPoints");
                stat.TodayWin = reader.ReadByte("TodayWin");
                stat.TodayBattles = reader.ReadByte("TodayBattles"); // doesn't exist in the DB, removed it
                stat.LastSeasonWin = reader.ReadUInt32("LastSeasonWin");
                stat.LastSeasonLose = reader.ReadUInt32("LastSeasonLose");
                stat.TotalWin = reader.ReadUInt32("TotalWin");
                stat.TotalLose = reader.ReadUInt32("TotalLose");
                stat.HistoryHonor = reader.ReadUInt32("HistoryHonor");
                stat.CurrentHonor = reader.ReadUInt32("CurrentHonor");
                stat.Level = reader.ReadByte("Level");
                stat.Class = reader.ReadByte("Class");
                stat.Model = reader.ReadUInt32("Model");
                stat.LastArenaPointFill = DateTime.FromBinary(reader.ReadInt64("ArenaPointFill"));

                if (DateTime.Now.DayOfYear != stat.LastArenaPointFill.DayOfYear)
                {
                    stat.LastSeasonArenaPoints = stat.ArenaPoints;
                    stat.LastSeasonWin = stat.TodayWin;
                    stat.LastSeasonLose = stat.TodayBattles - stat.TodayWin;
                    stat.ArenaPoints = ArenaPointFill(stat.Level);
                    stat.LastArenaPointFill = DateTime.Now;
                    stat.TodayWin = 0;
                    stat.TodayBattles = 0;
                }

                Game.ConquerStructures.Arena.ArenaStatistics.Add(stat.EntityID, stat);
            }
            reader.Close();
            reader.Dispose();
            Game.ConquerStructures.Arena.Sort();
            Game.ConquerStructures.Arena.YesterdaySort();
            Console.WriteLine("Arena information loaded.");
        }
        public static void LoadEnemy(Client.GameState client)
        {
            client.Enemy = new SafeDictionary<uint, PhoenixProject.Game.ConquerStructures.Society.Enemy>(50);
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd = new MySqlCommand(MySqlCommandType.SELECT);

            cmd.Select("enemy").Where("EntityID", client.Entity.UID);
            MySqlReader reader = new MySqlReader(cmd);
            reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                Game.ConquerStructures.Society.Enemy enemy = new Game.ConquerStructures.Society.Enemy();
                enemy.ID = reader.ReadUInt32("EnemyID");
                enemy.Name = reader.ReadString("EnemyName");
                client.Enemy.Add(enemy.ID, enemy);
            }
            reader.Close();
            reader.Dispose();
        }
 public static void Load()
 {
     MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
     command.Select("maps");
     MySqlReader reader = new MySqlReader(command);
     while (reader.Read())
     {
         MapInformation info = new MapInformation();
         info.ID = reader.ReadUInt64("id");
         info.BaseID = reader.ReadUInt64("mapdoc");
         //Console.WriteLine("id " + info.ID + "  base : " + info.BaseID + "");
         info.Status = reader.ReadUInt32("type");
         info.Weather = reader.ReadUInt32("weather");
         MapInformations.Add(info.ID, info);
     }
     reader.Close();
     reader.Dispose();
     Console.WriteLine("Map informations loaded.");
 }
 public static void Load()
 {
     MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
     command.Select("lottery");
     MySqlReader reader = new MySqlReader(command);
     while (reader.Read())
     {
         LotteryItem item = new LotteryItem();
         item.Rank = reader.ReadInt32("rank");
         item.Chance = reader.ReadInt32("chance");
         item.Name = reader.ReadString("prize_name");
         item.ID = reader.ReadUInt32("prize_item");
         item.Color = reader.ReadByte("color");
         item.Sockets = reader.ReadByte("hole_num");
         item.Plus = reader.ReadByte("addition_lev");
         LotteryItems.Add(item);
     }
     reader.Close();
     reader.Dispose();
     Console.WriteLine("Lottery items loaded.");
 }
        public static Interfaces.IConquerItem GetSingleItem(uint UID)
        {
            Interfaces.IConquerItem item = new Network.GamePackets.ConquerItem(true);
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("items").Where("UID", UID);
            PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd);
            if (r.Read())
            {
                item.ID = r.ReadUInt32("ID");
                item.UID = r.ReadUInt32("UID");
                item.Durability = r.ReadUInt16("Durability");
                item.MaximDurability = r.ReadUInt16("MaximDurability");
                item.Position = r.ReadUInt16("Position");
                item.SocketProgress = r.ReadUInt32("SocketProgress");
                item.PlusProgress = r.ReadUInt32("PlusProgress");
                item.SocketOne = (Game.Enums.Gem)r.ReadByte("SocketOne");
                item.SocketTwo = (Game.Enums.Gem)r.ReadByte("SocketTwo");
                item.Effect = (Game.Enums.ItemEffect)r.ReadByte("Effect");
                item.Mode = Game.Enums.ItemMode.Default;
                item.Plus = r.ReadByte("Plus");
                item.Bless = r.ReadByte("Bless");
                item.Bound = r.ReadBoolean("Bound");
                item.Enchant = r.ReadByte("Enchant");
                item.Lock = r.ReadByte("Locked");
                item.UnlockEnd = DateTime.FromBinary(r.ReadInt64("UnlockEnd"));
                item.Suspicious = r.ReadBoolean("Suspicious");

                item.SuspiciousStart = DateTime.FromBinary(r.ReadInt64("SuspiciousStart"));
                item.Color = (Game.Enums.Color)r.ReadByte("Color");
                item.Warehouse = r.ReadUInt16("Warehouse");
                if (item.Lock == 2)
                    if (DateTime.Now >= item.UnlockEnd)
                        item.Lock = 0;
            }
            r.Close();
            //r.Close();
            r.Dispose();

            return item;
        }
        public static void Load(Client.GameState client)
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("pk_explorer").Where("uid", client.Account.EntityID);
            MySqlReader r = new MySqlReader(cmd);
            while (r.Read())
            {
                Game.PkExpeliate pk = new Game.PkExpeliate();
                pk.UID = r.ReadUInt32("killed_uid");
                pk.Name = r.ReadString("killed_name");
                pk.KilledAt = r.ReadString("killed_map");
                pk.LostExp = r.ReadUInt32("lost_exp");
                pk.Times = r.ReadUInt32("times");
                pk.Potency = r.ReadUInt32("battle_power");
                pk.Level = r.ReadByte("level");
                //client.Entity.PkExplorerValues.SafeAdd(pk.UID, pk);
                client.Entity.PkExplorerValues.Add(pk.UID, pk);

            }
            r.Close();
            r.Dispose();
        }
 public static void PkExploitAdd(Client.GameState client, uint UIDEnemy, Game.PkExpeliate pk)
 {
     MySqlCommand cmds = new MySqlCommand(MySqlCommandType.SELECT);
     cmds.Select("pk_explorer").Where("uid", client.Account.EntityID);
     MySqlReader rdr = new MySqlReader(cmds);
     if (rdr.Read())
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE);
         cmd.Update("pk_explorer")
              .Set("killed_uid", UIDEnemy)
              .Set("killed_name", pk.Name).Set("killed_map", pk.KilledAt)
              .Set("lost_exp", pk.LostExp).Set("times", pk.Times++)
              .Set("battle_power", pk.Potency).Set("level", pk.Level);
         cmd.Execute();
         if (!client.Entity.PkExplorerValues.ContainsKey(pk.UID))
         {
             client.Entity.PkExplorerValues.Add(pk.UID, pk);
         }
         else
         {
             client.Entity.PkExplorerValues.Remove(pk.UID);
             client.Entity.PkExplorerValues.Add(pk.UID, pk);
         }
     }
     else
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
         cmd.Insert("pk_explorer")
              .Insert("uid", pk.UID).Insert("killed_uid", UIDEnemy)
              .Insert("killed_name", pk.Name).Insert("killed_map", pk.KilledAt)
              .Insert("lost_exp", pk.LostExp).Insert("times", pk.Times)
              .Insert("battle_power", pk.Potency).Insert("level", pk.Level);
         cmd.Execute();
         if (!client.Entity.PkExplorerValues.ContainsKey(pk.UID))
             client.Entity.PkExplorerValues.Add(pk.UID, pk);
     }
     rdr.Close();
     rdr.Dispose();
 }
 private static bool Exists(uint id)
 {
     bool result;
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("flowers").Where("id", (long)((ulong)id));
         MySqlReader r = new MySqlReader(cmd);
         if (r.Read())
         {
             r.Close();
             r.Dispose();
             result = true;
             return result;
         }
     }
     catch
     {
     }
     result = false;
     return result;
 }
        public static void GetMembers()
        {
            foreach (KeyValuePair<uint, Game.Clans> G in PhoenixProject.ServerBase.Kernel.ServerClans)
            {
                Game.Clans clan = G.Value;
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("entities").Where("ClanId", clan.ClanId);
                PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd);
                while (r.Read())
                {

                    Game.ClanMembers member = new PhoenixProject.Game.ClanMembers();
                    member.Donation = r.ReadUInt32("ClanDonation");
                    //member.Rank = r.ReadByte("ClanRank");
                    member.UID = r.ReadUInt32("UID");
                    member.Name = r.ReadString("Name");
                    member.Class = r.ReadUInt16("Class");
                    member.Level = r.ReadByte("Level");

                    if (clan.ClanLider == member.Name)
                    {
                        member.Rank = 100;
                    }
                    else
                    {
                        member.Rank = 10;
                    }

                    if (!clan.Members.ContainsKey(member.UID))
                        clan.Members.Add(member.UID, member);
                }
                r.Close();
                //r.Close();
                r.Dispose();
                //Console.WriteLine("1818");
            }
        }
 public AccountTable(string username)
 {
     this.Username = username;
     this.Password = "";
     this.IP = "";
     this.LastCheck = DateTime.Now;
     this.State = AccountState.DoesntExist;
     this.EntityID = 0;
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
     cmd.Select("accounts").Where("Username", username);
     MySqlReader r = new MySqlReader(cmd);
     if (r.Read())
     {
         exists = true;
         this.Password = r.ReadString("Password");
         this.IP = r.ReadString("IP");
         this.EntityID = r.ReadUInt32("EntityID");
         this.LastCheck = DateTime.FromBinary(r.ReadInt64("LastCheck"));
         this.State = (AccountState)r.ReadByte("State");
         this.Email = r.ReadString("Email");
     }
     r.Close();
     r.Dispose();
 }
        public static void Load(Entity Entity)
        {
            MySqlCommand Command = new MySqlCommand(MySqlCommandType.SELECT);
            Command.Select("subclasses").Where("id", Entity.UID);
            MySqlReader Reader = new MySqlReader(Command);
            while (Reader.Read())
            {
                Statement.SubClass Sub = new Statement.SubClass();
                Sub.ID = Reader.ReadByte("uid");
                Sub.Level = Reader.ReadByte("level");
                Sub.Phase = Reader.ReadByte("phase");
                Entity.SubClasses.Classes.Add(Sub.ID, Sub);

                Game_SubClass packet = new Game_SubClass();
                packet.ClassId = (Game_SubClass.ID)Sub.ID;
                packet.Phase = Sub.Phase;
                packet.Type = Game_SubClass.Types.Learn;
                Entity.Owner.Send(packet);
                packet.Type = Game_SubClass.Types.MartialPromoted;
                Entity.Owner.Send(packet);
            }
            Reader.Close();
            Reader.Dispose();
        }
        public static void LoadAllClans()
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("Clans");
            PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd);
            while (r.Read())
            {
                Game.Clans clan = new PhoenixProject.Game.Clans();
                clan.ClanLider = r.ReadString("Leader");
                clan.ClanId = r.ReadUInt32("ClanID");
                clan.ClanName = r.ReadString("Name");
                clan.ClanBuletion = r.ReadString("Bulletin");
                clan.ClanDonation = r.ReadUInt32("Fund");
                clan.ClanLevel = r.ReadByte("Level");
                if (!PhoenixProject.ServerBase.Kernel.ServerClans.ContainsKey(clan.ClanId))
                    PhoenixProject.ServerBase.Kernel.ServerClans.Add(clan.ClanId, clan);
            }
            r.Close();
            //r.Close();
            r.Dispose();

            Console.WriteLine("Clans Loading " + PhoenixProject.ServerBase.Kernel.ServerClans.Count);
            GetMembers();
               // Console.WriteLine("1515");
            foreach (Game.Clans c in ServerBase.Kernel.ServerClans.Values)
            {
                c.LoadAssociates();
            }
        }
        /* public static void LoadKnownPersons(Client.GameState client)
        {
            client.Friends = new SafeDictionary<uint, Friend>(50);
            client.Enemy = new SafeDictionary<uint, PhoenixProject.Game.ConquerStructures.Society.Enemy>(10);
            client.Partners = new SafeDictionary<uint, TradePartner>(40);
            client.Apprentices = new SafeDictionary<uint, PhoenixProject.Game.ConquerStructures.Society.Apprentice>(10);
            FriendXCollection entities = new FriendXCollection();
            entities.LoadAndCloseReader(FriendX.FetchByParameter("EntityID", client.Entity.UID));
            for (int x = 0; x < entities.Count; x++)
            {
                Friend friend = new Friend();
                friend.ID = (uint)entities[x].FriendID;
                friend.Name = entities[x].FriendName;
                friend.Message = entities[x].Message;
                client.Friends.Add(friend.ID, friend);
            }

            EnemyCollection entities2 = new EnemyCollection();
            entities2.LoadAndCloseReader(Conquer.Database.Enemy.FetchByParameter("EntityID", client.Entity.UID));
            for (int x = 0; x < entities2.Count; x++)
            {
                PhoenixProject.Game.ConquerStructures.Society.Enemy enemy = new PhoenixProject.Game.ConquerStructures.Society.Enemy();
                enemy.ID = (uint)entities2[x].EnemyID;
                enemy.Name = entities2[x].EnemyName;
                client.Enemy.Add(enemy.ID, enemy);
            }

            PartnerCollection entities3 = new PartnerCollection();
            entities3.LoadAndCloseReader(Conquer.Database.Partner.FetchByParameter("EntityID", client.Entity.UID));
            for (int x = 0; x < entities3.Count; x++)
            {
                TradePartner partner = new TradePartner();
                partner.ID = (uint)entities3[x].PartnerID;
                partner.Name = entities3[x].PartnerName;
                partner.ProbationStartedOn = DateTime.FromBinary(entities3[x].ProbationStartedOn);
                client.Partners.Add(partner.ID, partner);
            }

            ApprenticeCollection entities4 = new ApprenticeCollection();
            entities4.LoadAndCloseReader(Conquer.Database.Apprentice.FetchByParameter("MentorID", client.Entity.UID));
            for (int x = 0; x < entities4.Count; x++)
            {
                PhoenixProject.Game.ConquerStructures.Society.Apprentice app = new PhoenixProject.Game.ConquerStructures.Society.Apprentice();
                app.ID = (uint)entities4[x].ApprenticeID;
                app.Name = entities4[x].ApprenticeName;
                app.EnroleDate = (uint)entities4[x].EnroleDate;
                app.Actual_Experience = (ulong)entities4[x].ActualExperience;
                app.Total_Experience = (ulong)entities4[x].TotalExperience;
                app.Actual_Plus = (ushort)entities4[x].ActualPlus;
                app.Total_Plus = (ushort)entities4[x].TotalPlus;
                app.Actual_HeavenBlessing = (ushort)entities4[x].ActualHeavenBlessing;
                app.Total_HeavenBlessing = (ushort)entities4[x].TotalHeavenBlessing;
                client.PrizeExperience += app.Actual_Experience;
                client.PrizePlusStone += app.Actual_Plus;
                client.PrizeHeavenBlessing += app.Actual_HeavenBlessing;
                client.Apprentices.Add(app.ID, app);
                client.apprtnum += 1;

                if (client.PrizeExperience > 50 * 606)
                    client.PrizeExperience = 50 * 606;
            }

            ApprenticeCollection entities5 = new ApprenticeCollection();
            entities5.LoadAndCloseReader(Conquer.Database.Apprentice.FetchByParameter("ApprenticeID", client.Entity.UID));
            for (int x = 0; x < entities5.Count; x++)
            {
                client.Mentor = new Mentor();
                client.Mentor.ID = (uint)entities5[x].MentorID;
                client.Mentor.Name = entities5[x].MentorName;
                client.Mentor.EnroleDate = (uint)entities5[x].EnroleDate;
                client.AsApprentice = new PhoenixProject.Game.ConquerStructures.Society.Apprentice();
                client.AsApprentice.ID = client.Entity.UID;
                client.AsApprentice.Name = client.Entity.Name;
                client.AsApprentice.EnroleDate = client.Mentor.EnroleDate;
                client.AsApprentice.Actual_Experience = (ulong)entities5[x].ActualExperience;
                client.AsApprentice.Total_Experience = (ulong)entities5[x].TotalExperience;
                client.AsApprentice.Actual_Plus = (ushort)entities5[x].ActualPlus;
                client.AsApprentice.Total_Plus = (ushort)entities5[x].TotalPlus;
                client.AsApprentice.Actual_HeavenBlessing = (ushort)entities5[x].ActualHeavenBlessing;
                client.AsApprentice.Total_HeavenBlessing = (ushort)entities5[x].TotalHeavenBlessing;
            }
        }*/
        public static void LoaderFriends(Client.GameState client)
        {
            client.Friends = new SafeDictionary<uint, Friend>(50);

            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("friends").Where("EntityID", client.Entity.UID);
            MySqlReader reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                Friend friend = new Friend();
                friend.ID = reader.ReadUInt32("FriendID");
                friend.Name = reader.ReadString("FriendName");
                friend.Message = reader.ReadString("Message");
                client.Friends.Add(friend.ID, friend);
            }
            reader.Close();
            reader.Dispose();
        }
        public static void LoadMentor(Client.GameState client)
        {
            client.Apprentices = new SafeDictionary<uint, PhoenixProject.Game.ConquerStructures.Society.Apprentice>(10);
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);

            cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("apprentice").Where("MentorID", client.Entity.UID);
            MySqlReader reader = new MySqlReader(cmd);
            //reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                Game.ConquerStructures.Society.Apprentice app = new Game.ConquerStructures.Society.Apprentice();
                app.ID = reader.ReadUInt32("ApprenticeID");
                app.Name = reader.ReadString("ApprenticeName");
                app.EnroleDate = reader.ReadUInt32("EnroleDate");
                app.Actual_Experience = reader.ReadUInt64("Actual_Experience");
                app.Total_Experience = reader.ReadUInt64("Total_Experience");
                app.Actual_Plus = reader.ReadUInt16("Actual_Plus");
                app.Total_Plus = reader.ReadUInt16("Total_Plus");
                app.Actual_HeavenBlessing = reader.ReadUInt16("Actual_HeavenBlessing");
                app.Total_HeavenBlessing = reader.ReadUInt16("Total_HeavenBlessing");
                client.PrizeExperience += app.Actual_Experience;
                client.PrizePlusStone += app.Actual_Plus;
                client.PrizeHeavenBlessing += app.Actual_HeavenBlessing;
                client.Apprentices.Add(app.ID, app);

                if (client.PrizeExperience > 50 * 606)
                    client.PrizeExperience = 50 * 606;
            }
            reader.Close();
            reader.Dispose();

            cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("apprentice").Where("ApprenticeID", client.Entity.UID);
            reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                client.Mentor = new Mentor();
                client.Mentor.ID = reader.ReadUInt32("MentorID");
                client.Mentor.Name = reader.ReadString("MentorName");
                client.Mentor.EnroleDate = reader.ReadUInt32("EnroleDate");
                client.AsApprentice = new Game.ConquerStructures.Society.Apprentice();
                client.AsApprentice.ID = client.Entity.UID;
                client.AsApprentice.Name = client.Entity.Name;
                client.AsApprentice.EnroleDate = client.Mentor.EnroleDate;
                client.AsApprentice.Actual_Experience = reader.ReadUInt64("Actual_Experience");
                client.AsApprentice.Total_Experience = reader.ReadUInt64("Total_Experience");
                client.AsApprentice.Actual_Plus = reader.ReadUInt16("Actual_Plus");
                client.AsApprentice.Total_Plus = reader.ReadUInt16("Total_Plus");
                client.AsApprentice.Actual_HeavenBlessing = reader.ReadUInt16("Actual_HeavenBlessing");
                client.AsApprentice.Total_HeavenBlessing = reader.ReadUInt16("Total_HeavenBlessing");
            }
            reader.Close();
            reader.Dispose();
        }
Ejemplo n.º 21
0
 public void LoadAssociates()
 {
     MySqlCommand Command = new MySqlCommand(MySqlCommandType.SELECT);
     Command.Select("clanrelation").Where("clanid", this.ClanId);
     PhoenixProject.Database.MySqlReader cmd = new PhoenixProject.Database.MySqlReader(Command);
     while (cmd.Read())
     {
         UInt32 AssociateId = cmd.ReadUInt32("associatedid");
         Network.GamePackets.ClanRelations.RelationTypes Type = (Network.GamePackets.ClanRelations.RelationTypes)(cmd.ReadByte("type"));
         Game.Clans c;
         if (ServerBase.Kernel.ServerClans.TryGetValue(AssociateId, out c))
         {
             if (Type == Network.GamePackets.ClanRelations.RelationTypes.Allies)
                 this.Allies.Add(AssociateId, c);
             else
                 this.Enemies.Add(AssociateId, c);
         }
       
     }
     cmd.Close();
     cmd.Dispose();
     //Console.WriteLine("4444");
 }
        public static void LoadDetainedItems(Client.GameState client)
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("detaineditems").Where("OwnerUID", client.Entity.UID);
            MySqlReader r = new MySqlReader(cmd);
            while (r.Read())
            {
                DetainedItem item = new DetainedItem(true);
                item.ItemUID = r.ReadUInt32("ItemUID");
                item.UID = item.ItemUID ;
               // Console.WriteLine("S " + item.UID + "");
                item.Item = ConquerItemTable.LoadItem(item.ItemUID);
                item.ConquerPointsCost = r.ReadUInt32("ConquerPointsCost");
                item.OwnerUID = r.ReadUInt32("OwnerUID");
                item.OwnerName = r.ReadString("OwnerName");
                item.GainerUID = r.ReadUInt32("GainerUID");
                item.GainerName = r.ReadString("GainerName");
                item.Date = DateTime.FromBinary(r.ReadInt64("Date"));
                item.DaysLeft = (uint)(TimeSpan.FromTicks(DateTime.Now.Ticks).Days - TimeSpan.FromTicks(item.Date.Ticks).Days);
                if (DateTime.Now < item.Date.AddDays(7))
                    client.DeatinedItem.Add(item.UID, item);
                else
                    if (item.Bound)
                        Claim(item.UID, client);
            }
            r.Close();

               /* DetaineditemCollection items = new DetaineditemCollection();
            items.LoadAndCloseReader(Detaineditem.FetchByParameter("OwnerUID", client.Entity.UID));
            for (int x = 0; x < items.Count; x++)
            {
                DetainedItem item = new DetainedItem(true);
                item.ItemUID = items[x].ItemUID;
                item.UID = item.ItemUID - 1;
                item.Item = ConquerItemTable.LoadItem(item.ItemUID);
                item.ConquerPointsCost = items[x].ConquerPointsCost;
                item.OwnerUID = items[x].OwnerUID;
                item.GainerName = items[x].OwnerName;
                item.GainerUID = items[x].GainerUID;
                item.OwnerName = items[x].GainerName;
                item.Date = DateTime.FromBinary((long)items[x].DateX);
                item.DaysLeft = (uint)(TimeSpan.FromTicks(DateTime.Now.Ticks).Days - TimeSpan.FromTicks(item.Date.Ticks).Days);
                if (DateTime.Now < item.Date.AddDays(7))
                    client.DeatinedItem.Add(item.UID, item);
                else
                    if (item.Bound)
                        Claim(item, client);
            }*/
        }
Ejemplo n.º 23
0
        public static void LoadHouse()
        {
            MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
            command.Select("house");
            PhoenixProject.Database.MySqlReader reader = new PhoenixProject.Database.MySqlReader(command);
            while (reader.Read())
            {
                uint id;
                uint BaseID;
                uint HouseLevel;
                //MapsTable.MapInformation info = new MapsTable.MapInformation();
                id = reader.ReadUInt16("id");
                BaseID = 3024;
                // info.Status = reader.ReadUInt32("type");
                // info.Weather = reader.ReadUInt32("weather");
                id = reader.ReadUInt32("owner");
                HouseLevel = reader.ReadUInt32("HouseLevel");
                // info.Box = reader.ReadUInt32("Box");
                // info.BoxX = reader.ReadUInt32("BoxX");
                // info.BoxY = reader.ReadUInt32("BoxY");
                bool Success = CreateDynamicMap2(id, (ushort)BaseID, id, HouseLevel);

            }
            reader.Close();
            reader.Dispose();
            Console.WriteLine("Houses Loaded informations loaded.");
        }
        public void Load(Client.GameState h)
        {
            MySqlCommand Command = new MySqlCommand(MySqlCommandType.SELECT);
            Command.Select("heroquests").Where("hero", h.Entity.UID).And("quest", 0xb71b0);
            PhoenixProject.Database.MySqlReader cmd2 = new PhoenixProject.Database.MySqlReader(Command);

            if (cmd2.Read())
            {
                this.QuestGiver = cmd2.ReadUInt32("npc");
                this.Kills = cmd2.ReadUInt16("step");
                this.CompletedTimes = cmd2.ReadByte("dailyfinishes");
            }
            else
            {
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
                cmd.Insert("heroquests").Insert("hero", h.Entity.UID).Insert("quest", 0xb71b0).Execute();

            }
        }
        public static void LoadPartner(Client.GameState client)
        {
            client.Partners = new SafeDictionary<uint, TradePartner>(40);

            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);

            cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("partners").Where("EntityID", client.Entity.UID);
            MySqlReader reader = new MySqlReader(cmd);
            reader = new MySqlReader(cmd);
            while (reader.Read())
            {
                Game.ConquerStructures.Society.TradePartner partner = new Game.ConquerStructures.Society.TradePartner();
                partner.ID = reader.ReadUInt32("PartnerID");
                partner.Name = reader.ReadString("PartnerName");
                partner.ProbationStartedOn = DateTime.FromBinary(reader.ReadInt64("ProbationStartedOn"));
                client.Partners.Add(partner.ID, partner);
            }
            reader.Close();
            reader.Dispose();
        }
        public static void Load()
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("specialdrops");
            PhoenixProject.Database.MySqlReader rdr = new PhoenixProject.Database.MySqlReader(cmd);
            while (rdr.Read())
            {
                SpecialItemDrop sitem = new SpecialItemDrop();
                sitem.ItemID = rdr.ReadInt32("itemid");
                sitem.Rate = rdr.ReadInt32("rate");
                sitem.Discriminant = rdr.ReadInt32("discriminant");
                sitem.Map = rdr.ReadUInt64("map");
                SpecialItemDropList.Add(sitem);
            }
            rdr.Close();
            rdr.Dispose();
            MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
            command.Select("monsterinfos");
            PhoenixProject.Database.MySqlReader reader = new PhoenixProject.Database.MySqlReader(command);
            while (reader.Read())
            {
                MonsterInformation mf = new MonsterInformation();
                mf.ID = reader.ReadUInt32("id");
                mf.Name = reader.ReadString("name");
                mf.Mesh = reader.ReadUInt16("lookface");
                mf.Level = reader.ReadByte("level");
                mf.Hitpoints = reader.ReadUInt32("life");
                ServerBase.IniFile IniFile = new ServerBase.IniFile(ServerBase.Constants.MonstersPath);
                if (IniFile.ReadString(mf.Name, "MaxLife") != "")
                {
                    if (uint.Parse(IniFile.ReadString(mf.Name, "MaxLife")) != 0)
                    {
                        mf.Hitpoints = uint.Parse(IniFile.ReadString(mf.Name, "MaxLife"));
                        byte boss = byte.Parse(IniFile.ReadString(mf.Name, "Boss"));
                        if (boss == 0)
                            mf.Boss = false;
                        else mf.Boss = true;
                    }
                }
                mf.ViewRange = reader.ReadUInt16("view_range");
                mf.AttackRange = reader.ReadUInt16("attack_range");
                mf.AttackType = reader.ReadByte("attack_user");
                mf.MinAttack = reader.ReadUInt32("attack_min");
                mf.MaxAttack = reader.ReadUInt32("attack_max");
                mf.SpellID = reader.ReadUInt16("magic_type");
                mf.MoveSpeed = reader.ReadInt32("move_speed");
                mf.RunSpeed = reader.ReadInt32("run_speed");
                mf.OwnItemID = reader.ReadInt32("ownitem");
                mf.HPPotionID = reader.ReadInt32("drop_hp");
                mf.MPPotionID = reader.ReadInt32("drop_mp");
                mf.OwnItemRate = reader.ReadInt32("ownitemrate");
                mf.AttackSpeed = reader.ReadInt32("attack_speed");
                mf.ExtraExperience = reader.ReadUInt32("extra_exp");
                uint MoneyDropAmount = reader.ReadUInt16("level");
                if (MoneyDropAmount != 0)
                {
                    mf.MaxMoneyDropAmount = MoneyDropAmount * 25;
                    if (mf.MaxMoneyDropAmount != 0)
                        mf.MinMoneyDropAmount = 1;
                }
                if (mf.MoveSpeed <= 500)
                    mf.MoveSpeed += 500;
                if (mf.AttackSpeed <= 500)
                    mf.AttackSpeed += 500;
                MonsterInfos.Add(mf.ID, mf);
                byte lvl = mf.Level;
                if (mf.Name == "Slinger" ||
                    mf.Name == "GoldGhost" ||
                    mf.Name == "AgileRat" ||
                    mf.Name == "Bladeling" ||
                    mf.Name == "BlueBird" ||
                    mf.Name == "BlueFiend" ||
                    mf.Name == "MinotaurL120")
                {
                    mf.LabirinthDrop = true;
                    lvl = 20;
                }
                if (!ItemDropCache.ContainsKey(lvl))
                {
                    List<uint> itemdroplist = new List<uint>();
                    foreach (ConquerItemBaseInformation itemInfo in ConquerItemInformation.BaseInformations.Values)
                    {

                        if (itemInfo.ID >= 800000 && itemInfo.ID <= 824014)
                            continue;
                        ushort position = Network.PacketHandler.ItemPosition(itemInfo.ID);
                        if (Network.PacketHandler.IsArrow(itemInfo.ID) || itemInfo.Level == 0 || itemInfo.Level > 121)
                            continue;
                        if (position < 9 && position != 7)
                        {
                            if (itemInfo.Level == 100)
                                if (itemInfo.Name.Contains("Dress"))
                                    continue;
                            if (itemInfo.Level > 121)
                                continue;
                            int diff = (int)lvl - (int)itemInfo.Level;
                            if (!(diff > 10 || diff < -10))
                            {
                                itemdroplist.Add(itemInfo.ID);
                            }
                        }
                        if (position == 10 || position == 11 && lvl >= 70)
                            itemdroplist.Add(itemInfo.ID);
                    }
                    ItemDropCache.Add(lvl, itemdroplist);
                }
                if (mf.Boss)
                {
                    List<uint> itemdroplist = new List<uint>();
                    foreach (ConquerItemBaseInformation itemInfo in ConquerItemInformation.BaseInformations.Values)
                    {
                        if (itemInfo.ID >= 800000 && itemInfo.ID <= 824014)
                        {
                            if (itemInfo.PurificationLevel <= 3)
                            {
                                int diff = (int)mf.Level - (int)itemInfo.Level;
                                if (!(diff > 10 || diff < -10))
                                {
                                    itemdroplist.Add(itemInfo.ID);
                                }
                            }
                        }
                    }
                    SoulItemCache.Add(lvl, itemdroplist);
                }
            }

            reader.Close();
            reader.Dispose();
            Console.WriteLine("Monster information loaded.");
            Console.WriteLine("Monster drops generated.");
        }
 public static void LoadTop8()
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
     cmd.Select("elitepk");
     MySqlReader r = new MySqlReader(cmd);
     while (r.Read())
     {
         Elite_client client = new Elite_client(r.ReadUInt32("UID"), r.ReadUInt16("Avatar"), r.ReadUInt16("Mesh"), r.ReadString("Name"), r.ReadUInt32("Points"), r.ReadUInt16("Postion"), r.ReadByte("MyTitle"));
         if (!Top8.ContainsKey(client.UID))
             Top8.Add(client.UID, client);
     }
     r.Close();
     r.Dispose();
 }
        public static void NextClan()
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
            cmd.Select("clans");
            PhoenixProject.Database.MySqlReader r = new PhoenixProject.Database.MySqlReader(cmd);
            while (r.Read())
            {
                uint uid = r.ReadUInt32("ClanID");
                if (uid > 0)
                {
                    if (uid > Program.nextClanid)
                        Program.nextClanid = uid;
                }
            }
            r.Close();
            //r.Close();
            r.Dispose();

            Program.nextClanid += 1;
            Console.WriteLine("Last Clan ID: " + Program.nextClanid + "");
        }
        public static void Load()
        {
            MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT);
            command.Select("guilds");
            MySqlReader reader = new MySqlReader(command);
            while (reader.Read())
            {
                PhoenixProject.Game.ConquerStructures.Society.Guild guild = new PhoenixProject.Game.ConquerStructures.Society.Guild(reader.ReadString("LeaderName"));
                guild.ID = reader.ReadUInt16("ID");
                guild.Name = reader.ReadString("Name");
                guild.Wins = reader.ReadUInt32("Wins");
                guild.Losts = reader.ReadUInt32("Losts");
                guild.Bulletin = reader.ReadString("Bulletin");
                guild.SilverFund = reader.ReadUInt32("SilverFund");
                guild.ConquerPointFund = reader.ReadUInt32("ConquerPointFund");
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("entities").Where("GuildID", guild.ID);
                MySqlReader rdr = new MySqlReader(cmd);
                while (rdr.Read())
                {
                    PhoenixProject.Game.ConquerStructures.Society.Guild.Member member = new PhoenixProject.Game.ConquerStructures.Society.Guild.Member(guild.ID);
                    member.ID = rdr.ReadUInt32("UID");
                    member.Name = rdr.ReadString("Name");
                    member.Level = rdr.ReadByte("Level");

                    if (Game.ConquerStructures.Nobility.Board.ContainsKey(member.ID))
                    {
                        member.NobilityRank = Game.ConquerStructures.Nobility.Board[member.ID].Rank;
                        member.Gender = Game.ConquerStructures.Nobility.Board[member.ID].Gender;
                    }

                    member.Rank = (PhoenixProject.Game.Enums.GuildMemberRank)rdr.ReadUInt16("GuildRank");
                    if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.GuildLeader)
                        guild.LeaderName = member.Name;
                    else if (member.Rank == PhoenixProject.Game.Enums.GuildMemberRank.DeputyLeader)
                        guild.DeputyLeaderCount++;
                    member.SilverDonation = rdr.ReadUInt64("GuildSilverDonation");
                    member.ConquerPointDonation = rdr.ReadUInt64("GuildConquerPointDonation");
                    guild.Members.Add(member.ID, member);
                }
                guild.MemberCount = (uint)guild.Members.Count;
                ServerBase.Kernel.Guilds.Add(guild.ID, guild);
                Database.ArsenalTable.LoadArsenal(guild);
                rdr.Close();
                rdr.Dispose();
            }
            reader.Close();
            reader.Dispose();
            command = new MySqlCommand(MySqlCommandType.SELECT);
            command.Select("guildally");
            reader = new MySqlReader(command);
            while (reader.Read())
            {
                ushort guildID = reader.ReadUInt16("GuildID");
                ushort allyID = reader.ReadUInt16("AllyID");
                if (ServerBase.Kernel.Guilds.ContainsKey(allyID))
                {
                    if (PhoenixProject.ServerBase.Kernel.Guilds.ContainsKey(guildID))
                        if (PhoenixProject.ServerBase.Kernel.Guilds.ContainsKey(allyID))
                            ServerBase.Kernel.Guilds[guildID].Ally.Add(allyID, ServerBase.Kernel.Guilds[allyID]);
                }
            }
            reader.Close();
            reader.Dispose();
            command = new MySqlCommand(MySqlCommandType.SELECT);
            command.Select("guildenemy");
            reader = new MySqlReader(command);
            while (reader.Read())
            {
                ushort guildID = reader.ReadUInt16("GuildID");
                ushort enemyID = reader.ReadUInt16("EnemyID");
                if (ServerBase.Kernel.Guilds.ContainsKey(guildID))
                    if (ServerBase.Kernel.Guilds.ContainsKey(enemyID))
                    {
                        if (PhoenixProject.ServerBase.Kernel.Guilds.ContainsKey(guildID))
                            if (PhoenixProject.ServerBase.Kernel.Guilds.ContainsKey(enemyID))
                                ServerBase.Kernel.Guilds[guildID].Enemy.Add(enemyID, ServerBase.Kernel.Guilds[enemyID]);
                    }
            }
            reader.Close();
            reader.Dispose();

            Console.WriteLine("Guild information loaded.");
        }
 public static void GetAddingsForItem(Interfaces.IConquerItem item)
 {
     if (item != null)
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
         cmd.Select("itemadding").Where("UID", item.UID);
         MySqlReader r = new MySqlReader(cmd);
         while (r.Read())
         {
             uint type = r.ReadUInt32("addingtype");
             if (type == 0)
             {
                 ItemAdding.Purification_ purification = new ItemAdding.Purification_();
                 purification.ItemUID = item.UID;
                 purification.Available = true;
                 purification.PurificationItemID = r.ReadUInt32("addingid");
                 purification.PurificationDuration = r.ReadUInt32("duration");
                 purification.PurificationLevel = r.ReadUInt32("addinglevel");
                 purification.AddedOn = DateTime.FromBinary(r.ReadInt64("addedon"));
                 if (purification.PurificationDuration != 0)
                 {
                     TimeSpan span1 = new TimeSpan(purification.AddedOn.AddSeconds(purification.PurificationDuration).Ticks);
                     TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks);
                     int secondsleft = (int)(span1.TotalSeconds - span2.TotalSeconds);
                     if (secondsleft <= 0)
                     {
                         purification.Available = false;
                         RemoveAdding(item.UID, purification.PurificationItemID);
                         continue;
                     }
                 }
                 item.Purification = purification;
             }
             else
             {
                 ItemAdding.Refinery_ extraeffect = new ItemAdding.Refinery_();
                 extraeffect.ItemUID = item.UID;
                 extraeffect.Available = true;
                 extraeffect.EffectID = item.RefineItem;
                 extraeffect.EffectLevel = r.ReadUInt32("addinglevel");
                 extraeffect.EffectPercent = r.ReadUInt32("addingpercent");
                 extraeffect.EffectDuration = r.ReadUInt32("duration");
                 extraeffect.AddedOn = DateTime.FromBinary(r.ReadInt64("addedon"));
                 item.ExtraEffect = extraeffect;
                 if (extraeffect.EffectDuration != 0)
                 {
                     TimeSpan span1 = new TimeSpan(extraeffect.AddedOn.AddSeconds(extraeffect.EffectDuration).Ticks);
                     TimeSpan span2 = new TimeSpan(DateTime.Now.Ticks);
                     int secondsleft = (int)(span1.TotalSeconds - span2.TotalSeconds);
                     if (secondsleft <= 0)
                     {
                         extraeffect.Available = false;
                         RemoveAdding(item.UID, extraeffect.EffectID);
                         continue;
                     }
                 }
                 item.ExtraEffect = extraeffect;
             }
         }
         r.Close();
         r.Dispose();
     }
 }