public static void NewReincarnated(Game.Entity entity)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
     cmd.Insert("reincarnation")
         .Insert("uid", entity.UID)
         .Insert("level", entity.Level)
         .Insert("experience", 0);
     cmd.Execute();
        // Conquer.Database.Reincarnation.Insert((int)entity.UID, (int)entity.Level, 0);
 }
 public static void Create(Game.ConquerStructures.Society.Guild guild)
 {
     MySqlCommand command = new MySqlCommand(MySqlCommandType.INSERT);
     command.Insert("guilds").
         Insert("ID", guild.ID).
         Insert("Name", guild.Name).
         Insert("SilverFund", 500000).
         Insert("LeaderName", guild.LeaderName);
     command.Execute();
 }
        public static void DetainItem(Interfaces.IConquerItem item, Client.GameState owner, Client.GameState gainer)
        {
            DetainedItem Item = new DetainedItem(true);
            Item.ItemUID = item.UID;
            Item.Item = item;
            Item.UID = Item.ItemUID ;
            Item.ConquerPointsCost = CalculateCost(item);
            Item.OwnerUID = owner.Entity.UID;
            Item.OwnerName = owner.Entity.Name;
            Item.GainerUID = gainer.Entity.UID;
            Item.GainerName = gainer.Entity.Name;
            Item.Date = DateTime.Now;
            Item.DaysLeft = 0;
            owner.DeatinedItem.Add(Item.UID, Item);
            owner.Send(Item);

            DetainedItem Item2 = new DetainedItem(true);
            Item2.ItemUID = item.UID;
            Item2.UID = Item2.ItemUID ;
            Item2.Item = item;
            Item2.Page = (byte)DetainedItem.ClaimPage;
            Item2.ConquerPointsCost = CalculateCost(item);
            Item.OwnerUID = owner.Entity.UID;
            Item.OwnerName = owner.Entity.Name;
            Item.GainerUID = gainer.Entity.UID;
            Item.GainerName = gainer.Entity.Name;
            Item2.Date = Item.Date;
            Item2.DaysLeft = 0;
            gainer.ClaimableItem.Add(Item2.UID, Item2);
            gainer.Send(Item2);
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT)
               .Insert("detaineditems").Insert("ItemUID", item.UID).Insert("ConquerPointsCost", Item.ConquerPointsCost)
               .Insert("Date", Item.Date.Ticks).Insert("OwnerUID", owner.Entity.UID).Insert("OwnerName", owner.Entity.Name)
               .Insert("GainerUID", gainer.Entity.UID).Insert("GainerName", gainer.Entity.Name);
            cmd.Execute();

            MySqlCommand cmd2 = new MySqlCommand(MySqlCommandType.INSERT)
              .Insert("claimitems").Insert("ItemUID", item.UID).Insert("ConquerPointsCost", Item.ConquerPointsCost)
              .Insert("Date", Item.Date.Ticks).Insert("OwnerUID", owner.Entity.UID).Insert("OwnerName", owner.Entity.Name)
              .Insert("GainerUID", gainer.Entity.UID).Insert("GainerName", gainer.Entity.Name);
            cmd2.Execute();

            /*Detaineditem.Insert(item.UID, (ulong)Item.Date.Ticks, Item.ConquerPointsCost,
            owner.Entity.UID, owner.Entity.Name, gainer.Entity.UID, gainer.Entity.Name);

            ClaimItem.Insert(item.UID, (ulong)Item.Date.Ticks, Item.ConquerPointsCost,
            owner.Entity.UID, owner.Entity.Name, gainer.Entity.UID, gainer.Entity.Name);*/
        }
        public static void createhouse(Client.GameState client)
        {
            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
            cmd.Insert("house").Insert("id", client.Entity.UID).Insert("mapdoc", "3024").Insert("type", "7").Insert("weather", "0").Insert("owner", client.Entity.UID).Insert("HouseLevel", "1");

            cmd.Execute();

            //PhoenixProject.Database.MapsTable.MapInformation info = new PhoenixProject.Database.MapsTable.MapInformation();
           // info.ID = (ushort)client.Entity.UID;
           // info.BaseID = 601;
            //info.Status = 7;
           // info.Weather = 0;
            //info.Owner = client.Entity.UID;
            //info.HouseLevel = 1;
            //PhoenixProject.Database.MapsTable.MapInformations.Add(info.ID, info);
            bool Success = DMaps.CreateDynamicMap2(client.Entity.UID, 1765, (uint)client.Entity.UID, 1);
            return;
        }
 public static void AddItem(ref Interfaces.IConquerItem Item, Client.GameState client)
 {
     try
     {
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
         cmd.Insert("items").Insert("EntityID", client.Entity.UID).Insert("UID", Item.UID)
             .Insert("ID", Item.ID).Insert("Plus", Item.Plus).Insert("Bless", Item.Bless)
             .Insert("Enchant", Item.Enchant).Insert("SocketOne", (byte)Item.SocketOne)
             .Insert("SocketTwo", (byte)Item.SocketTwo).Insert("Durability", Item.Durability)
             .Insert("MaximDurability", Item.MaximDurability).Insert("SocketProgress", Item.SocketProgress)
             .Insert("PlusProgress", Item.PlusProgress).Insert("Effect", (ushort)Item.Effect)
             .Insert("Bound", Item.Bound).Insert("Locked", Item.Lock).Insert("Suspicious", Item.Suspicious)
             .Insert("Color", (uint)Item.Color).Insert("Position", Item.Position).Insert("Warehouse", Item.Warehouse)
             .Insert("UnlockEnd", Item.UnlockEnd.ToBinary()).Insert("SuspiciousStart", Item.SuspiciousStart.ToBinary())
             .Insert("StackSize", Item.StackSize);
         cmd.Execute();
         new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastItem", PhoenixProject.Client.AuthState.nextID).Where("Coder", "kimo").Execute();
     }
     catch
     {
     again:
         PhoenixProject.Client.AuthState.nextID++;
         Item.UID = PhoenixProject.Client.AuthState.nextID;
         if (IsThere(Item.UID))
             goto again;
         MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
         cmd.Insert("items").Insert("EntityID", client.Entity.UID).Insert("UID", Item.UID)
             .Insert("ID", Item.ID).Insert("Plus", Item.Plus).Insert("Bless", Item.Bless)
             .Insert("Enchant", Item.Enchant).Insert("SocketOne", (byte)Item.SocketOne)
             .Insert("SocketTwo", (byte)Item.SocketTwo).Insert("Durability", Item.Durability)
             .Insert("MaximDurability", Item.MaximDurability).Insert("SocketProgress", Item.SocketProgress)
             .Insert("PlusProgress", Item.PlusProgress).Insert("Effect", (ushort)Item.Effect)
             .Insert("Bound", Item.Bound).Insert("Locked", Item.Lock).Insert("Suspicious", Item.Suspicious)
             .Insert("Color", (uint)Item.Color).Insert("Position", Item.Position).Insert("Warehouse", Item.Warehouse)
             .Insert("UnlockEnd", Item.UnlockEnd.ToBinary()).Insert("SuspiciousStart", Item.SuspiciousStart.ToBinary())
             .Insert("StackSize", Item.StackSize);
         cmd.Execute();
         new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastItem", PhoenixProject.Client.AuthState.nextID).Where("Coder", "kimo").Execute();
     }
 }
 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();
 }
 public static void Claim(uint kimo, Client.GameState owner)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE).Delete("detaineditems", "ItemUID", kimo);
     cmd.Execute();
 }
 public static void Redeem(DetainedItem item, Client.GameState owner)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE)
         .Update("detaineditems").Set("OwnerUID", 500).Where("ItemUID", item.UID);
     cmd.Execute();
 }
 public static void Redeem(uint kimo, Client.GameState owner)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.UPDATE)
         .Update("claimitems").Set("OwnerUID", 500).Where("ItemUID", kimo);
     cmd.Execute();
 }
 public static void SaveTop8(Client.GameState client)
 {
     //Conquer.Database.Elitepk.Insert((int)client.Entity.UID, (int)client.Entity.Face, (string)client.Entity.Name, (int)client.Entity.Mesh, (int)client.Entity.Points, (int)client.Entity.Postion, (long)client.Entity.MyTitle);
     Elite_client clients = new Elite_client(
         (uint)client.Entity.UID
         , (ushort)client.Entity.Face
         , (ushort)client.Entity.Body
         , (string)client.Entity.Name
         , (uint)client.Entity.Points
         , (ushort)Program.EliteRank
         , (byte)client.Entity.MyTitle
             );
     if (!Top8.ContainsKey(clients.UID))
         Top8.Add(clients.UID, clients);
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
     cmd.Insert("elitepk")
         .Insert("UID", clients.UID).Insert("Avatar", clients.Avatar)
         .Insert("Mesh", clients.Mesh).Insert("Name", clients.Name)
         .Insert("Points", clients.Points).Insert("Postion", Program.EliteRank)
   .Insert("MyTitle", clients.MyTitle);
     cmd.Execute();
    // Conquer.Database.Elitepk.Insert((int)clients.UID, (int)clients.Avatar, (string)clients.Name, (int)clients.Mesh, (int)clients.Points, (int)Program.EliteRank, (long)clients.MyTitle);
 }
 public static void SaveArenaStatistics(Network.GamePackets.ArenaStatistic stats)
 {
     var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("arena")
         .Set("LastSeasonRank", stats.LastSeasonRank)
         .Set("ArenaPoints", stats.ArenaPoints)
         .Set("TodayWin", stats.TodayWin)
         .Set("TodayBattles", stats.TodayBattles)
         .Set("LastSeasonWin", stats.LastSeasonWin)
         .Set("LastSeasonLose", stats.LastSeasonLose)
         .Set("TotalWin", stats.TotalWin)
         .Set("TotalLose", stats.TotalLose)
         .Set("HistoryHonor", stats.HistoryHonor)
         .Set("CurrentHonor", stats.CurrentHonor)
         .Set("Level", stats.Level)
         .Set("Class", stats.Class)
         .Set("ArenaPointFill", stats.LastArenaPointFill.Ticks)
         .Set("Model", stats.Model)
         .Set("LastSeasonArenaPoints", stats.LastSeasonArenaPoints)
         .Where("EntityID", stats.EntityID);
     cmd.Execute();
 }
 public static void DeletVotes()
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE).Delete("VoteIp", "delete", "1");
     cmd.Execute();
 }
 public static void DeletVotes(PhoenixProject.Game.ConquerStructures.PlayersVot PlayerVot)
 {
     MySqlCommand cmd = new MySqlCommand(MySqlCommandType.DELETE).Delete("VoteIp", "ID", PlayerVot.Uid).And("IP", PlayerVot.AdressIp);
     cmd.Execute();
 }
        public static bool CreateEntity(Network.GamePackets.EnitityCreate eC, Client.GameState client, ref string message)
        {
            if (eC.Name.Length > 16)
                eC.Name = eC.Name.Substring(0, 16);
            if (eC.Name == "")
                return false;

            if (InvalidCharacters(eC.Name))
            {
                message = "Invalid characters inside the name.";
                return false;
            }
            var rdr =new PhoenixProject.Database.MySqlReader(new MySqlCommand(MySqlCommandType.SELECT).Select("entities").Where("name", eC.Name));
            if (rdr.Read())
            {
                rdr.Close();
                rdr.Dispose();
                message = "The chosen name is already in use.";
                return false;
            }
            rdr.Close();
            rdr.Dispose();
            client.Entity = new Game.Entity(Game.EntityFlag.Player, false);
            client.Entity.Name = eC.Name;
            if (eC.Class != 0)
            {
                DataHolder.GetStats(eC.Class, 1, client);
            }
            else
            {
                DataHolder.GetStats(70, 1, client);
                eC.Class = 70;
            }
            client.Entity.UID = Program.nextEntityID;
            Program.nextEntityID++;
            new Database.MySqlCommand(Database.MySqlCommandType.UPDATE).Update("rates").Set("LastEntity", Program.nextEntityID).Where("Coder", "kimo").Execute();
            client.CalculateStatBonus();
            client.CalculateHPBonus();
            client.Entity.Hitpoints = client.Entity.MaxHitpoints;
            client.Entity.Mana = (ushort)(client.Entity.Spirit * 5);
            client.Entity.Class = eC.Class;
            client.Entity.Body = eC.Body;
            if (eC.Body == 1003 || eC.Body == 1004)
                client.Entity.Face = (ushort)ServerBase.Kernel.Random.Next(1, 50);
            else
                client.Entity.Face = (ushort)ServerBase.Kernel.Random.Next(201, 250);
            byte Color = (byte)ServerBase.Kernel.Random.Next(4, 8);
            client.Entity.HairStyle = (ushort)(Color * 100 + 10 + (byte)ServerBase.Kernel.Random.Next(4, 9));
            client.Account.EntityID = client.Entity.UID;
            client.Account.Save();

            MySqlCommand cmd = new MySqlCommand(MySqlCommandType.INSERT);
            cmd.Insert("entities").Insert("Name", eC.Name).Insert("Owner", client.Account.Username).Insert("Class", eC.Class).Insert("UID", client.Entity.UID)
                .Insert("Hitpoints", client.Entity.Hitpoints).Insert("Mana", client.Entity.Mana).Insert("Body", client.Entity.Body)
                .Insert("Face", client.Entity.Face).Insert("HairStyle", client.Entity.HairStyle).Insert("Strength", client.Entity.Strength)
                .Insert("WarehousePW","")
                .Insert("Agility", client.Entity.Agility).Insert("Vitality", client.Entity.Vitality).Insert("Spirit", client.Entity.Spirit);

            cmd.Execute();
            message = "ANSWER_OK";
            return true;
        }