Exemplo n.º 1
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.º 2
0
 public static void SaveLogMoney(ItemRecordBussiness db)
 {
     lock (m_LogMoney)
     {
         db.LogMoneyDb(m_LogMoney);
     }
 }
Exemplo n.º 3
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (countConnect >= 3000){client.Disconnect();return 0;}

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

            int ItemBagType = packet.ReadInt();
            int ItemPlace = packet.ReadInt();

            int HoleNum = packet.ReadInt();

            int GemBagType = packet.ReadInt();
            int GemPlace = packet.ReadInt();

            ItemInfo Item = client.Player.GetItemAt((eBageType)ItemBagType, ItemPlace);

            ItemInfo Gem = client.Player.GetItemAt((eBageType)GemBagType, GemPlace);

            string BeginProperty = null;
            string AddItem = "";
             using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.PropertyString(Item, ref BeginProperty);
            }

            int Glod = 2000;
            if (Item == null || Gem == null || Gem.Template.Property1 != 31)
                return 0;
            if (client.Player.PlayerCharacter.Gold > Glod)
            {
                string[] Hole = Item.Template.Hole.Split('|');
                if (HoleNum > 0 && HoleNum < 7)
                {
                    client.Player.RemoveGold(Glod);
                    bool result = false;
                    switch (HoleNum)
                    {
                        case 1:
                            if (Item.Hole1 >= 0)
                            {
                                string[] str = Hole[0].Split(',');

                                if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
                                {
                                    Item.Hole1 = Gem.TemplateID;
                                    AddItem += "," + Gem.ItemID + ","+ Gem.Template.Name ;
                                    result = true;
                                }
                            }
                            break;
                        case 2:
                            if (Item.Hole2 >= 0)
                            {
                                string[] str = Hole[1].Split(',');

                                if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
                                {
                                    Item.Hole2 = Gem.TemplateID;
                                    AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
                                    result = true;
                                }
                            }
                            break;
                        case 3:
                            if (Item.Hole3 >= 0)
                            {
                                string[] str = Hole[2].Split(',');

                                if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
                                {
                                    Item.Hole3 = Gem.TemplateID;
                                    AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
                                    result = true;
                                }
                            }
                            break;
                        case 4:
                            if (Item.Hole4 >= 0)
                            {
                                string[] str = Hole[3].Split(',');

                                if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
                                {
                                    Item.Hole4 = Gem.TemplateID;
                                    AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
                                    result = true;
                                }
                            }
                            break;
                        case 5:
                            if (Item.Hole5 >= 0)
                            {
                                string[] str = Hole[4].Split(',');

                                if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
                                {
                                    Item.Hole5 = Gem.TemplateID;
                                    AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
                                    result = true;
                                }
                            }
                            break;
                        case 6:
                            if (Item.Hole6 >= 0)
                            {
                                string[] str = Hole[5].Split(',');

                                if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
                                {
                                    Item.Hole6 = Gem.TemplateID;
                                    AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
                                    result = true;
                                }
                            }
                            break;
                    }

                    if (result)
                    {
                        //client.Player.StoreBag2.MoveToStore(client.Player.StoreBag2, 0, client.Player.MainBag.FindFirstEmptySlot(31), client.Player.MainBag, 9);
                        pkg.WriteInt(0);
                        Gem.Count--;
                        client.Player.StoreBag2.UpdateItem(Item);
                        client.Player.UpdateItem(Gem);
                        //client.Player.UpdateItem(Item);
                        //client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemInlayHandle.Success", Gem.Template.Name));
                    }
                    LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Insert, BeginProperty, Item, AddItem, Convert.ToInt32(result));
                }
                else
                {
                    pkg.WriteByte(1);
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemInlayHandle.NoPlace"));
                }
                client.Player.SendTCP(pkg);
                client.Player.SaveIntoDatabase();//保存到数据库
            }

            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.NoMoney"));
            }
            return 0;
        }
Exemplo n.º 4
0
 public static void SaveLogFight(ItemRecordBussiness db)
 {
     lock (m_LogFight)
     {
         db.LogFightDb(m_LogFight);
     }
 }
Exemplo n.º 5
0
 public static void SaveLogItem(ItemRecordBussiness db)
 {
     lock (m_LogItem)
     {
         db.LogItemDb(m_LogItem);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 定时保存
 /// </summary>
 public static void Save()
 {
     if (_syncStop != null) //是否已经初始化
     {
         lock (_syncStop)
         {
             using (ItemRecordBussiness db = new ItemRecordBussiness())
             {
                 SaveLogItem(db);
                 SaveLogMoney(db);
                 SaveLogFight(db);
             }
         }
     }
 }
Exemplo n.º 7
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;
        }
Exemplo n.º 9
0
        /// <summary>
        /// 定时保存
        /// </summary>
        public static void Save()
        {
            int online = LoginMgr.GetOnlineCount();//在线人数
            object[] info = { _gameType, _serverId, DateTime.Now, online, RegCount };
            //lock (m_LogServer)
            //{
               // m_LogServer.Rows.Add(info);
            //}
            RegCount = 0;

            int interval = SaveRecordSecond;
            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                db.LogServerDb(m_LogServer);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 熔炼步骤
        /// 第一步:检查四个熔炼类型与熔炼物品&是否有二级密码
        /// 第二步:检验数据是否合乎熔炼规则
        /// 第三步:生成预览或生成物品
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <returns></returns>
        /// 
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
           


            StringBuilder str = new StringBuilder();
            //第一步:传入操作类型、与四个石头
            int opertionType = packet.ReadByte();
            int count = packet.ReadInt();
            int MinValid = int.MaxValue; //默认最短有效时间
            List<ItemInfo> items = new List<ItemInfo>();
            List<ItemInfo> appendItems = new List<ItemInfo>();
            List<eBageType> bagTypes = new List<eBageType>();
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return 1;
            }
            for (int i = 0; i < count; i++)
            {
                eBageType bagType = (eBageType)packet.ReadByte();
                int place = packet.ReadInt();
                ItemInfo info = client.Player.GetItemAt(bagType, place);
                if (info != null)
                {
                    //str.Append(info.ItemID + ":" + info.TemplateID + ",");
                    //items.Add(info);
                    //bagTypes.Add(bagType);
                    if (!items.Contains(info))
                    {
                        str.Append(info.ItemID + ":" + info.TemplateID + ",");
                        items.Add(info);
                        bagTypes.Add(bagType);
                        if (info.ValidDate < MinValid && info.ValidDate != 0)
                        {
                            MinValid = info.ValidDate;
                        }
                    }
                    else
                    {
                        client.Out.SendMessage(eMessageType.Normal, "Bad Input");
                        return 1;
                    }
                }
            }

            if (MinValid == int.MaxValue)
            {
                MinValid = 0;
                items.Clear();
            }
            //第二步:传入熔炼公式与背包类型
            eBageType bagformul = (eBageType)packet.ReadByte();
            int placeformul = packet.ReadInt();
            var storeBag2 = client.Player.StoreBag2;
            ItemInfo formul = storeBag2.GetItemAt(0); ;
            ItemInfo tempitem = null;
            string beginProperty = null;
            string AddItem = "";

            for (int i = 1; i <= 4; i++)
            {
                items.Add(storeBag2.GetItemAt(i));
            }
            using (ItemRecordBussiness db = new ItemRecordBussiness())
            {
                foreach (ItemInfo item in items)
                {
                    db.FusionItem(item, ref beginProperty);
                }
            }

            if (items.Count != 4 || formul == null)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.ItemNotEnough"));
                return 0;
            }

            //第三步:附加物品个数+(背包类型与附加物品位置)
            int appendCount = packet.ReadInt();
            List<eBageType> bagTypesAppend = new List<eBageType>();
            for (int i = 0; i < appendCount; i++)
            {
                eBageType bagType = (eBageType)packet.ReadByte();
                int place = packet.ReadInt();
                ItemInfo info = client.Player.GetItemAt(bagType, place);
                if (info != null)
                {
                    if (!items.Contains(info) && !appendItems.Contains(info))
                    {
                        str.Append(info.ItemID + ":" + info.TemplateID + ",");
                        appendItems.Add(info);
                        bagTypesAppend.Add(bagType);
                        AddItem += info.ItemID + ":" + info.Template.Name + "," + info.IsBinds + "|";
                    }
                    else
                    {
                        client.Out.SendMessage(eMessageType.Normal, "Bad Input");
                        return 1;
                    }
                }

            }
            //结束:预览或熔炼
            if (0 == opertionType) //预览模式
            {
                bool isBind = false;
                Dictionary<int, double> previewItemList = FusionMgr.FusionPreview(items, appendItems, formul, ref isBind);

                if (previewItemList != null)
                {
                    if (previewItemList.Count != 0)
                    {
                        client.Out.SendFusionPreview(client.Player, previewItemList, isBind, MinValid);
                    }
                }
            }
            else //生成熔炼物品
            {
                storeBag2.ClearBag();
                int mustGold = (count + appendCount) * 400;
                if (client.Player.PlayerCharacter.Gold < mustGold)
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemFusionHandler.NoMoney"));
                    return 0;
                }

                bool isBind = false;
                bool result = false;
                ItemTemplateInfo rewardItem = FusionMgr.Fusion(items, appendItems, formul, ref isBind, ref result);
                if (rewardItem != null)
                {
                    client.Player.RemoveGold(mustGold);
                    for (int i = 0; i < items.Count; i++)
                    {
                        items[i].Count--;
                        client.Player.UpdateItem(items[i]);

                    }
                    formul.Count--;
                    client.Player.UpdateItem(formul);
                    for (int i = 0; i < appendItems.Count; i++)
                    {
                        appendItems[i].Count--;
                        client.Player.UpdateItem(appendItems[i]);

                    }

                    if (result)
                    {

                        str.Append(rewardItem.TemplateID + ",");
                        ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, (int)ItemAddType.Fusion);
                        if (item == null)
                            return 0;
                        tempitem = item;
                        item.IsBinds = isBind;
                        item.ValidDate = MinValid;
                        client.Player.OnItemFusion(item.Template.FusionType);  //熔炼成功
                        client.Out.SendFusionResult(client.Player, result);
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Succeed1") + item.Template.Name);

                        //系统广播
                        if (((item.TemplateID >= 8300) && (item.TemplateID <= 8999)) || ((item.TemplateID >= 9300) && (item.TemplateID <= 9999)) || ((item.TemplateID >= 14300) && (item.TemplateID <= 14999)))
                        {
                            string msg = LanguageMgr.GetTranslation("ItemFusionHandler.Notice", client.Player.PlayerCharacter.NickName, item.Template.Name);

                            //client.Out.SendSystemNotice(msg);

                            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);
                            }

                        }

                        if (!client.Player.AddTemplate(item, item.Template.BagType, item.Count))
                        {
                            str.Append("NoPlace");
                            client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(item.GetBagName()) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace"));
                        }
                    }
                    else
                    {
                        str.Append("false");

                        client.Out.SendFusionResult(client.Player, result);
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.Failed"));
                    }
                    LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Fusion, beginProperty, tempitem, AddItem, Convert.ToInt32(result));
                    client.Player.SaveIntoDatabase();//保存到数据库
                }
                else
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemFusionHandler.NoCondition"));
                }
            }

            return 0;
        }