public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
           

            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");
            int total = 0;

            try
            {
                int consortiaID = int.Parse(context.Request["consortiaID"]);

               
                using (ConsortiaBussiness db = new ConsortiaBussiness())
                {
                    for (int i = 1; i < 3;i++ )
                    {
                        for (int j = 1; j < 11; j++) 
                        {
                            ConsortiaEquipControlInfo cecInfo = db.GetConsortiaEuqipRiches(consortiaID, j,i);
                            if (cecInfo != null)
                            {
                                result.Add(new XElement("Item", new XAttribute("type", cecInfo.Type), new XAttribute("level", cecInfo.Level), new XAttribute("riches", cecInfo.Riches)));
                                total++;
                            }
                            
                        }
                    }
             
                    value = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("ConsortiaEventList", ex);
            }

            result.Add(new XAttribute("total", total));
            result.Add(new XAttribute("vaule", value));
            result.Add(new XAttribute("message", message));

            context.Response.ContentType = "text/plain";
            context.Response.Write(result.ToString(false));



           
        }
Exemplo n.º 2
0
        //private static readonly double[] rateItems = new double[] { 0.75, 3, 12, 48, 240, 768 };
        //public static int countConnect = 0;
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //if (countConnect >= 3000)
            //{
            //    client.Disconnect();
            //    return 0;
            //}
            StringBuilder str = new StringBuilder();
            bool isBinds = false;
            bool consortia = packet.ReadBoolean();
            bool MultiSelected = packet.ReadBoolean();

            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            List<ItemInfo> stones = new List<ItemInfo>();
            ItemInfo stone = client.Player.StoreBag2.GetItemAt(0);
            ItemInfo item = client.Player.StoreBag2.GetItemAt(1);

            //ItemInfo luck = null;
            //ItemInfo god = null;
            string BeginProperty = null;
            string AddItem = "";
            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(item, ref BeginProperty);
            }

            if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1)
            {
                isBinds = isBinds ? true : item.IsBinds;
                str.Append(item.ItemID + ":" + item.TemplateID + ",");
                double exp1 = 0;
                double exp2 = 0;
                double exp3 = 0;
                double totalExp = 0;

                if (stone != null && stone.Template.CategoryID == 11 && (stone.Template.Property1 == 2 || stone.Template.Property1 == 35))
                {
                    isBinds = isBinds ? true : stone.IsBinds;
                    AddItem += "," + stone.ItemID.ToString() + ":" + stone.Template.Name;
                    stones.Add(stone);
                    exp1 += stone.Template.Property2;
                }

                bool ConsortiaRate = false;
                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                //判断是公会铁匠铺还是铁匠铺??
                if (consortia)
                {
                    ConsortiaBussiness csbs = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);

                    if (info == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail"));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < cecInfo.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission"));
                            return 1;
                        }
                        ConsortiaRate = true;
                    }
                }
                if (ConsortiaRate)
                {
                    //ConsortiaRateManager.instance.getConsortiaStrengthenEx(PlayerManager.Instance.Self.consortiaInfo.SmithLevel)
                    //"ConsortiaStrengthenEx" Value="10|20|30|40|50|60|70|80|90|100"
                    List<double> ConsortiaStrengthenEx = new List<double> { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
                    exp2 = ConsortiaStrengthenEx[info.SmithLevel - 1] / 100 * exp1;
                }
                if (client.Player.PlayerCharacter.VIPExpireDay >= DateTime.Now)
                {
                    //_loc_4 = VipController.instance.getVIPStrengthenEx(PlayerManager.Instance.Self.VIPLevel)
                    //"VIPStrengthenEx" Value="25|25|25|35|35|50|50|50|50|50|50|50"
                    List<double> VIPStrengthenEx = new List<double> { 25, 25, 25, 35, 35, 50, 50, 50, 50, 50, 50, 50 };
                    exp3 = VIPStrengthenEx[client.Player.PlayerCharacter.VIPLevel - 1] / 100 * exp1;
                }
                totalExp += Math.Floor(exp1 + exp2 + exp3);
                str.Append("true");
                List<int> StrengThenExp = new List<int> { 0, 10, 50, 150, 350, 700, 1500, 2300, 3300, 4500, 6000, 7500, 9000 };

                //Console.WriteLine("-------Total: " + stone.Count.ToString() + "| Inject: " + MultiSelected);
                if (MultiSelected)// && stone.Count > 1)
                {
                    //for (int i = 0; i < stone.Count; i++)
                    //{
                    item.StrengthenExp += (int)totalExp * stone.Count;
                    client.Player.StoreBag2.RemoveTemplate(stone.TemplateID, stone.Count);
                    //}
                }
                else
                {
                    item.StrengthenExp += (int)totalExp;
                    client.Player.StoreBag2.RemoveTemplate(stone.TemplateID, 1);

                }

                if (item.StrengthenExp >= StrengThenExp[item.StrengthenLevel + 1])
                {
                    //for (int a = StrengThenExp[item.StrengthenLevel]; a < item.StrengthenExp; a++)
                    int a = StrengThenExp[item.StrengthenLevel];
                    do
                    {
                        if (item.StrengthenLevel < 13)
                        {
                            if (item.StrengthenExp >= StrengThenExp[item.StrengthenLevel + 1])
                            {
                                item.StrengthenLevel++;
                                item.StrengthenExp -= StrengThenExp[item.StrengthenLevel];
                                a = StrengThenExp[item.StrengthenLevel];

                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    while (item.StrengthenExp > a);
                    if (item.StrengthenLevel == 12 && (item.StrengthenExp / totalExp) > 0)
                    {
                        stone.Count = (int)Math.Floor(item.StrengthenExp / totalExp);
                        client.Player.StoreBag2.AddItemTo(stone, 0);
                        client.Player.StoreBag2.UpdateItem(stone);
                        //if (item.StrengthenLevel == 12)
                        item.StrengthenExp = 0;
                    }
                    pkg.WriteByte(1);

                    StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID);
                    if (strengthenGoodsInfo != null && item.Template.CategoryID == 7)
                    {
                        ItemTemplateInfo Temp = Bussiness.Managers.ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip);
                        if (Temp != null)
                        {
                            ItemInfo newItem = ItemInfo.CreateFromTemplate(Temp, 1, (int)ItemAddType.Strengthen);
                            newItem.StrengthenLevel = item.StrengthenLevel;
                            newItem.StrengthenExp = item.StrengthenExp;
                            ItemInfo.OpenHole(ref newItem);
                            StrengthenMgr.InheritProperty(item, ref newItem);
                            client.Player.StoreBag2.RemoveItemAt(1);
                            client.Player.StoreBag2.AddItemTo(newItem, 1);
                            //client.Player.StoreBag2.UpdateItem(newItem);
                            item = newItem;
                            if ((item.StrengthenLevel == 3 || item.StrengthenLevel == 6 || item.StrengthenLevel == 9 || item.StrengthenLevel == 12) && item.Template.CategoryID != 17)
                            {
                                pkg.WriteBoolean(true);
                            }
                            else
                            {
                                pkg.WriteBoolean(false);
                            }
                        }
                    }
                    else
                    {

                        ItemInfo.OpenHole(ref item);
                        //client.Player.StoreBag2.AddItemTo(item, 1);
                        if ((item.StrengthenLevel == 3 || item.StrengthenLevel == 6 || item.StrengthenLevel == 9 || item.StrengthenLevel == 12) && item.Template.CategoryID != 17)
                        {
                            pkg.WriteBoolean(true);
                        }
                        else
                        {
                            pkg.WriteBoolean(false);
                        }
                    }

                    //系统广播
                    if (item.StrengthenLevel >= 7)
                    {
                        string msg = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", client.Player.PlayerCharacter.NickName, item.Template.Name, item.StrengthenLevel);
                        GSPacketIn sys_notice = WorldMgr.SendSysNotice(msg);
                        GameServer.Instance.LoginServer.SendPacket(sys_notice);

                    }
                }
                else
                {
                    pkg.WriteByte(1);
                    pkg.WriteBoolean(false);
                }

                client.Player.StoreBag2.UpdateItem(item);
                client.Player.OnItemStrengthen(item.Template.CategoryID, item.StrengthenLevel);//任务<强化>
                LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 1);//强化日志

                //client.Player.SaveIntoDatabase();//保存到数据库
                client.Out.SendTCP(pkg);
                str.Append(item.StrengthenLevel);
                //client.Player.BeginChanges();
                //client.Player.CommitChanges();
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1") + stone.Template.Name + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2"));
            }
            if (item.Place < 31)
            {
                client.Player.MainBag.UpdatePlayerProperties();
            }

            return 0;
        }
Exemplo n.º 3
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (countConnect >= 3000){client.Disconnect();return 0;}
            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            StringBuilder str = new StringBuilder();
            int mustGold = GameProperties.PRICE_COMPOSE_GOLD;
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {

                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return 0;
            }
            if (client.Player.PlayerCharacter.Gold < mustGold)
            {
                client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemComposeHandler.NoMoney"));
                return 0;
            }

            int itemPlace = - 1;
            int godPlace = -1;
            bool isBinds = false;
            bool consortia = packet.ReadBoolean();

            ItemInfo item = client.Player.StoreBag2.GetItemAt(1);
            ItemInfo stone = client.Player.StoreBag2.GetItemAt(2);
            ItemInfo luck = null;
            ItemInfo god = null;

            string BeginProperty = null;
            string AddItem = null;
            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(item, ref BeginProperty);
            }
            if (item != null && stone != null && item.Template.CanCompose && (item.Template.CategoryID < 10 || stone.Template.CategoryID == 11 && stone.Template.Property1 == 1))
            {

                isBinds = isBinds ? true : item.IsBinds;
                isBinds = isBinds ? true : stone.IsBinds;
                str.Append(item.ItemID + ":" + item.TemplateID + "," + stone.ItemID + ":" + stone.TemplateID + ",");
                ThreadSafeRandom random = new ThreadSafeRandom();
                bool result = false;
                byte isSuccess = 1;
                //bool isGod = false;
                double probability = composeRate[(stone.Template.Quality - 1)] * 100;//stone.Template.Property2;
                if (client.Player.StoreBag2.GetItemAt(0)!=null)
                {
                    luck = client.Player.StoreBag2.GetItemAt(0);
                    if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3)
                    {
                        isBinds = isBinds ? true : luck.IsBinds;
                        AddItem += "|" + luck.ItemID + ":" + luck.Template.Name + "|" + stone.ItemID + ":" + stone.Template.Name;
                        str.Append(luck.ItemID + ":" + luck.TemplateID + ",");
                        probability += probability * luck.Template.Property2 / 100;
                    }

                }
                else
                {
                    probability += probability * 1 / 100;
                }
                if (godPlace != -1)
                {
                    god = client.Player.PropBag.GetItemAt(godPlace);
                    if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7)
                    {
                        isBinds = isBinds ? true : god.IsBinds;
                        //isGod = true;
                        str.Append(god.ItemID + ":" + god.TemplateID + ",");
                        AddItem += "," + god.ItemID + ":" + god.Template.Name;
                    }
                    else
                    {
                        god = null;
                    }
                }
                //判断是公会铁匠铺还是铁匠铺
                if (consortia)
                {

                    ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    //这里添加公会权限限制的判断
                    ConsortiaBussiness csbs = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);

                    if (info == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail"));
                    }
                    else
                    {

                        if (client.Player.PlayerCharacter.Riches < cecInfo.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission"));
                            return 1;
                        }
                        else
                        {
                            probability *= (1 + 0.1 * info.SmithLevel);

                        }
                    }

                }
                probability = Math.Floor(probability * 10) / 10;
                //client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Probability: " + probability.ToString()));
                int rand = random.Next(100);
                switch (stone.Template.Property3)
                {
                    case 1:
                        if (stone.Template.Property4 > item.AttackCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.AttackCompose = stone.Template.Property4;
                            }

                        }
                        break;
                    case 2:
                        if (stone.Template.Property4 > item.DefendCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.DefendCompose = stone.Template.Property4;
                            }

                        }
                        break;
                    case 3:
                        if (stone.Template.Property4 > item.AgilityCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.AgilityCompose = stone.Template.Property4;
                            }

                        }
                        break;
                    case 4:
                        if (stone.Template.Property4 > item.LuckCompose)
                        {
                            result = true;
                            if (probability > rand)
                            {
                                isSuccess = 0;
                                item.LuckCompose = stone.Template.Property4;
                            }

                        }
                        break;
                }

                if (result)
                {
                    item.IsBinds = isBinds;
                    if (isSuccess != 0)
                    {
                        str.Append("false!");
                        result = false;

                    }
                    else
                    {
                        str.Append("true!");
                        result = true;
                        client.Player.OnItemCompose(stone.TemplateID);
                    }
                    LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Compose, BeginProperty, item, AddItem, Convert.ToInt32(result));
                    client.Player.RemoveItem(stone);
                    client.Player.SaveIntoDatabase();//保存到数据库
                    if (luck != null)
                    {
                        client.Player.RemoveItem(luck);
                    }
                    if (god != null)
                    {
                        client.Player.RemoveItem(god);
                    }
                    client.Player.RemoveGold(mustGold);
                    client.Player.StoreBag2.ClearBag();
                    client.Player.StoreBag2.AddItemTo(item, 1);
                    //client.Player.StoreBag2.UpdateItem(item);
                    pkg.WriteByte(isSuccess);
                    client.Out.SendTCP(pkg);
                    if (itemPlace < 31)
                    {
                        client.Player.MainBag.UpdatePlayerProperties();
                    }
                }
                else
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.NoLevel"));
                }
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.Fail"));
            }

            return 0;
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {

            if (countConnect >= 3000)
            {
                client.Disconnect();
                return 0;
            }

            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            StringBuilder str = new StringBuilder();
            bool isBinds = false;
            int mustGold = GameProperties.PRICE_STRENGHTN_GOLD;
            if (client.Player.PlayerCharacter.Gold < mustGold)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney"));
                return 0;
            }

            int luckPlace = 0;
            int godPlace = 0;

            //int itemPlace = client.Player.TempBag.GetItemAt(0).ItemID ;
            //int luckPlace = packet.ReadInt();
            //int godPlace = packet.ReadInt();
            //int stone1Place = packet.ReadInt();
            //int stone2Place = packet.ReadInt();
            //int stone3Place = packet.ReadInt();
            bool consortia = packet.ReadBoolean();

            List<ItemInfo> stones = new List<ItemInfo>();
            ItemInfo item = client.Player.StoreBag2.GetItemAt(5);
            ItemInfo luck = null;
            ItemInfo god = null;
            string BeginProperty = null;
            string AddItem = "";
            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(item, ref BeginProperty);
            }

            if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1)
            {
                isBinds = isBinds ? true : item.IsBinds;
                str.Append(item.ItemID + ":" + item.TemplateID + ",");
                ThreadSafeRandom random = new ThreadSafeRandom();
                int result = 1;
                double probability = 0;
                bool isGod = false;

                StrengthenInfo strengthenInfo;
                StrengthenGoodsInfo strengthenGoodsInfo = null;
                if (item.Template.RefineryLevel > 0)
                {
                    strengthenInfo = StrengthenMgr.FindRefineryStrengthenInfo(item.StrengthenLevel + 1);
                }
                else
                {
                    strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID);
                    strengthenInfo = StrengthenMgr.FindStrengthenInfo(item.StrengthenLevel + 1);
                }
                if (strengthenInfo == null)
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength"));
                    return 0;
                }

                if (client.Player.StoreBag2.GetItemAt(3) != null)
                {
                    god = client.Player.StoreBag2.GetItemAt(3);
                    AddItem += "," + god.ItemID.ToString() + ":" + god.Template.Name;
                    if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7)
                    {
                        isBinds = isBinds ? true : god.IsBinds;
                        str.Append(god.ItemID + ":" + god.TemplateID + ",");
                        isGod = true;
                    }
                    else
                    {
                        god = null;
                    }
                }

                ItemInfo stone1 = client.Player.StoreBag2.GetItemAt(0);
                if (stone1 != null && stone1.Template.CategoryID == 11 && (stone1.Template.Property1 == 2 || stone1.Template.Property1 == 35) && !stones.Contains(stone1))
                {
                    isBinds = isBinds ? true : stone1.IsBinds;
                    AddItem += "," + stone1.ItemID.ToString() + ":" + stone1.Template.Name;
                    stones.Add(stone1);
                    probability += stone1.Template.Property2;
                }

                ItemInfo stone2 = client.Player.StoreBag2.GetItemAt(1);
                if (stone2 != null && stone2.Template.CategoryID == 11 && (stone2.Template.Property1 == 2 || stone2.Template.Property1 == 35) && !stones.Contains(stone2))
                {
                    isBinds = isBinds ? true : stone2.IsBinds;
                    AddItem += "," + stone2.ItemID.ToString() + ":" + stone2.Template.Name;
                    stones.Add(stone2);
                    probability += stone2.Template.Property2;
                }

                ItemInfo stone3 = client.Player.StoreBag2.GetItemAt(2);
                if (stone3 != null && stone3.Template.CategoryID == 11 && (stone3.Template.Property1 == 2 || stone3.Template.Property1 == 35) && !stones.Contains(stone3))
                {
                    isBinds = isBinds ? true : stone3.IsBinds;
                    AddItem += "," + stone3.ItemID + ":" + stone3.Template.Name;
                    stones.Add(stone3);
                    probability += stone3.Template.Property2;
                }
                bool RefineryStrengthen = false;

                foreach (ItemInfo stoneinfo in stones)
                {
                    if (stoneinfo.Template.Property1 == 35 && stoneinfo.Template.CategoryID == 11)
                    {
                        RefineryStrengthen = true;

                    }
                    else
                    {
                        RefineryStrengthen = false;
                    }
                }

                //if (!RefineryStrengthen && item.Template.RefineryLevel > 0)
                //{
                //    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.StoneMatch"));
                //    return 1;
                //}
                if (client.Player.StoreBag2.GetItemAt(4) != null)
                {
                    luck = client.Player.StoreBag2.GetItemAt(4);
                    AddItem += "," + luck.ItemID.ToString() + ":" + luck.Template.Name;
                    if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3)
                    {
                        isBinds = isBinds ? true : luck.IsBinds;
                        str.Append(luck.ItemID + ":" + luck.TemplateID + ",");
                        probability = probability * (luck.Template.Property2 + 100);
                    }
                    else
                    {
                        probability *= 100;
                        luck = null;
                    }
                }
                else
                {
                    probability *= 100;
                }
                bool CanUpdate = false;
                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                //判断是公会铁匠铺还是铁匠铺??
                if (consortia)
                {
                    ConsortiaBussiness csbs = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);

                    if (info == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail"));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < cecInfo.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission"));
                            return 1;
                        }
                        CanUpdate = true;
                    }
                }

                if (stones.Count >= 1)
                {
                    probability = probability / strengthenInfo.Rock;
                    for (int i = 0; i < stones.Count; i++)
                    {
                        str.Append(stones[i].ItemID + ":" + stones[i].TemplateID + ",");

                        AbstractInventory bg = client.Player.GetItemInventory(stones[i].Template);
                        stones[i].Count--;
                        bg.UpdateItem(stones[i]);
                    }

                    if (luck != null)
                    {
                        AbstractInventory bg = client.Player.GetItemInventory(luck.Template);
                        bg.RemoveItem(luck);
                    }

                    if (god != null)
                    {
                        AbstractInventory bg = client.Player.GetItemInventory(god.Template);
                        bg.RemoveItem(god);
                    }
                    if (CanUpdate)
                    {
                        probability *= (1 + 0.1 * info.SmithLevel);
                    }
                    item.IsBinds = isBinds;

                    client.Player.StoreBag2.ClearBag();
                    if (probability > random.Next(10000))
                    {
                        str.Append("true");
                        pkg.WriteByte(0);
                        if (strengthenGoodsInfo != null)
                        {
                            ItemTemplateInfo Temp = Bussiness.Managers.ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip);
                            if (Temp != null)
                            {
                                ItemInfo Item = ItemInfo.CreateFromTemplate(Temp, 1, (int)ItemAddType.Strengthen);
                                Item.StrengthenLevel = item.StrengthenLevel + 1;


                                ItemInfo.OpenHole(ref Item);
                                StrengthenMgr.InheritProperty(item, ref Item);

                                client.Player.RemoveItem(item);
                                client.Player.AddTemplate(Item, Item.Template.BagType, Item.Count);
                                item = Item;
                                pkg.WriteBoolean(false);
                            }
                        }
                        else
                        {
                            pkg.WriteBoolean(true);
                            item.StrengthenLevel++;
                            ItemInfo.OpenHole(ref item);
                            //client.Player.MainBag.AddItem(item);
                            client.Player.StoreBag2.AddItemTo(item, 5);
                        }



                        client.Player.OnItemStrengthen(item.Template.CategoryID, item.StrengthenLevel);//任务<强化>                                               
                        LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 1);//强化日志
                        client.Player.SaveIntoDatabase();//保存到数据库
                        //系统广播
                        if (item.StrengthenLevel >= 7)
                        {
                            string msg = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", client.Player.PlayerCharacter.NickName, item.Template.Name, item.StrengthenLevel);

                            GSPacketIn pkg1 = new GSPacketIn((byte)ePackageType.SYS_NOTICE);
                            pkg1.WriteInt(1);
                            pkg1.WriteString(msg);

                            GameServer.Instance.LoginServer.SendPacket(pkg1);

                            GamePlayer[] players = Game.Server.Managers.WorldMgr.GetAllPlayers();

                            foreach (GamePlayer p in players)
                            {
                                p.Out.SendTCP(pkg1);
                            }
                        }

                    }
                    else
                    {
                        str.Append("false");
                        pkg.WriteByte(1);
                        pkg.WriteBoolean(false);
                        if (isGod == false)
                        {
                            if (item.Template.Level == 3)
                            {
                                item.StrengthenLevel = item.StrengthenLevel == 0 ? 0 : item.StrengthenLevel - 1;
                                // client.Player.MainBag.AddItem(item);
                                client.Player.StoreBag2.AddItemTo(item, 5);
                            }
                            else
                            {
                                item.Count--;
                                // client.Player.MainBag.AddItem(item);
                                client.Player.StoreBag2.AddItemTo(item, 5);
                            }
                        }
                        else
                        {

                            //client.Player.MainBag.AddItem(item);
                            client.Player.StoreBag2.AddItemTo(item, 5);
                        }
                        LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, BeginProperty, item, AddItem, 0);

                        client.Player.SaveIntoDatabase();//保存到数据库
                    }

                    client.Out.SendTCP(pkg);
                    str.Append(item.StrengthenLevel);
                    client.Player.BeginChanges();
                    client.Player.RemoveGold(mustGold);
                    client.Player.CommitChanges();
                }
                else
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1") + result + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2"));
                }
                if (item.Place < 31)
                    client.Player.MainBag.UpdatePlayerProperties();
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Success"));
            }

            return 0;
        }