Ejemplo n.º 1
0
        /// <summary>
        /// 拆分物品
        /// </summary>
        /// <param name="item"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public bool SplitItem(ItemInfo item, int count, int toSlot)
        {
            if (_bagType == 11)
            {
                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(_player.PlayerCharacter.ConsortiaID);
                if (info != null || toSlot >= info.StoreLevel * 10)
                {
                    _player.Out.SendUpdateInventorySlot(item.Place, true, item, _bagType);
                    return(false);
                }
            }

            if (item.Count > count && m_items[toSlot] == null)
            {
                ItemInfo clone = item.Clone();
                clone.ItemID = -1;
                clone.Count  = count;
                if (AddItemTo(clone, toSlot) != -1)
                {
                    item.Count -= count;
                    _player.Out.SendUpdateInventorySlot(item.Place, true, item, _bagType);
                    _player.Out.SendUpdateInventorySlot(clone.Place, true, clone, _bagType);
                    return(true);
                }
            }
            else
            {
                _player.Out.SendUpdateInventorySlot(item.Place, true, item, _bagType);
            }

            return(false);
        }
Ejemplo n.º 2
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //TODO: 储存物品
            if (client.Player.PlayerCharacter.ConsortiaID == 0)
            {
                return(1);
            }

            int bagType    = packet.ReadByte();
            int bagPlace   = packet.ReadInt();
            int storePlace = packet.ReadInt();

            if (bagType == 0 && bagPlace < 31)
            {
                return(1);
            }

            ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);

            if (info != null)
            {
                PlayerInventory storeBag = client.Player.StoreBag;
                PlayerInventory toBag    = client.Player.GetInventory((eBageType)bagType);
                // client.Player.StoreBag.MoveToStore(storeBag, storePlace, bagPlace, toBag, info.StoreLevel * 10);
            }

            return(0);
        }
Ejemplo n.º 3
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result;

            if (player.PlayerCharacter.ConsortiaID == 0)
            {
                result = 1;
            }
            else
            {
                int bagType    = (int)packet.ReadByte();
                int bagPlace   = packet.ReadInt();
                int storePlace = packet.ReadInt();
                if (bagType == 0 && bagPlace < 31)
                {
                    result = 1;
                }
                else
                {
                    ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                    if (info != null)
                    {
                        PlayerInventory storeBag = player.StoreBag;
                        PlayerInventory toBag    = player.GetInventory((eBageType)bagType);
                    }
                    result = 0;
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result2;

            if (player.PlayerCharacter.ConsortiaID == 0)
            {
                result2 = 0;
            }
            else
            {
                bool          result = false;
                string        msg    = "ConsortiaSmithUpGradeHandler.Failed";
                ConsortiaInfo info   = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                if (info == null)
                {
                    msg = "ConsortiaSmithUpGradeHandler.NoConsortia";
                }
                else
                {
                    using (ConsortiaBussiness cb = new ConsortiaBussiness())
                    {
                        if (cb.UpGradeSmithConsortia(player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.ID, ref msg))
                        {
                            info.SmithLevel++;
                            GameServer.Instance.LoginServer.SendConsortiaSmithUpGrade(info);
                            msg    = "ConsortiaSmithUpGradeHandler.Success";
                            result = true;
                        }
                    }
                }
                if (info.SmithLevel >= 3 && info.Level <= 10)
                {
                    string msg2 = LanguageMgr.GetTranslation("ConsortiaSmithUpGradeHandler.Notice", new object[]
                    {
                        player.PlayerCharacter.ConsortiaName,
                        info.SmithLevel
                    });
                    GSPacketIn pkg = new GSPacketIn(10);
                    pkg.WriteInt(2);
                    pkg.WriteString(msg2);
                    GameServer.Instance.LoginServer.SendPacket(pkg);
                    GamePlayer[] players = WorldMgr.GetAllPlayers();
                    GamePlayer[] array   = players;
                    for (int i = 0; i < array.Length; i++)
                    {
                        GamePlayer p = array[i];
                        if (p != player)
                        {
                            p.Out.SendTCP(pkg);
                        }
                    }
                }
                packet.WriteBoolean(result);
                packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0]));
                player.Out.SendTCP(packet);
                result2 = 1;
            }
            return(result2);
        }
Ejemplo n.º 5
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result2;

            if (player.PlayerCharacter.ConsortiaID != 0)
            {
                result2 = 0;
            }
            else
            {
                int    id            = packet.ReadInt();
                bool   result        = false;
                int    consortiaID   = 0;
                string consortiaName = "";
                string msg           = "ConsortiaInvitePassHandler.Failed";
                int    tempID        = 0;
                string tempName      = "";
                using (ConsortiaBussiness db = new ConsortiaBussiness())
                {
                    int consortiaRepute    = 0;
                    ConsortiaUserInfo info = new ConsortiaUserInfo();
                    if (db.PassConsortiaInviteUsers(id, player.PlayerCharacter.ID, player.PlayerCharacter.NickName, ref consortiaID, ref consortiaName, ref msg, info, ref tempID, ref tempName, ref consortiaRepute))
                    {
                        player.PlayerCharacter.ConsortiaID   = consortiaID;
                        player.PlayerCharacter.ConsortiaName = consortiaName;
                        player.PlayerCharacter.DutyLevel     = info.Level;
                        player.PlayerCharacter.DutyName      = info.DutyName;
                        player.PlayerCharacter.Right         = info.Right;
                        ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(consortiaID);
                        if (consotia != null)
                        {
                            player.PlayerCharacter.ConsortiaLevel = consotia.Level;
                        }
                        msg                = "ConsortiaInvitePassHandler.Success";
                        result             = true;
                        info.UserID        = player.PlayerCharacter.ID;
                        info.UserName      = player.PlayerCharacter.NickName;
                        info.Grade         = player.PlayerCharacter.Grade;
                        info.Offer         = player.PlayerCharacter.Offer;
                        info.RichesOffer   = player.PlayerCharacter.RichesOffer;
                        info.RichesRob     = player.PlayerCharacter.RichesRob;
                        info.Win           = player.PlayerCharacter.Win;
                        info.Total         = player.PlayerCharacter.Total;
                        info.Escape        = player.PlayerCharacter.Escape;
                        info.ConsortiaID   = consortiaID;
                        info.ConsortiaName = consortiaName;
                        GameServer.Instance.LoginServer.SendConsortiaUserPass(tempID, tempName, info, true, consortiaRepute, player.PlayerCharacter.UserName, player.PlayerCharacter.FightPower, player.PlayerCharacter.AchievementPoint, player.PlayerCharacter.Honor);
                    }
                }
                packet.WriteBoolean(result);
                packet.WriteInt(consortiaID);
                packet.WriteString(consortiaName);
                packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0]));
                player.Out.SendTCP(packet);
                result2 = 0;
            }
            return(result2);
        }
        public void HandleConsortiaUserPass(GSPacketIn packet)
        {
            packet.ReadInt();
            packet.ReadBoolean();
            int    num           = packet.ReadInt();
            string consortiaName = packet.ReadString();
            int    num2          = packet.ReadInt();

            packet.ReadString();
            packet.ReadInt();
            packet.ReadString();
            packet.ReadInt();
            string dutyName = packet.ReadString();

            packet.ReadInt();
            packet.ReadInt();
            packet.ReadInt();
            packet.ReadDateTime();
            packet.ReadInt();
            int dutyLevel = packet.ReadInt();

            packet.ReadInt();
            packet.ReadBoolean();
            int right = packet.ReadInt();

            packet.ReadInt();
            packet.ReadInt();
            packet.ReadInt();
            int consortiaRepute = packet.ReadInt();

            GamePlayer[] allPlayers = WorldMgr.GetAllPlayers();
            GamePlayer[] array      = allPlayers;
            for (int i = 0; i < array.Length; i++)
            {
                GamePlayer gamePlayer = array[i];
                if (gamePlayer.PlayerCharacter.ID == num2)
                {
                    gamePlayer.BeginChanges();
                    gamePlayer.PlayerCharacter.ConsortiaID     = num;
                    gamePlayer.PlayerCharacter.ConsortiaName   = consortiaName;
                    gamePlayer.PlayerCharacter.DutyName        = dutyName;
                    gamePlayer.PlayerCharacter.DutyLevel       = dutyLevel;
                    gamePlayer.PlayerCharacter.Right           = right;
                    gamePlayer.PlayerCharacter.ConsortiaRepute = consortiaRepute;
                    ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(num);
                    if (consortiaInfo != null)
                    {
                        gamePlayer.PlayerCharacter.ConsortiaLevel = consortiaInfo.Level;
                    }
                    gamePlayer.CommitChanges();
                }
                if (gamePlayer.PlayerCharacter.ConsortiaID == num)
                {
                    gamePlayer.Out.SendTCP(packet);
                }
            }
        }
Ejemplo n.º 7
0
        public void HandleConsortiaUserPass(GSPacketIn packet)
        {
            int      cid             = packet.ReadInt();
            bool     isInvite        = packet.ReadBoolean();
            int      consortiaID     = packet.ReadInt();
            string   consortiaName   = packet.ReadString();
            int      id              = packet.ReadInt();
            string   userName        = packet.ReadString();
            int      inviteUserID    = packet.ReadInt();
            string   inviteUserName  = packet.ReadString();
            int      dutyID          = packet.ReadInt();
            string   dutyName        = packet.ReadString();
            int      offer           = packet.ReadInt();
            int      richesOffer     = packet.ReadInt();
            int      richesRob       = packet.ReadInt();
            DateTime lastDate        = packet.ReadDateTime();
            int      grade           = packet.ReadInt();
            int      level           = packet.ReadInt();
            int      state           = packet.ReadInt();
            bool     sex             = packet.ReadBoolean();
            int      right           = packet.ReadInt();
            int      win             = packet.ReadInt();
            int      total           = packet.ReadInt();
            int      escape          = packet.ReadInt();
            int      consortiaRepute = packet.ReadInt();

            GamePlayer[] players = WorldMgr.GetAllPlayers();
            foreach (GamePlayer p in players)
            {
                if (p.PlayerCharacter.ID == id)
                {
                    p.BeginChanges();

                    p.PlayerCharacter.ConsortiaID     = consortiaID;
                    p.PlayerCharacter.ConsortiaName   = consortiaName;
                    p.PlayerCharacter.DutyName        = dutyName;
                    p.PlayerCharacter.DutyLevel       = level;
                    p.PlayerCharacter.Right           = right;
                    p.PlayerCharacter.ConsortiaRepute = consortiaRepute;
                    ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(consortiaID);
                    if (consotia != null)
                    {
                        p.PlayerCharacter.ConsortiaLevel = consotia.Level;
                    }

                    p.CommitChanges();
                }

                if (p.PlayerCharacter.ConsortiaID == consortiaID)
                {
                    p.Out.SendTCP(packet);
                }
            }
        }
Ejemplo n.º 8
0
        private ItemInfo getitem(GameClient client, int type, string color, string skin, int id)
        {
            ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
            ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(id);
            bool         flag             = false;
            ItemInfo     itemInfo         = null;

            if (shopItemInfoById != null)
            {
                itemInfo = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID), 1, 102);
                if (shopItemInfoById.BuyType == 0)
                {
                    if (1 == type)
                    {
                        itemInfo.ValidDate = shopItemInfoById.AUnit;
                    }
                    if (2 == type)
                    {
                        itemInfo.ValidDate = shopItemInfoById.BUnit;
                    }
                    if (3 == type)
                    {
                        itemInfo.ValidDate = shopItemInfoById.CUnit;
                    }
                }
                else
                {
                    if (1 == type)
                    {
                        itemInfo.Count = shopItemInfoById.AUnit;
                    }
                    if (2 == type)
                    {
                        itemInfo.Count = shopItemInfoById.BUnit;
                    }
                    if (3 == type)
                    {
                        itemInfo.Count = shopItemInfoById.CUnit;
                    }
                }
                if (itemInfo != null || shopItemInfoById != null)
                {
                    itemInfo.Color = ((color == null) ? "" : color);
                    itemInfo.Skin  = ((skin == null) ? "" : skin);
                    if (flag)
                    {
                        itemInfo.IsBinds = true;
                        return(itemInfo);
                    }
                    itemInfo.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind);
                }
            }
            return(itemInfo);
        }
Ejemplo n.º 9
0
        private SqlDataProvider.Data.ItemInfo getitem(GameClient client, int type, string color, string skin, int id)
        {
            ConsortiaInfo info             = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
            ShopItemInfo  shopItemInfoById = ShopMgr.GetShopItemInfoById(id);
            bool          flag             = false;

            SqlDataProvider.Data.ItemInfo info3 = null;
            if (shopItemInfoById != null)
            {
                info3 = SqlDataProvider.Data.ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID), 1, 102);
                if (0 == shopItemInfoById.BuyType)
                {
                    if (1 == type)
                    {
                        info3.ValidDate = shopItemInfoById.AUnit;
                    }
                    if (2 == type)
                    {
                        info3.ValidDate = shopItemInfoById.BUnit;
                    }
                    if (3 == type)
                    {
                        info3.ValidDate = shopItemInfoById.CUnit;
                    }
                }
                else
                {
                    if (1 == type)
                    {
                        info3.Count = shopItemInfoById.AUnit;
                    }
                    if (2 == type)
                    {
                        info3.Count = shopItemInfoById.BUnit;
                    }
                    if (3 == type)
                    {
                        info3.Count = shopItemInfoById.CUnit;
                    }
                }
                if ((info3 != null) || (shopItemInfoById != null))
                {
                    info3.Color = (color == null) ? "" : color;
                    info3.Skin  = (skin == null) ? "" : skin;
                    if (flag)
                    {
                        info3.IsBinds = true;
                        return(info3);
                    }
                    info3.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind);
                }
            }
            return(info3);
        }
Ejemplo n.º 10
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int result;

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                result = 0;
            }
            else
            {
                int           consortiaID = packet.ReadInt();
                ConsortiaInfo consortia   = ConsortiaMgr.FindConsortiaInfo(consortiaID);
                if (consortia.ChairmanName != client.Player.PlayerCharacter.NickName)
                {
                    result = 0;
                }
                else
                {
                    eBageType bagType         = (eBageType)packet.ReadByte();
                    int       place           = packet.ReadInt();
                    string    newConsotiaName = packet.ReadString();
                    string    message         = "";
                    ItemInfo  info            = client.Player.GetItemAt(bagType, place);
                    if (info != null)
                    {
                        if (info.TemplateID == 11993)
                        {
                            string userName = client.Player.PlayerCharacter.UserName;
                            string nickName = client.Player.PlayerCharacter.NickName;
                            using (PlayerBussiness db = new PlayerBussiness())
                            {
                                if (db.RenameConsortiaNameByCard(userName, nickName, newConsotiaName, ref message))
                                {
                                    client.Player.RemoveItem(info, eItemRemoveType.Use);
                                    packet.WriteString(LanguageMgr.GetTranslation("Tank.Request.RenameConsortiaName.Success", new object[0]));
                                    client.Out.SendTCP(packet);
                                }
                                else
                                {
                                    client.Out.SendMessage(eMessageType.Normal, message);
                                }
                            }
                        }
                    }
                    result = 0;
                }
            }
            return(result);
        }
Ejemplo n.º 11
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.ConsortiaID == 0)
            {
                return(1);
            }
            int num  = (int)packet.ReadByte();
            int num2 = packet.ReadInt();

            packet.ReadInt();
            if (num == 0 && num2 < 31)
            {
                return(1);
            }
            ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);

            if (consortiaInfo != null)
            {
                PlayerInventory arg_57_0 = client.Player.ConsortiaBag;
                client.Player.GetInventory((eBageType)num);
            }
            return(0);
        }
Ejemplo n.º 12
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result2;

            if (player.PlayerCharacter.ConsortiaID == 0)
            {
                result2 = 0;
            }
            else
            {
                bool          result = false;
                string        msg    = "ConsortiaStoreUpGradeHandler.Failed";
                ConsortiaInfo info   = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                if (info == null)
                {
                    msg = "ConsortiaStoreUpGradeHandler.NoConsortia";
                }
                else
                {
                    using (ConsortiaBussiness cb = new ConsortiaBussiness())
                    {
                        if (cb.UpGradeStoreConsortia(player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.ID, ref msg))
                        {
                            info.StoreLevel++;
                            GameServer.Instance.LoginServer.SendConsortiaStoreUpGrade(info);
                            msg    = "ConsortiaStoreUpGradeHandler.Success";
                            result = true;
                        }
                    }
                }
                packet.WriteBoolean(result);
                packet.WriteString(LanguageMgr.GetTranslation(msg, new object[0]));
                player.Out.SendTCP(packet);
                result2 = 1;
            }
            return(result2);
        }
Ejemplo n.º 13
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            StringBuilder stringBuilder = new StringBuilder();
            bool          flag          = false;
            bool          flag2         = packet.ReadBoolean();
            bool          flag3         = packet.ReadBoolean();
            GSPacketIn    gSPacketIn    = new GSPacketIn(59, client.Player.PlayerCharacter.ID);
            ItemInfo      itemAt        = client.Player.StoreBag.GetItemAt(0);
            ItemInfo      itemInfo      = client.Player.StoreBag.GetItemAt(1);
            int           num           = 1;
            string        beginProperty = null;
            string        text          = "";

            using (ItemRecordBussiness itemRecordBussiness = new ItemRecordBussiness())
            {
                itemRecordBussiness.PropertyString(itemInfo, ref beginProperty);
            }
            if (itemInfo != null && itemInfo.Template.CanStrengthen && itemInfo.Template.CategoryID < 18 && itemInfo.Count == 1)
            {
                flag = (flag || itemInfo.IsBinds);
                stringBuilder.Append(string.Concat(new object[]
                {
                    itemInfo.ItemID,
                    ":",
                    itemInfo.TemplateID,
                    ","
                }));
                double num2            = 0.0;
                double num3            = 0.0;
                double num4            = 0.0;
                int    strengthenExp   = itemInfo.StrengthenExp;
                int    strengthenLevel = itemInfo.StrengthenLevel;
                if (strengthenLevel >= 12)
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("Level đã đạt cấp độ cao nhất, không thể cường hóa!", new object[0]));
                    return(0);
                }
                bool          flag4         = false;
                ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                if (flag2)
                {
                    ConsortiaBussiness        consortiaBussiness   = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);
                    if (consortiaInfo == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
                            return(1);
                        }
                        flag4 = true;
                    }
                }
                if (itemAt != null && itemAt.Template.CategoryID == 11 && (itemAt.Template.Property1 == 2 || itemAt.Template.Property1 == 35))
                {
                    flag = (flag || itemAt.IsBinds);
                    string text2 = text;
                    text = string.Concat(new string[]
                    {
                        text2,
                        ",",
                        itemAt.ItemID.ToString(),
                        ":",
                        itemAt.Template.Name
                    });
                    int num5 = (itemAt.Template.Property2 < 10) ? 10 : itemAt.Template.Property2;
                    if (flag4)
                    {
                        int    smithLevel = consortiaInfo.SmithLevel;
                        double num6       = (double)GameProperties.ConsortiaStrengExp(smithLevel - 1);
                        num3 = num6 * (double)num5 / 100.0;
                    }
                    if (client.Player.PlayerCharacter.VIPExpireDay.Date >= DateTime.Now.Date)
                    {
                        int    vIPLevel = client.Player.PlayerCharacter.VIPLevel;
                        double num7     = (double)GameProperties.VIPStrengthenExp(vIPLevel - 1);
                        num4 = num7 * (double)num5 / 100.0;
                    }
                    num5 += (int)num3 + (int)num4;
                    if (flag3)
                    {
                        int needExp = StrengthenMgr.getNeedExp(strengthenExp, strengthenLevel);
                        num = this.CalculatorCount(needExp, num5);
                        if (num > itemAt.Count)
                        {
                            num = itemAt.Count;
                        }
                        num2 += (double)(num5 * num);
                    }
                    else
                    {
                        num2 += (double)num5;
                    }
                }
                stringBuilder.Append("true");
                int num8 = (int)num2 + strengthenExp;
                if (StrengthenMgr.canUpLv(num8, strengthenLevel))
                {
                    itemInfo.StrengthenLevel++;
                    itemInfo.StrengthenExp = num8 - StrengthenMgr.FindStrengthenExpInfo(strengthenLevel + 1).Exp;
                    gSPacketIn.WriteByte(1);
                    StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(itemInfo.StrengthenLevel, itemInfo.TemplateID);
                    if (strengthenGoodsInfo != null && itemInfo.Template.CategoryID == 7 && strengthenGoodsInfo.GainEquip > itemInfo.TemplateID)
                    {
                        ItemTemplateInfo itemTemplateInfo = ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip);
                        if (itemTemplateInfo != null)
                        {
                            ItemInfo itemInfo2 = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 116);
                            itemInfo2.StrengthenLevel = itemInfo.StrengthenLevel;
                            itemInfo2.StrengthenExp   = itemInfo.StrengthenExp;
                            StrengthenMgr.InheritProperty(itemInfo, ref itemInfo2);
                            client.Player.StoreBag.RemoveItemAt(1);
                            client.Player.StoreBag.AddItemTo(itemInfo2, 1);
                            itemInfo = itemInfo2;
                        }
                    }
                    if (itemInfo.StrengthenLevel == 10 || itemInfo.StrengthenLevel == 12)
                    {
                        string translation = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", new object[]
                        {
                            client.Player.PlayerCharacter.NickName,
                            itemInfo.Template.Name,
                            itemInfo.StrengthenLevel
                        });
                        client.Player.SendAllMessage(translation);
                    }
                }
                else
                {
                    itemInfo.StrengthenExp = num8;
                }
                client.Player.StoreBag.RemoveTemplate(itemAt.TemplateID, num);
                client.Player.StoreBag.UpdateItem(itemInfo);
                client.Player.OnItemStrengthen(itemInfo.Template.CategoryID, itemInfo.StrengthenLevel);
                LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Strengthen, beginProperty, itemInfo, text, 1);
                gSPacketIn.WriteBoolean(false);
                client.Out.SendTCP(gSPacketIn);
                stringBuilder.Append(itemInfo.StrengthenLevel);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1", new object[0]) + itemAt.Template.Name + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2", new object[0]));
            }
            if (itemInfo.Place < 31)
            {
                client.Player.MainBag.UpdatePlayerProperties();
            }
            return(0);
        }
Ejemplo n.º 14
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();
            StringBuilder str      = new StringBuilder();
            int           mustGold = AppConfig.AppSettings["ComposeGold"].ConvertToInt(1000);
            int           result2;

            if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                result2 = 0;
            }
            else
            {
                if (player.PlayerCharacter.Gold < mustGold)
                {
                    player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemComposeHandler.NoMoney", new object[0]));
                    result2 = 0;
                }
                else
                {
                    bool     isBinds       = false;
                    bool     consortia     = packet.ReadBoolean();
                    ItemInfo item          = player.HideBag.GetItemAt(1);
                    ItemInfo stone         = player.HideBag.GetItemAt(2);
                    ItemInfo luck          = null;
                    string   BeginProperty = "";
                    if (item != null)
                    {
                        BeginProperty = item.GetPropertyString();
                    }
                    string AddItem = null;
                    if (item != null && stone != null && item.Template.CanCompose && (item.Template.CategoryID < 10 || item.Template.CategoryID >= 18) && stone.Template.CategoryID == 11 && stone.Template.Property1 == 1)
                    {
                        isBinds = (isBinds || item.IsBinds);
                        isBinds = (isBinds || stone.IsBinds);
                        str.Append(string.Concat(new object[]
                        {
                            item.ItemID,
                            ":",
                            item.TemplateID,
                            ",",
                            stone.ItemID,
                            ":",
                            stone.TemplateID,
                            ","
                        }));
                        bool   result      = false;
                        byte   isSuccess   = 1;
                        bool   isGod       = false;
                        double probability = (double)stone.Template.Property2;
                        luck = player.HideBag.GetItemAt(0);
                        if (luck != null)
                        {
                            if (luck.Template.CategoryID == 11 && luck.Template.Property1 == 3)
                            {
                                isBinds = (isBinds || luck.IsBinds);
                                object obj = AddItem;
                                AddItem = string.Concat(new object[]
                                {
                                    obj,
                                    "|",
                                    luck.ItemID,
                                    ":",
                                    luck.Template.Name,
                                    "|",
                                    stone.ItemID,
                                    ":",
                                    stone.Template.Name
                                });
                                probability *= (double)(luck.Template.Property2 + 100);
                                str.Append(string.Concat(new object[]
                                {
                                    luck.ItemID,
                                    ":",
                                    luck.TemplateID,
                                    ","
                                }));
                            }
                            else
                            {
                                probability *= 100.0;
                                luck         = null;
                            }
                        }
                        else
                        {
                            probability *= 100.0;
                        }
                        if (consortia)
                        {
                            ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                            using (ConsortiaBussiness csbs = new ConsortiaBussiness())
                            {
                                ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(player.PlayerCharacter.ConsortiaID, 0, 2);
                                if (info == null)
                                {
                                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
                                }
                                else
                                {
                                    if (player.PlayerCharacter.Riches < cecInfo.Riches)
                                    {
                                        player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
                                        result2 = 1;
                                        return(result2);
                                    }
                                    probability *= 1.0 + 0.1 * (double)info.SmithLevel;
                                }
                            }
                        }
                        int rand = ItemComposeHandler.random.Next(10000);
                        switch (stone.Template.Property3)
                        {
                        case 1:
                            if (stone.Template.Property4 > item.AttackCompose)
                            {
                                result = true;
                                if (probability > (double)rand)
                                {
                                    isSuccess          = 0;
                                    item.AttackCompose = stone.Template.Property4;
                                }
                                else
                                {
                                    if (!isGod)
                                    {
                                    }
                                }
                            }
                            break;

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

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

                        case 4:
                            if (stone.Template.Property4 > item.LuckCompose)
                            {
                                result = true;
                                if (probability > (double)rand)
                                {
                                    isSuccess        = 0;
                                    item.LuckCompose = stone.Template.Property4;
                                }
                                else
                                {
                                    if (!isGod)
                                    {
                                    }
                                }
                            }
                            break;
                        }
                        if (result)
                        {
                            item.IsBinds = isBinds;
                            if (isSuccess != 0)
                            {
                                str.Append("false!");
                                result = false;
                                if (!isGod)
                                {
                                    if (item.Template.Level < 3)
                                    {
                                    }
                                }
                            }
                            else
                            {
                                str.Append("true!");
                                result = true;
                                player.OnItemCompose(stone.TemplateID);
                            }
                            //LogMgr.LogItemAdd(player.PlayerCharacter.ID, LogItemType.Compose, BeginProperty, item, AddItem, Convert.ToInt32(result));
                            stone.Count--;
                            player.UpdateItem(stone);
                            if (luck != null)
                            {
                                luck.Count--;
                                player.UpdateItem(luck);
                            }
                            player.RemoveGold(mustGold);
                            player.HideBag.UpdateItem(item);
                            pkg.WriteByte(isSuccess);
                            player.Out.SendTCP(pkg);
                            player.SaveIntoDatabase();
                        }
                        else
                        {
                            player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.NoLevel", new object[0]));
                        }
                    }
                    else
                    {
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.Fail", new object[0]));
                    }
                    result2 = 0;
                }
            }
            return(result2);
        }
Ejemplo n.º 15
0
        public static int countConnect = 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);
        }
Ejemplo n.º 16
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int             num            = 0;
            int             num2           = 0;
            int             num3           = 0;
            int             num4           = 0;
            int             num5           = 0;
            StringBuilder   stringBuilder  = new StringBuilder();
            eMessageType    eMessageType   = eMessageType.Normal;
            string          translateId    = "UserBuyItemHandler.Success";
            GSPacketIn      gSPacketIn     = new GSPacketIn(44);
            List <ItemInfo> list           = new List <ItemInfo>();
            List <bool>     list2          = new List <bool>();
            List <int>      list3          = new List <int>();
            StringBuilder   stringBuilder2 = new StringBuilder();
            bool            flag           = false;
            ConsortiaInfo   consortiaInfo  = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
            int             num6           = packet.ReadInt();

            for (int i = 0; i < num6; i++)
            {
                packet.ReadInt();
                int    iD    = packet.ReadInt();
                int    num7  = packet.ReadInt();
                string text  = packet.ReadString();
                bool   item  = packet.ReadBoolean();
                string text2 = packet.ReadString();
                int    item2 = packet.ReadInt();
                packet.ReadBoolean();
                ShopItemInfo shopItemInfoById = ShopMgr.GetShopItemInfoById(iD);
                if (shopItemInfoById == null)
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission", new object[0]));
                    return(1);
                }
                if (!ShopMgr.CanBuy(shopItemInfoById.ShopID, (consortiaInfo == null) ? 1 : consortiaInfo.ShopLevel, ref flag, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission", new object[0]));
                    return(1);
                }
                ItemTemplateInfo goods    = ItemMgr.FindItemTemplate(shopItemInfoById.TemplateID);
                ItemInfo         itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102);
                if (shopItemInfoById.BuyType == 0)
                {
                    if (1 == num7)
                    {
                        itemInfo.ValidDate = shopItemInfoById.AUnit;
                    }
                    if (2 == num7)
                    {
                        itemInfo.ValidDate = shopItemInfoById.BUnit;
                    }
                    if (3 == num7)
                    {
                        itemInfo.ValidDate = shopItemInfoById.CUnit;
                    }
                }
                else
                {
                    if (1 == num7)
                    {
                        itemInfo.Count = shopItemInfoById.AUnit;
                    }
                    if (2 == num7)
                    {
                        itemInfo.Count = shopItemInfoById.BUnit;
                    }
                    if (3 == num7)
                    {
                        itemInfo.Count = shopItemInfoById.CUnit;
                    }
                }
                if (itemInfo != null || shopItemInfoById != null)
                {
                    itemInfo.Color = ((text == null) ? "" : text);
                    itemInfo.Skin  = ((text2 == null) ? "" : text2);
                    if (flag)
                    {
                        itemInfo.IsBinds = true;
                    }
                    else
                    {
                        itemInfo.IsBinds = Convert.ToBoolean(shopItemInfoById.IsBind);
                    }
                    stringBuilder2.Append(num7);
                    stringBuilder2.Append(",");
                    list.Add(itemInfo);
                    list2.Add(item);
                    list3.Add(item2);
                    ItemInfo.SetItemType(shopItemInfoById, num7, ref num, ref num2, ref num3, ref num4, ref num5);
                }
            }
            int val = packet.ReadInt();

            if (list.Count == 0)
            {
                return(1);
            }
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(1);
            }
            bool flag2 = false;
            int  num8  = 0;

            if (num <= client.Player.PlayerCharacter.Gold && num2 <= client.Player.PlayerCharacter.Money && num3 <= client.Player.PlayerCharacter.Offer && num4 <= client.Player.PlayerCharacter.GiftToken)
            {
                num8++;
                client.Player.AddExpVip(num2);
                client.Player.RemoveMoney(num2);
                client.Player.RemoveGold(num);
                client.Player.RemoveOffer(num3);
                client.Player.RemoveGiftToken(num4);
                string        text3          = "";
                int           num9           = 0;
                MailInfo      mailInfo       = new MailInfo();
                StringBuilder stringBuilder3 = new StringBuilder();
                stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0]));
                for (int j = 0; j < list.Count; j++)
                {
                    text3 += ((text3 == "") ? list[j].TemplateID.ToString() : ("," + list[j].TemplateID.ToString()));
                    if (!client.Player.AddTemplate(list[j], list[j].Template.BagType, list[j].Count))
                    {
                        flag2 = true;
                        using (PlayerBussiness playerBussiness = new PlayerBussiness())
                        {
                            list[j].UserID = 0;
                            playerBussiness.AddGoods(list[j]);
                            num9++;
                            stringBuilder3.Append(num9);
                            stringBuilder3.Append("、");
                            stringBuilder3.Append(list[j].Template.Name);
                            stringBuilder3.Append("x");
                            stringBuilder3.Append(list[j].Count);
                            stringBuilder3.Append(";");
                            switch (num9)
                            {
                            case 1:
                                mailInfo.Annex1     = list[j].ItemID.ToString();
                                mailInfo.Annex1Name = list[j].Template.Name;
                                break;

                            case 2:
                                mailInfo.Annex2     = list[j].ItemID.ToString();
                                mailInfo.Annex2Name = list[j].Template.Name;
                                break;

                            case 3:
                                mailInfo.Annex3     = list[j].ItemID.ToString();
                                mailInfo.Annex3Name = list[j].Template.Name;
                                break;

                            case 4:
                                mailInfo.Annex4     = list[j].ItemID.ToString();
                                mailInfo.Annex4Name = list[j].Template.Name;
                                break;

                            case 5:
                                mailInfo.Annex5     = list[j].ItemID.ToString();
                                mailInfo.Annex5Name = list[j].Template.Name;
                                break;
                            }
                            if (num9 == 5)
                            {
                                num9 = 0;
                                mailInfo.AnnexRemark = stringBuilder3.ToString();
                                stringBuilder3.Remove(0, stringBuilder3.Length);
                                stringBuilder3.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark", new object[0]));
                                mailInfo.Content    = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "]";
                                mailInfo.Gold       = 0;
                                mailInfo.Money      = 0;
                                mailInfo.Receiver   = client.Player.PlayerCharacter.NickName;
                                mailInfo.ReceiverID = client.Player.PlayerCharacter.ID;
                                mailInfo.Sender     = mailInfo.Receiver;
                                mailInfo.SenderID   = mailInfo.ReceiverID;
                                mailInfo.Title      = mailInfo.Content;
                                mailInfo.Type       = 8;
                                playerBussiness.SendMail(mailInfo);
                                eMessageType = eMessageType.ERROR;
                                translateId  = "UserBuyItemHandler.Mail";
                                mailInfo.Revert();
                            }
                        }
                    }
                }
                if (num9 > 0)
                {
                    using (PlayerBussiness playerBussiness2 = new PlayerBussiness())
                    {
                        mailInfo.AnnexRemark = stringBuilder3.ToString();
                        mailInfo.Content     = LanguageMgr.GetTranslation("UserBuyItemHandler.Title", new object[0]) + mailInfo.Annex1Name + "]";
                        mailInfo.Gold        = 0;
                        mailInfo.Money       = 0;
                        mailInfo.Receiver    = client.Player.PlayerCharacter.NickName;
                        mailInfo.ReceiverID  = client.Player.PlayerCharacter.ID;
                        mailInfo.Sender      = mailInfo.Receiver;
                        mailInfo.SenderID    = mailInfo.ReceiverID;
                        mailInfo.Title       = mailInfo.Content;
                        mailInfo.Type        = 8;
                        playerBussiness2.SendMail(mailInfo);
                        eMessageType = eMessageType.ERROR;
                        translateId  = "UserBuyItemHandler.Mail";
                    }
                }
                if (eMessageType == eMessageType.ERROR)
                {
                    client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver);
                }
                client.Player.OnPaid(num2, num, num3, num4, num5, stringBuilder.ToString());
                LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, num, num4, num3, num5, "牌子编号", text3, stringBuilder2.ToString());
            }
            else
            {
                if (num2 > client.Player.PlayerCharacter.Money)
                {
                    translateId = "UserBuyItemHandler.NoMoney";
                }
                if (num > client.Player.PlayerCharacter.Gold)
                {
                    translateId = "UserBuyItemHandler.NoGold";
                }
                if (num3 > client.Player.PlayerCharacter.Offer)
                {
                    translateId = "UserBuyItemHandler.NoOffer";
                }
                if (num4 > client.Player.PlayerCharacter.GiftToken)
                {
                    translateId = "UserBuyItemHandler.GiftToken";
                }
                if (num5 > client.Player.PlayerCharacter.medal)
                {
                    translateId = "UserBuyItemHandler.Medal";
                }
                eMessageType = eMessageType.ERROR;
            }
            int val2 = 0;

            if (num8 == num6)
            {
                val2 = (flag2 ? 2 : 1);
            }
            client.Player.MainBag.SaveToDatabase();
            client.Player.PropBag.SaveToDatabase();
            gSPacketIn.WriteInt(val2);
            gSPacketIn.WriteInt(val);
            client.Out.SendMessage(eMessageType, LanguageMgr.GetTranslation(translateId, new object[0]));
            client.Out.SendTCP(gSPacketIn);
            return(0);
        }
Ejemplo n.º 17
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int  pRICE_STRENGHTN_GOLD = AppConfig.AppSettings["StrengthenGold"].ConvertToInt(1000);
            bool flag = player.PlayerCharacter.Gold < pRICE_STRENGHTN_GOLD;
            int  num;
            int  result;

            if (flag)
            {
                player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney", new object[0]));
                num = 0;
            }
            else
            {
                GSPacketIn gSPacketIn = packet.Clone();
                gSPacketIn.ClearContext();
                ItemInfo itemInfo = player.HideBag.GetItemAt(5);
                bool     flag2    = itemInfo != null && itemInfo.Template.CanStrengthen && itemInfo.Count == 1;
                if (flag2)
                {
                    StrengthenInfo strengthenInfo = StrengthenMgr.FindStrengthenInfo(itemInfo.StrengthenLevel + 1);
                    bool           flag3          = strengthenInfo == null;
                    if (flag3)
                    {
                        bool flag4 = itemInfo.StrengthenLevel == 9 || itemInfo.StrengthenLevel == 15;
                        if (flag4)
                        {
                            player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.FullStrengthLevel", new object[0]));
                        }
                        else
                        {
                            player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength", new object[0]));
                        }
                        num    = 0;
                        result = num;
                        return(result);
                    }
                    bool          flag5          = itemInfo.IsBinds;
                    bool          flag6          = packet.ReadBoolean();
                    StringBuilder stringBuilder  = new StringBuilder();
                    string        propertyString = itemInfo.GetPropertyString();
                    double        num2           = 0.0;
                    bool          flag7          = false;
                    ItemInfo      itemInfo2      = player.HideBag.GetItemAt(3);
                    bool          flag8          = itemInfo2 != null && itemInfo2.Template.CategoryID == 11 && itemInfo2.Template.Property1 == 7;
                    if (flag8)
                    {
                        flag5 |= itemInfo2.IsBinds;
                        stringBuilder.Append(itemInfo2.ToShortString());
                        flag7 = true;
                    }
                    else
                    {
                        itemInfo2 = null;
                    }
                    bool            flag9  = false;
                    List <ItemInfo> list   = new List <ItemInfo>();
                    ItemInfo        itemAt = player.HideBag.GetItemAt(0);
                    bool            flag10 = itemAt != null && itemAt.Template.CategoryID == 11 && (itemAt.Template.Property1 == 2 || itemAt.Template.Property1 == 35) && !list.Contains(itemAt);
                    if (flag10)
                    {
                        bool flag11 = itemInfo.StrengthenLevel >= 15 && itemAt.Template.Property8 == 2;
                        if (flag11)
                        {
                            player.Out.SendMessage(0, "不能使用[" + itemAt.Template.Name + "]来强化此装备.");
                            num    = 1;
                            result = num;
                            return(result);
                        }
                        flag5 |= itemAt.IsBinds;
                        flag9 |= (itemAt.Template.Property1 == 35 && itemAt.Template.CategoryID == 11);
                        num2  += (double)itemAt.Template.Property2;
                        stringBuilder.Append(itemAt.ToShortString());
                        list.Add(itemAt);
                    }
                    ItemInfo itemAt2 = player.HideBag.GetItemAt(1);
                    bool     flag12  = itemAt2 != null && itemAt2.Template.CategoryID == 11 && (itemAt2.Template.Property1 == 2 || itemAt2.Template.Property1 == 35) && !list.Contains(itemAt2);
                    if (flag12)
                    {
                        bool flag13 = itemInfo.StrengthenLevel >= 15 && itemAt2.Template.Property8 == 2;
                        if (flag13)
                        {
                            player.Out.SendMessage(0, "不能使用[" + itemAt2.Template.Name + "]来强化此装备.");
                            num    = 1;
                            result = num;
                            return(result);
                        }
                        flag5 |= itemAt2.IsBinds;
                        flag9 |= (itemAt2.Template.Property1 == 35 && itemAt2.Template.CategoryID == 11);
                        num2  += (double)itemAt2.Template.Property2;
                        stringBuilder.Append(itemAt2.ToShortString());
                        list.Add(itemAt2);
                    }
                    ItemInfo itemAt3 = player.HideBag.GetItemAt(2);
                    bool     flag14  = itemAt3 != null && itemAt3.Template.CategoryID == 11 && (itemAt3.Template.Property1 == 2 || itemAt3.Template.Property1 == 35) && !list.Contains(itemAt3);
                    if (flag14)
                    {
                        bool flag15 = itemInfo.StrengthenLevel >= 15 && itemAt3.Template.Property8 == 2;
                        if (flag15)
                        {
                            player.Out.SendMessage(0, "不能使用[" + itemAt3.Template.Name + "]来强化此装备.");
                            num    = 1;
                            result = num;
                            return(result);
                        }
                        flag5 |= itemAt3.IsBinds;
                        flag9 |= (itemAt3.Template.Property1 == 35 && itemAt3.Template.CategoryID == 11);
                        num2  += (double)itemAt3.Template.Property2;
                        stringBuilder.Append(itemAt3.ToShortString());
                        list.Add(itemAt3);
                    }
                    ItemInfo itemInfo3 = player.HideBag.GetItemAt(4);
                    bool     flag16    = itemInfo3 != null && itemInfo3.Template.CategoryID == 11 && itemInfo3.Template.Property1 == 3;
                    if (flag16)
                    {
                        flag5 |= itemInfo3.IsBinds;
                        num2  *= (double)(itemInfo3.Template.Property2 + 100);
                        stringBuilder.Append(itemInfo3.ToShortString());
                    }
                    else
                    {
                        num2     *= 100.0;
                        itemInfo3 = null;
                    }
                    bool          flag17        = false;
                    ConsortiaInfo consortiaInfo = null;
                    bool          flag18        = flag6;
                    if (flag18)
                    {
                        consortiaInfo = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                        bool flag19 = consortiaInfo == null;
                        if (flag19)
                        {
                            player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
                        }
                        else
                        {
                            using (ConsortiaBussiness consortiaBussiness = new ConsortiaBussiness())
                            {
                                ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(player.PlayerCharacter.ConsortiaID, 0, 2);
                                bool flag20 = player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches;
                                if (flag20)
                                {
                                    player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
                                    num    = 1;
                                    result = num;
                                    return(result);
                                }
                                flag17 = true;
                            }
                        }
                    }
                    bool flag21 = list.Count >= 1;
                    if (flag21)
                    {
                        StrengthenGoodsInfo strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(itemInfo.StrengthenLevel + 1, itemInfo.TemplateID);
                        ItemInfo            itemInfo4           = null;
                        bool flag22 = strengthenGoodsInfo != null;
                        if (flag22)
                        {
                            itemInfo4 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(strengthenGoodsInfo.GainEquip), 1, 116);
                            bool flag23 = itemInfo4 == null;
                            if (flag23)
                            {
                                num    = 0;
                                result = num;
                                return(result);
                            }
                        }
                        string text = null;
                        player.HideBag.BeginChanges();
                        try
                        {
                            num2 /= (double)strengthenInfo.Rock;
                            int num3;
                            for (int i = 0; i < list.Count; i = num3 + 1)
                            {
                                player.HideBag.RemoveCountFromStack(list[i], 1, (eItemRemoveType)5);
                                num3 = i;
                            }
                            bool flag24 = itemInfo3 != null;
                            if (flag24)
                            {
                                player.HideBag.RemoveCountFromStack(itemInfo3, 1, (eItemRemoveType)5);
                            }
                            bool flag25 = itemInfo2 != null;
                            if (flag25)
                            {
                                player.HideBag.RemoveCountFromStack(itemInfo2, 1, (eItemRemoveType)5);
                            }
                            bool flag26 = flag17;
                            if (flag26)
                            {
                                num2 *= 1.0 + 0.1 * (double)consortiaInfo.SmithLevel;
                            }
                            itemInfo.IsBinds = flag5;
                            int  num4   = 1;
                            bool flag27 = num2 > (double)ItemStrengthenHandler.random.Next(10000);
                            if (flag27)
                            {
                                num4 = 0;
                                bool flag28 = strengthenGoodsInfo != null && itemInfo4 != null;
                                if (flag28)
                                {
                                    StrengthenMgr.InheritProperty(itemInfo, itemInfo4);
                                    itemInfo4.StrengthenLevel = (itemInfo.StrengthenLevel + 1);
                                    player.HideBag.RemoveItem(itemInfo, (eItemRemoveType)5);
                                    player.HideBag.AddItemTo(itemInfo4, 5);
                                    text     = string.Format("temp_place_{0}", itemInfo.ItemID);
                                    itemInfo = itemInfo4;
                                    bool flag29 = itemInfo.ItemID == 0;
                                    if (flag29)
                                    {
                                        using (PlayerBussiness playerBussiness = new PlayerBussiness())
                                        {
                                            playerBussiness.AddGoods(itemInfo);
                                        }
                                    }
                                }
                                else
                                {
                                    ItemInfo itemInfo5 = itemInfo;
                                    num3 = itemInfo5.StrengthenLevel;
                                    itemInfo5.StrengthenLevel = (num3 + 1);
                                }
                                player.OnItemStrengthen(itemInfo.Template.CategoryID, itemInfo.StrengthenLevel);
                                bool flag30 = itemInfo.StrengthenLevel >= 7;
                                if (flag30)
                                {
                                    string translation = LanguageMgr.GetTranslation("ItemStrengthenHandler.congratulation", new object[]
                                    {
                                        player.PlayerCharacter.NickName,
                                        itemInfo.StrengthenLevel
                                    });
                                    GSPacketIn packet2 = WorldMgr.SendSysNotice(translation, itemInfo, player);
                                    GameServer.Instance.LoginServer.SendPacket(packet2);
                                }
                            }
                            else
                            {
                                num4 = 1;
                                bool flag31 = !flag7;
                                if (flag31)
                                {
                                    StrengthenGoodsInfo strengthenGoodsInfo2 = StrengthenMgr.FindStrengthenFailGoodsInfo(itemInfo.StrengthenLevel, itemInfo.TemplateID);
                                    itemInfo.StrengthenLevel = ((itemInfo.StrengthenLevel == 0) ? 0 : (itemInfo.StrengthenLevel - 1));
                                    bool flag32 = strengthenGoodsInfo2 != null;
                                    if (flag32)
                                    {
                                        ItemInfo itemInfo6 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(strengthenGoodsInfo2.CurrentEquip), 1, 116);
                                        bool     flag33    = itemInfo6 == null;
                                        if (flag33)
                                        {
                                            num    = 0;
                                            result = num;
                                            return(result);
                                        }
                                        StrengthenMgr.InheritProperty(itemInfo, itemInfo6);
                                        itemInfo6.StrengthenLevel = (itemInfo.StrengthenLevel);
                                        player.HideBag.RemoveItem(itemInfo, (eItemRemoveType)5);
                                        player.HideBag.AddItemTo(itemInfo6, 5);
                                    }
                                }
                            }
                            player.HideBag.UpdateItem(itemInfo);
                            gSPacketIn.WriteByte((byte)num4);
                            gSPacketIn.WriteBoolean(itemInfo.IsOpenHole);
                            player.RemoveGold(pRICE_STRENGHTN_GOLD);
                            //LogMgr.LogItemAdd(player.PlayerCharacter.ID, 1, propertyString, itemInfo, stringBuilder.ToString(), (num4 == 1) ? 0 : 1);
                        }
                        finally
                        {
                            player.HideBag.CommitChanges();
                            player.Out.SendTCP(gSPacketIn);
                        }
                        player.SaveIntoDatabase();
                        bool flag34 = text != null && player.TempProperties.ContainsKey(text);
                        if (flag34)
                        {
                            int num5 = (int)player.TempProperties[text];
                            player.TempProperties.Remove(text);
                            text = string.Format("temp_place_{0}", itemInfo.ItemID);
                            player.TempProperties.Add(text, num5);
                        }
                    }
                    else
                    {
                        player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Content1", new object[0]) + 1 + LanguageMgr.GetTranslation("ItemStrengthenHandler.Content2", new object[0]));
                    }
                }
                else
                {
                    player.Out.SendMessage(0, LanguageMgr.GetTranslation("ItemStrengthenHandler.Success", new object[0]));
                }
                num = 0;
            }
            result = num;
            return(result);
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType eBageType  = (eBageType)packet.ReadByte();
            int       num        = packet.ReadInt();
            eBageType eBageType2 = (eBageType)packet.ReadByte();
            int       num2       = packet.ReadInt();
            int       num3       = packet.ReadInt();

            packet.ReadBoolean();
            PlayerInventory inventory  = client.Player.GetInventory(eBageType);
            PlayerInventory inventory2 = client.Player.GetInventory(eBageType2);
            ItemInfo        itemAt     = inventory.GetItemAt(num);

            if (eBageType2 == eBageType.TempBag)
            {
                GameServer.log.Error("User want to put item into temp bag!");
                return(0);
            }
            if (inventory == null || itemAt == null)
            {
                return(0);
            }
            ItemInfo itemAt2 = inventory2.GetItemAt(num2);

            if (itemAt2 != null)
            {
                if (itemAt2.ItemID == itemAt.ItemID)
                {
                    GameServer.log.Error(string.Concat(new string[]
                    {
                        "Hack Trung ItemID ",
                        client.Player.PlayerCharacter.UserName,
                        "-[",
                        client.Player.PlayerCharacter.NickName,
                        "]"
                    }));
                    client.Disconnect();//kick user hack
                    return(0);
                }
                if (inventory == inventory2 && itemAt2.Place == itemAt.Place)
                {
                    GameServer.log.Error(string.Concat(new string[]
                    {
                        "Hack Trung PLace ",
                        client.Player.PlayerCharacter.UserName,
                        "-[",
                        client.Player.PlayerCharacter.NickName,
                        "]"
                    }));
                    return(0);
                }
            }
            if (num3 < 0 || num3 > itemAt.Count)
            {
                num3 = itemAt.Count;
            }
            inventory.BeginChanges();
            inventory2.BeginChanges();
            try
            {
                if (eBageType2 == eBageType.Consortia)
                {
                    ConsortiaInfo consortiaInfo = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    if (consortiaInfo != null)
                    {
                        inventory2.Capalility = consortiaInfo.StoreLevel * 10;
                    }
                }
                if (num2 == -1)
                {
                    bool flag = false;
                    if (eBageType == eBageType.CaddyBag && eBageType2 == eBageType.BeadBag)
                    {
                        num2 = inventory2.FindFirstEmptySlot();
                        if (inventory2.AddItemTo(itemAt, num2))
                        {
                            inventory.TakeOutItem(itemAt);
                        }
                        else
                        {
                            flag = true;
                        }
                    }
                    else
                    {
                        if (eBageType == eBageType2 && eBageType2 == eBageType.MainBag)
                        {
                            num2 = inventory2.FindFirstEmptySlot();
                            if (!inventory.MoveItem(num, num2, num3))
                            {
                                flag = true;
                            }
                        }
                        else
                        {
                            if (inventory2.StackItemToAnother(itemAt) || inventory2.AddItem(itemAt))
                            {
                                inventory.TakeOutItem(itemAt);
                            }
                            else
                            {
                                flag = true;
                            }
                        }
                    }
                    if (flag)
                    {
                        client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]));
                    }
                }
                else
                {
                    if (eBageType == eBageType2)
                    {
                        inventory.MoveItem(num, num2, num3);
                        client.Player.OnNewGearEvent(itemAt.Template.CategoryID);
                    }
                    else
                    {
                        if (eBageType == eBageType.Store)
                        {
                            this.MoveFromStore(client, inventory, itemAt, num2, inventory2, num3);
                        }
                        else
                        {
                            if (eBageType == eBageType.Consortia)
                            {
                                UserChangeItemPlaceHandler.MoveFromBank(client, num, num2, inventory, inventory2, itemAt);
                            }
                            else
                            {
                                if (eBageType2 == eBageType.Store)
                                {
                                    this.MoveToStore(client, inventory, itemAt, num2, inventory2, num3);
                                }
                                else
                                {
                                    if (eBageType2 == eBageType.Consortia)
                                    {
                                        UserChangeItemPlaceHandler.MoveToBank(num, num2, inventory, inventory2, itemAt);
                                    }
                                    else
                                    {
                                        if (inventory2.AddItemTo(itemAt, num2))
                                        {
                                            inventory.TakeOutItem(itemAt);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                inventory.CommitChanges();
                inventory2.CommitChanges();
            }
            return(0);
        }
Ejemplo n.º 20
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType       bageType   = (eBageType)packet.ReadByte();
            int             slot       = packet.ReadInt();
            eBageType       toBageType = (eBageType)packet.ReadByte();
            int             toSlot     = packet.ReadInt();
            int             count      = packet.ReadInt();
            PlayerInventory bag        = client.Player.GetInventory(bageType);
            PlayerInventory inventory  = client.Player.GetInventory(toBageType);

            if (toSlot < 0)
            {
                if ((inventory.BagType == (int)eBageType.Bank) || (inventory.BagType == (int)eBageType.PropBag))
                {
                    toSlot = inventory.FindFirstEmptySlot(0);
                }
                else
                {
                    toSlot = inventory.FindFirstEmptySlot(31);
                }
            }
            //==================================
            if (count > 0)
            {
                if ((bag == null) || (bag.GetItemAt(slot) == null))
                {
                    return(0);
                }
                if ((bageType == toBageType) && (slot != -1))
                {
                    if (bag.GetItemAt(slot).Count >= count)
                    {
                        Console.WriteLine("-----Stage 1 !");
                        bag.MoveItem(slot, toSlot, count);
                    }
                    else
                    {
                        Console.WriteLine("--" + client.Player.Account + " Hack = CE");
                        bag.MoveItem(slot, toSlot, bag.GetItemAt(slot).Count);
                    }
                    return(1);
                }

                if ((slot == -1) && (toSlot != -1))
                {
                    Console.WriteLine("-----Stage 2 !");
                    bag.RemoveItemAt(toSlot);
                    return(1);
                }

                if (((((slot != -1) && (toSlot == -1)) &&
                      ((bageType != eBageType.CaddyBag) &&
                       (toBageType != eBageType.Bank))) &&
                     (bageType != eBageType.Store)) &&
                    (toBageType != eBageType.Store))
                {
                    if (bageType == eBageType.MainBag)
                    {
                        Console.WriteLine("-----Stage 3 !");
                        bag.AddItem(client.Player.GetItemAt(bageType, slot), 31);
                    }
                    else
                    {
                        Console.WriteLine("-----Stage 4 !");
                        //bag.AddItem(client.Player.GetItemAt(bageType, slot), 0);
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Full"));
                    }
                    return(1);
                }

                if ((((slot != -1) && (toBageType != bageType)) && (toBageType != eBageType.Store)) && (toBageType != eBageType.MainBag))
                {
                    ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    if (info != null)
                    {
                        if (toBageType == eBageType.Store)
                        {
                        }
                        Console.WriteLine("-----Stage 5 !");
                        bag.MoveToStore(bag, slot, toSlot, inventory, info.StoreLevel * 10);
                        return(1);
                    }
                }

                if ((toBageType == eBageType.Store) || (bageType == eBageType.Store))
                {
                    SqlDataProvider.Data.ItemInfo itemAt = client.Player.GetItemAt(bageType, slot);
                    if ((itemAt != null) && (itemAt.Count > 1))
                    {
                        itemAt.Count -= count;
                        bag.UpdateItem(itemAt);
                        SqlDataProvider.Data.ItemInfo item = itemAt.Clone();
                        item.Count = count;
                        if (inventory.GetItemAt(toSlot) == null)
                        {
                            Console.WriteLine("-----Stage 6 !");
                            inventory.AddItemTo(item, toSlot);
                        }
                        else
                        {
                            SqlDataProvider.Data.ItemInfo itemByTemplateID = bag.GetItemByTemplateID(0, inventory.GetItemAt(toSlot).TemplateID);
                            if (itemByTemplateID == null)
                            {
                                Console.WriteLine("-----Stage 7 !");
                                bag.MoveToStore(inventory, toSlot, bag.FindFirstEmptySlot(0), bag, 999);
                            }
                            else
                            {
                                Console.WriteLine("-----Stage 8 !");
                                itemByTemplateID.Count++;
                                bag.UpdateItem(itemByTemplateID);
                                inventory.RemoveItemAt(toSlot);
                            }
                            Console.WriteLine("-----Stage 9 !");
                            inventory.AddItemTo(item, toSlot);
                        }
                    }
                    else
                    {
                        if ((((toBageType != eBageType.Store) && (toBageType != eBageType.MainBag)) && ((bag.GetItemAt(slot) != null) && (bag.GetItemAt(slot).Template.CategoryID == 7))) && (((toSlot > 0) && (toSlot < 31)) && (toSlot != 6)))
                        {
                            return(1);
                        }
                        try
                        {
                            Console.WriteLine("-----Stage 10 !");
                            bag.MoveToStore(bag, slot, toSlot, inventory, 50);
                        }
                        catch (Exception)
                        {
                            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", new object[] { slot, toSlot, bageType, toBageType });
                            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(slot), inventory.GetItemAt(toSlot));
                        }
                    }
                    return(1);
                }
                if ((toBageType == eBageType.MainBag) && (bageType == eBageType.Bank))
                {
                    Console.WriteLine("-----Stage 11!");
                    bag.MoveToStore(bag, slot, toSlot, inventory, 50);
                    return(1);
                }
            }
            //==================================
            return(0);
        }
Ejemplo n.º 21
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType bagType = (eBageType)packet.ReadByte();
            int       place   = packet.ReadInt();
            //int toBagTemp = packet.ReadByte();
            //if (toBagTemp == 11) toBagTemp++;
            //eBageType tobagType = (eBageType)toBagTemp;
            eBageType tobagType = (eBageType)packet.ReadByte();
            int       toplace   = packet.ReadInt();
            int       count     = packet.ReadInt();
            //pkg.writeByte(bagtype);
            //pkg.writeInt(place);
            //pkg.writeByte(tobagType);
            //pkg.writeInt(toplace);
            //pkg.writeInt(count);
            PlayerInventory bag   = client.Player.GetInventory(bagType);
            PlayerInventory tobag = client.Player.GetInventory(tobagType);



            //chong hack chua xac dinh. do nem' vui khi di lung tung
            if (bag == null || bag.GetItemAt(place) == null)
            {
                return(0);
            }
            // chuyen do noi bo trong cung 1 tui'
            if ((bagType == tobagType) && place != -1)
            {
                //.GetItemInventory(temp);
                bag.MoveItem(place, toplace, count);
                return(1);
            }
            if (place == -1 && toplace != -1)
            {
                bag.RemoveItemAt(toplace);
                return(1);
            }
            if (place != -1 && toplace == -1 && bagType != eBageType.CaddyBag && tobagType != eBageType.Bank && bagType != eBageType.Store && tobagType != eBageType.Store)
            {
                if (bagType == 0)
                {
                    bag.AddItem(client.Player.GetItemAt(bagType, place), 31); //toSolt = bag.FindFirstEmptySlot(31);
                }
                else
                {
                    bag.AddItem(client.Player.GetItemAt(bagType, place), 0);
                }
                return(1);
            }
            if (place != -1 && tobagType != bagType && tobagType != eBageType.Store && tobagType != eBageType.MainBag)
            {
                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                if (info != null)
                {
                    //if(tobagType==eBageType.Store) client.Player.StoreBag.MoveToStore(bag, place, bagType, info.StoreLevel * 10);

                    bag.MoveToStore(bag, place, toplace, tobag, info.StoreLevel * 10);
                    return(1);
                }
            }

            //danh cho store khi nang cap chuyen do ve main
            if (tobagType == eBageType.Store || bagType == eBageType.Store)
            {
                var item = client.Player.GetItemAt(bagType, place);
                if (item != null && item.Count > 1)
                {
                    item.Count--;
                    bag.UpdateItem(item);
                    var tempItem = item.Clone();
                    tempItem.Count = 1;
                    if (tobag.GetItemAt(toplace) == null)
                    {
                        tobag.AddItemTo(tempItem, toplace);
                    }
                    else
                    {
                        var tempItem2 = bag.GetItemByTemplateID(0, tobag.GetItemAt(toplace).TemplateID);
                        if (tempItem2 == null)
                        {
                            bag.MoveToStore(tobag, toplace, bag.FindFirstEmptySlot(0), bag, 999);
                        }
                        else
                        {
                            tempItem2.Count++;
                            bag.UpdateItem(tempItem2);
                            tobag.RemoveItemAt(toplace);
                        }

                        tobag.AddItemTo(tempItem, toplace);
                    }
                    //tobag.CommitChanges();
                }
                else
                {
                    if (tobagType != eBageType.Store && tobagType != eBageType.MainBag && bag.GetItemAt(place) != null && bag.GetItemAt(place).Template.CategoryID == 7 && (toplace > 0 && toplace < 31 && toplace != 6))
                    {
                        return(1);
                    }
                    try
                    {
                        bag.MoveToStore(bag, place, toplace, tobag, 50);
                    }
                    catch (Exception e)
                    {
                        LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", place, toplace, bagType, tobagType);
                        LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(place), tobag.GetItemAt(toplace));
                    }
                }

                return(1);
            }

            //danh cho tu ngan hang chuyen do ve main
            if (tobagType == eBageType.MainBag && bagType == eBageType.Bank)
            {
                bag.MoveToStore(bag, place, toplace, tobag, 50);
                return(1);
            }
            return(0);
        }
Ejemplo n.º 22
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType       bageType  = (eBageType)packet.ReadByte();
            int             slot      = packet.ReadInt();
            eBageType       type2     = (eBageType)packet.ReadByte();
            int             toSlot    = packet.ReadInt();
            int             count     = packet.ReadInt();
            PlayerInventory bag       = client.Player.GetInventory(bageType);
            PlayerInventory inventory = client.Player.GetInventory(type2);

            if (toSlot < 0)
            {
                if ((inventory.BagType == 11) || (inventory.BagType == 1))
                {
                    toSlot = inventory.FindFirstEmptySlot(0);
                }
                else
                {
                    toSlot = inventory.FindFirstEmptySlot(0x1f);
                }
            }
            if (count > 0)
            {
                if ((bag == null) || (bag.GetItemAt(slot) == null))
                {
                    return(0);
                }
                if ((bageType == type2) && (slot != -1))
                {
                    if (bag.GetItemAt(slot).Count >= count)
                    {
                        bag.MoveItem(slot, toSlot, count);
                    }
                    else
                    {
                        Console.WriteLine("--" + client.Player.Account + " Hack = CE");
                        bag.MoveItem(slot, toSlot, bag.GetItemAt(slot).Count);
                    }
                    return(1);
                }
                if ((slot == -1) && (toSlot != -1))
                {
                    bag.RemoveItemAt(toSlot);
                    return(1);
                }
                if (((((slot != -1) && (toSlot == -1)) && ((bageType != eBageType.CaddyBag) && (type2 != eBageType.Bank))) && (bageType != eBageType.Store)) && (type2 != eBageType.Store))
                {
                    if (bageType == eBageType.MainBag)
                    {
                        bag.AddItem(client.Player.GetItemAt(bageType, slot), 0x1f);
                    }
                    else
                    {
                        bag.AddItem(client.Player.GetItemAt(bageType, slot), 0);
                    }
                    return(1);
                }
                if ((((slot != -1) && (type2 != bageType)) && (type2 != eBageType.Store)) && (type2 != eBageType.MainBag))
                {
                    ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    if (info != null)
                    {
                        if (type2 == eBageType.Store)
                        {
                        }
                        bag.MoveToStore(bag, slot, toSlot, inventory, info.StoreLevel * 10);
                        return(1);
                    }
                }
                if ((type2 == eBageType.Store) || (bageType == eBageType.Store))
                {
                    SqlDataProvider.Data.ItemInfo itemAt = client.Player.GetItemAt(bageType, slot);
                    if ((itemAt != null) && (itemAt.Count > 1))
                    {
                        itemAt.Count--;
                        bag.UpdateItem(itemAt);
                        SqlDataProvider.Data.ItemInfo item = itemAt.Clone();
                        item.Count = 1;
                        if (inventory.GetItemAt(toSlot) == null)
                        {
                            inventory.AddItemTo(item, toSlot);
                        }
                        else
                        {
                            SqlDataProvider.Data.ItemInfo itemByTemplateID = bag.GetItemByTemplateID(0, inventory.GetItemAt(toSlot).TemplateID);
                            if (itemByTemplateID == null)
                            {
                                bag.MoveToStore(inventory, toSlot, bag.FindFirstEmptySlot(0), bag, 0x3e7);
                            }
                            else
                            {
                                itemByTemplateID.Count++;
                                bag.UpdateItem(itemByTemplateID);
                                inventory.RemoveItemAt(toSlot);
                            }
                            inventory.AddItemTo(item, toSlot);
                        }
                    }
                    else
                    {
                        if ((((type2 != eBageType.Store) && (type2 != eBageType.MainBag)) && ((bag.GetItemAt(slot) != null) && (bag.GetItemAt(slot).Template.CategoryID == 7))) && (((toSlot > 0) && (toSlot < 0x1f)) && (toSlot != 6)))
                        {
                            return(1);
                        }
                        try
                        {
                            bag.MoveToStore(bag, slot, toSlot, inventory, 50);
                        }
                        catch (Exception)
                        {
                            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("ERROR USER CHANGEITEM placce: {0},toplace: {1},bagType: {2},ToBagType {3}", new object[] { slot, toSlot, bageType, type2 });
                            LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType).InfoFormat("item :{0}, toitem {1}", bag.GetItemAt(slot), inventory.GetItemAt(toSlot));
                        }
                    }
                    return(1);
                }
                if ((type2 == eBageType.MainBag) && (bageType == eBageType.Bank))
                {
                    bag.MoveToStore(bag, slot, toSlot, inventory, 50);
                    return(1);
                }
            }
            return(0);
        }
Ejemplo n.º 23
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);
        }
Ejemplo n.º 24
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (countConnect >= 3000)
            {
                client.Disconnect(); return(0);
            }


            int           gold      = 0;                   //表示金币
            int           money     = 0;                   //表示点券
            int           offer     = 0;                   //表示功勋
            int           gifttoken = 0;                   //表示礼劵
            int           medal     = 0;
            StringBuilder payGoods  = new StringBuilder(); //表示支付物品ID
            eMessageType  eMsg      = eMessageType.Normal;
            string        msg       = "UserBuyItemHandler.Success";

            List <ItemInfo> buyitems = new List <ItemInfo>();                  //购买物品列表
            //List<int> needitemsinfo = new List<int>();                       //购买所需物品列表
            List <bool>   dresses = new List <bool>();
            List <int>    places  = new List <int>();
            StringBuilder types   = new StringBuilder();

            bool          isBind   = false;
            ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);


            int count = packet.ReadInt();

            for (int i = 0; i < count; i++)
            {
                int    buyFrom = packet.ReadInt();
                int    GoodsID = packet.ReadInt();
                int    type    = packet.ReadInt();
                string color   = packet.ReadString();
                bool   dress   = packet.ReadBoolean();
                string skin    = packet.ReadString();
                int    place   = packet.ReadInt();

                //这里开始处理公会商店
                ShopItemInfo shopItem = Bussiness.Managers.ShopMgr.GetShopItemInfoById(GoodsID);                   //获取商品信息
                //if (shopItem.ShopID == 2 || !Bussiness.Managers.ShopMgr.CanBuy(shopItem.ShopID, consotia == null ? 1 : consotia.ShopLevel, ref isBind, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
                if (!Bussiness.Managers.ShopMgr.CanBuy(shopItem.ShopID, consotia == null ? 1 : consotia.ShopLevel, ref isBind, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission"));
                    return(1);
                }

                //if (shopItem == null)
                //{
                //    continue;
                //}

                ItemTemplateInfo goods = Bussiness.Managers.ItemMgr.FindItemTemplate(shopItem.TemplateID);              //获取物品属性

                ItemInfo item = ItemInfo.CreateFromTemplate(goods, 1, (int)ItemAddType.Buy);                            //创建物品模板

                ////////////////////////////////////////////////////////////////////////////////////////////////////
                //判断有限期
                if (0 == shopItem.BuyType)                              //时间购买类型
                {
                    if (1 == type)
                    {
                        item.ValidDate = shopItem.AUnit;
                    }
                    if (2 == type)
                    {
                        item.ValidDate = shopItem.BUnit;
                    }
                    if (3 == type)
                    {
                        item.ValidDate = shopItem.CUnit;
                    }
                }
                else                                                  //数量购买类型
                {
                    if (1 == type)
                    {
                        item.Count = shopItem.AUnit;
                    }
                    if (2 == type)
                    {
                        item.Count = shopItem.BUnit;
                    }
                    if (3 == type)
                    {
                        item.Count = shopItem.CUnit;
                    }
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////////////

                if (item == null && shopItem == null)
                {
                    continue;
                }
                item.Color = color == null ? "" : color;
                item.Skin  = skin == null ? "" : skin;
                if (isBind == true)
                {
                    item.IsBinds = true;
                }
                else
                {
                    item.IsBinds = Convert.ToBoolean(shopItem.IsBind);
                }

                types.Append(type);
                types.Append(",");
                buyitems.Add(item);
                dresses.Add(dress);
                places.Add(place);

                ItemInfo.SetItemType(shopItem, type, ref gold, ref money, ref offer, ref gifttoken, ref medal);
            }

            if (buyitems.Count == 0)
            {
                return(1);
            }
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return(1);
            }



            //判断金币或礼券等是否足够
            if (gold <= client.Player.PlayerCharacter.Gold &&
                money <= client.Player.PlayerCharacter.Money &&
                offer <= client.Player.PlayerCharacter.Offer &&
                gifttoken <= client.Player.PlayerCharacter.GiftToken)// &&
            //medal <= client.Player.PlayerCharacter.medal)
            {
                client.Player.RemoveMoney(money);
                client.Player.RemoveGold(gold);
                client.Player.RemoveOffer(offer);
                client.Player.RemoveGiftToken(gifttoken);
                //client.Player.RemoveMedal(medal);

                string        itemIDs     = "";
                int           annexIndex  = 0;
                MailInfo      message     = new MailInfo();
                StringBuilder annexRemark = new StringBuilder();
                annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));

                for (int i = 0; i < buyitems.Count; i++)
                {
                    itemIDs += (itemIDs == "" ? buyitems[i].TemplateID.ToString() : "," + buyitems[i].TemplateID.ToString());
                    if (client.Player.AddTemplate(buyitems[i], buyitems[i].Template.BagType, buyitems[i].Count))
                    {
                        if (dresses[i] && buyitems[i].CanEquip())
                        {
                            int slot = client.Player.MainBag.FindItemEpuipSlot(buyitems[i].Template);
                            if ((slot == 9 || slot == 10) && (places[i] == 9 || places[i] == 10))
                            {
                                slot = places[i];
                            }
                            else if ((slot == 7 || slot == 8) && (places[i] == 7 || places[i] == 8))
                            {
                                slot = places[i];
                            }

                            client.Player.MainBag.MoveItem(buyitems[i].Place, slot, 0);
                            msg = "UserBuyItemHandler.Save";
                        }
                    }
                    else
                    {
                        using (PlayerBussiness db = new PlayerBussiness())
                        {
                            buyitems[i].UserID = 0;
                            db.AddGoods(buyitems[i]);

                            annexIndex++;
                            annexRemark.Append(annexIndex);
                            annexRemark.Append("、");
                            annexRemark.Append(buyitems[i].Template.Name);
                            annexRemark.Append("x");
                            annexRemark.Append(buyitems[i].Count);
                            annexRemark.Append(";");
                            switch (annexIndex)
                            {
                            case 1:
                                message.Annex1     = buyitems[i].ItemID.ToString();
                                message.Annex1Name = buyitems[i].Template.Name;
                                break;

                            case 2:
                                message.Annex2     = buyitems[i].ItemID.ToString();
                                message.Annex2Name = buyitems[i].Template.Name;
                                break;

                            case 3:
                                message.Annex3     = buyitems[i].ItemID.ToString();
                                message.Annex3Name = buyitems[i].Template.Name;
                                break;

                            case 4:
                                message.Annex4     = buyitems[i].ItemID.ToString();
                                message.Annex4Name = buyitems[i].Template.Name;
                                break;

                            case 5:
                                message.Annex5     = buyitems[i].ItemID.ToString();
                                message.Annex5Name = buyitems[i].Template.Name;
                                break;
                            }

                            if (annexIndex == 5)
                            {
                                annexIndex          = 0;
                                message.AnnexRemark = annexRemark.ToString();
                                annexRemark.Remove(0, annexRemark.Length);
                                annexRemark.Append(LanguageMgr.GetTranslation("GoodsPresentHandler.AnnexRemark"));

                                message.Content    = LanguageMgr.GetTranslation("UserBuyItemHandler.Title") + message.Annex1Name + "]";
                                message.Gold       = 0;
                                message.Money      = 0;
                                message.Receiver   = client.Player.PlayerCharacter.NickName;
                                message.ReceiverID = client.Player.PlayerCharacter.ID;
                                message.Sender     = message.Receiver;
                                message.SenderID   = message.ReceiverID;
                                message.Title      = message.Content;
                                message.Type       = (int)eMailType.BuyItem;
                                db.SendMail(message);

                                eMsg = eMessageType.ERROR;
                                msg  = "UserBuyItemHandler.Mail";

                                message.Revert();
                            }
                        }
                    }
                }

                if (annexIndex > 0)
                {
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        message.AnnexRemark = annexRemark.ToString();
                        message.Content     = LanguageMgr.GetTranslation("UserBuyItemHandler.Title") + message.Annex1Name + "]";
                        message.Gold        = 0;
                        message.Money       = 0;
                        message.Receiver    = client.Player.PlayerCharacter.NickName;
                        message.ReceiverID  = client.Player.PlayerCharacter.ID;
                        message.Sender      = message.Receiver;
                        message.SenderID    = message.ReceiverID;
                        message.Title       = message.Content;
                        message.Type        = (int)eMailType.BuyItem;
                        db.SendMail(message);

                        eMsg = eMessageType.ERROR;
                        msg  = "UserBuyItemHandler.Mail";
                    }
                }

                if (eMsg == eMessageType.ERROR)
                {
                    client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Receiver);
                }

                client.Player.OnPaid(money, gold, offer, gifttoken, medal, payGoods.ToString());//触发任务事件


                LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, gifttoken, offer, medal, "牌子编号", itemIDs, types.ToString());
            }
            else
            {
                if (gold > client.Player.PlayerCharacter.Gold)
                {
                    msg = "UserBuyItemHandler.NoGold";
                }
                if (offer > client.Player.PlayerCharacter.Offer)
                {
                    msg = "UserBuyItemHandler.NoOffer";
                }
                if (gifttoken > client.Player.PlayerCharacter.GiftToken)
                {
                    msg = "UserBuyItemHandler.GiftToken";
                }
                if (medal > client.Player.PlayerCharacter.medal)
                {
                    msg = "UserBuyItemHandler.Medal";
                }
                eMsg = eMessageType.ERROR;
            }

            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            return(0);
        }
Ejemplo n.º 25
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int                     totalGold          = 0;
            int                     totalMoney         = 0;
            int                     totalOffer         = 0;
            int                     totalGifttoken     = 0;
            int                     buyItemCount       = 0;
            eMessageType            eMsg               = eMessageType.Normal;
            string                  msg                = "UserBuyItemHandler.Success";
            GSPacketIn              pkg                = new GSPacketIn(44);
            List <ItemInfo>         buyItems           = new List <ItemInfo>();
            List <ItemInfo>         canNotBuyItems     = new List <ItemInfo>();
            List <int>              needitemsinfo      = new List <int>();
            Dictionary <int, int>   changeLimitShopsID = new Dictionary <int, int>();
            List <bool>             dresses            = new List <bool>();
            List <int>              places             = new List <int>();
            List <ItemJoinShopInfo> log                = new List <ItemJoinShopInfo>();
            Dictionary <int, int>   playerPayGoods     = new Dictionary <int, int>();
            int                     result2;

            if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                result2 = 1;
            }
            else
            {
                ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                int           count    = packet.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    int          goodsId   = packet.ReadInt();
                    int          type      = packet.ReadInt();
                    string       color     = packet.ReadString();
                    bool         isDress   = packet.ReadBoolean();
                    string       skin      = packet.ReadString();
                    int          place     = packet.ReadInt();
                    bool         isBind    = false;
                    int          gold      = 0;
                    int          money     = 0;
                    int          offer     = 0;
                    int          gifttoken = 0;
                    ShopItemInfo shopItem  = ShopMgr.GetShopItemInfoById(goodsId);
                    if (shopItem != null && shopItem.ShopID != 21 && shopItem.ShopID != 22)
                    {
                        if (shopItem.ShopID == 2 || !ShopMgr.CanBuy(shopItem.ShopID, (consotia == null) ? 1 : consotia.ShopLevel, ref isBind, player.PlayerCharacter.ConsortiaID, player.PlayerCharacter.Riches))
                        {
                            player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailbyPermission", new object[0]));
                            result2 = 1;
                            return(result2);
                        }
                        List <int> needsItems = ShopMgr.GetShopItemBuyConditions(shopItem, type, ref gold, ref money, ref offer, ref gifttoken);
                        for (int j = 0; j < needsItems.Count; j += 2)
                        {
                            if (!playerPayGoods.ContainsKey(needsItems[j]))
                            {
                                playerPayGoods.Add(needsItems[j], player.GetItemCount(needsItems[j]));
                            }
                        }
                        bool   result        = true;
                        string needsItemsLog = "";
                        for (int j = 0; j < needsItems.Count; j += 2)
                        {
                            if (playerPayGoods.ContainsKey(needsItems[j]) && playerPayGoods[needsItems[j]] >= needsItems[j + 1])
                            {
                                foreach (int a in needsItems)
                                {
                                    needitemsinfo.Add(a);
                                }
                                string text = needsItemsLog;
                                needsItemsLog = string.Concat(new string[]
                                {
                                    text,
                                    needsItems[j].ToString(),
                                    ":",
                                    needsItems[j + 1].ToString(),
                                    "|"
                                });
                                Dictionary <int, int> dictionary;
                                int key;
                                (dictionary = playerPayGoods)[key = needsItems[j]] = dictionary[key] - needsItems[j + 1];
                            }
                            else
                            {
                                result = false;
                            }
                        }
                        ItemInfo item       = ShopMgr.CreateItem(shopItem, 102, type, color, skin, isBind);
                        int      limitCount = ShopMgr.GetLimitCountByID(goodsId);
                        if (limitCount == -1 || limitCount > 0)
                        {
                            if (result && player.PlayerCharacter.Gold >= gold + totalGold && player.PlayerCharacter.Money >= money + totalMoney && player.PlayerCharacter.Offer >= offer + totalOffer && player.PlayerCharacter.GiftToken >= gifttoken + totalGifttoken)
                            {
                                totalGold      += gold;
                                totalMoney     += money;
                                totalOffer     += offer;
                                totalGifttoken += gifttoken;
                                buyItemCount++;
                                buyItems.Add(item);
                                dresses.Add(isDress);
                                places.Add(place);
                                if (limitCount != -1)
                                {
                                    ShopMgr.SubtractShopLimit(goodsId);
                                    this.Notice(player, goodsId, item.Template.Name);
                                    if (!changeLimitShopsID.ContainsKey(goodsId))
                                    {
                                        changeLimitShopsID.Add(goodsId, ShopMgr.GetLimitCountByID(goodsId));
                                    }
                                    else
                                    {
                                        changeLimitShopsID[goodsId] = ShopMgr.GetLimitCountByID(goodsId);
                                    }
                                }
                                log.Add(new ItemJoinShopInfo(item.TemplateID, item.Count, money, gold, gifttoken, offer, needsItemsLog));
                            }
                            else
                            {
                                canNotBuyItems.Add(item);
                            }
                        }
                    }
                }
                if (buyItems.Count == 0)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserBuyItemHandler.Failed", new object[0]));
                    result2 = 1;
                }
                else
                {
                    int buyFrom = packet.ReadInt();
                    player.RemoveMoney(totalMoney, LogMoneyType.Shop, LogMoneyType.Shop_Buy);
                    player.RemoveGold(totalGold);
                    player.RemoveOffer(totalOffer);
                    player.RemoveGiftToken(totalGifttoken);
                    StringBuilder allPayItemsStr = new StringBuilder();
                    for (int j = 0; j < needitemsinfo.Count; j += 2)
                    {
                        player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1], eItemRemoveType.Shopping);
                        allPayItemsStr.Append(needitemsinfo[j]).Append(",");
                    }
                    foreach (ItemJoinShopInfo templog in log)
                    {
                        //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Buy, player.PlayerCharacter.ID, templog.Moneys, templog.Gold, templog.GiftToken, templog.Offer, templog.OtherPay, templog.TemplateID, 4, templog.Data);
                    }
                    List <ItemInfo> lastItems = new List <ItemInfo>();
                    player.StackItem(ref buyItems);
                    for (int i = 0; i < buyItems.Count; i++)
                    {
                        switch (buyFrom)
                        {
                        case 0:
                        case 3:
                            if (player.AddItem(buyItems[i]))
                            {
                                if (dresses[i])
                                {
                                    player.EquipItem(buyItems[i], places[i]);
                                    msg = "UserBuyItemHandler.Save";
                                }
                            }
                            else
                            {
                                lastItems.Add(buyItems[i]);
                            }
                            break;

                        case 1:
                            if (!UserBuyItemHandler.AddStrengthItemsToHideBag(player, buyItems[i]))
                            {
                                lastItems.Add(buyItems[i]);
                            }
                            break;

                        case 2:
                            if (!UserBuyItemHandler.AddComposeItemsToHideBag(player, buyItems[i]))
                            {
                                lastItems.Add(buyItems[i]);
                            }
                            break;

                        case 4:
                            if (!UserBuyItemHandler.AddFusionItemsToHideBag(player, buyItems[i]))
                            {
                                lastItems.Add(buyItems[i]);
                            }
                            break;
                        }
                    }
                    bool sentMail = false;
                    if (lastItems.Count > 0)
                    {
                        string title = "";
                        sentMail = player.SendItemsToMail(lastItems, "", title, eMailType.BuyItem);
                        msg      = "UserBuyItemHandler.Mail";
                    }
                    if (canNotBuyItems.Count > 0)
                    {
                        string        title   = LanguageMgr.GetTranslation("UserBuyItemHandler.ListTitle", new object[0]);
                        StringBuilder content = new StringBuilder();
                        if (buyItems.Count > 0)
                        {
                            content.Append(LanguageMgr.GetTranslation("UserBuyItemHandler.BuyList", new object[]
                            {
                                buyItems.Count
                            }));
                            for (int i = 0; i < buyItems.Count; i++)
                            {
                                content.Append(string.Format("{0}{1}", (i == 0) ? "" : ";", buyItems[i].Template.Name));
                            }
                        }
                        if (canNotBuyItems.Count > 0)
                        {
                            content.Append(LanguageMgr.GetTranslation("UserBuyItemHandler.NoBuyList", new object[]
                            {
                                "\n"
                            }));
                            for (int j = 0; j < canNotBuyItems.Count; j++)
                            {
                                content.Append(string.Format("{0}{1}", (j == 0) ? "" : ";", canNotBuyItems[j].Template.Name));
                            }
                        }
                        sentMail = player.SendMail(content.ToString(), title, null, eMailType.BuyItem);
                    }
                    if (sentMail)
                    {
                        player.Out.SendMailResponse(player.PlayerCharacter.ID, eMailRespose.Receiver);
                    }
                    player.OnPaid(totalMoney, totalGold, totalOffer, totalGifttoken, allPayItemsStr.ToString());
                    int buyResult = 0;
                    if (buyItemCount == count)
                    {
                        buyResult = (sentMail ? 2 : 1);
                    }
                    pkg.WriteInt(buyResult);
                    pkg.WriteInt(buyFrom);
                    player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0]));
                    player.Out.SendTCP(pkg);
                    player.SaveIntoDatabase();

                    this.UpdateLimitShopCount(player, changeLimitShopsID);

                    result2 = 0;
                }
            }
            return(result2);
        }
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            eBageType bagType   = (eBageType)packet.ReadByte();
            int       place     = packet.ReadInt();
            eBageType tobagType = (eBageType)packet.ReadByte();
            int       result;

            if (tobagType == eBageType.TempBag)
            {
                GameServer.log.Error("User want to put item into temp bag!");
                result = 0;
            }
            else
            {
                int             toplace = packet.ReadInt();
                int             count   = packet.ReadInt();
                PlayerInventory bag     = player.GetInventory(bagType);
                PlayerInventory tobag   = player.GetInventory(tobagType);
                if (tobagType == eBageType.TempBag)
                {
                    result = 0;
                }
                else
                {
                    bag.BeginChanges();
                    tobag.BeginChanges();
                    try
                    {
                        if (place != -1)
                        {
                            ItemInfo item = bag.GetItemAt(place);
                            if (tobagType == eBageType.Bank)
                            {
                                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(player.PlayerCharacter.ConsortiaID);
                                if (info != null)
                                {
                                    tobag.Capalility = info.StoreLevel * 10;
                                }
                            }
                            if (toplace == -1)
                            {
                                if (tobag.StackItemToAnother(item) || tobag.AddItem(item))
                                {
                                    bag.TakeOutItem(item);
                                }
                                else
                                {
                                    player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]));
                                }
                            }
                            else
                            {
                                if (bagType == tobagType)
                                {
                                    bag.MoveItem(place, toplace, count);
                                }
                                else
                                {
                                    if (bagType == eBageType.HideBag)
                                    {
                                        this.MoveFromHide(player, bag, item, toplace, tobag, count);
                                    }
                                    else
                                    {
                                        if (tobagType == eBageType.HideBag)
                                        {
                                            this.MoveToHide(player, bag, item, toplace, tobag, count);
                                        }
                                        else
                                        {
                                            if (bagType == eBageType.Bank)
                                            {
                                                UserChangeItemPlaceHandler.MoveFromBank(player, place, toplace, bag, tobag, item);
                                            }
                                            else
                                            {
                                                if (tobagType == eBageType.Bank)
                                                {
                                                    UserChangeItemPlaceHandler.MoveToBank(place, toplace, bag, tobag, item);
                                                }
                                                else
                                                {
                                                    if (tobag.AddItemTo(item, toplace))
                                                    {
                                                        bag.TakeOutItem(item);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (toplace != -1)
                            {
                                bag.RemoveItemAt(toplace, eItemRemoveType.Delete);
                            }
                        }
                    }
                    finally
                    {
                        bag.CommitChanges();
                        tobag.CommitChanges();
                    }
                    result = 0;
                }
            }
            return(result);
        }
Ejemplo n.º 27
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn    gSPacketIn         = new GSPacketIn(58, client.Player.PlayerCharacter.ID);
            StringBuilder stringBuilder      = new StringBuilder();
            int           pRICE_COMPOSE_GOLD = GameProperties.PRICE_COMPOSE_GOLD;

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(0);
            }
            if (client.Player.PlayerCharacter.Gold < pRICE_COMPOSE_GOLD)
            {
                client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemComposeHandler.NoMoney", new object[0]));
                return(0);
            }
            int      num           = -1;
            int      num2          = -1;
            bool     flag          = false;
            bool     flag2         = packet.ReadBoolean();
            ItemInfo itemAt        = client.Player.StoreBag.GetItemAt(1);
            ItemInfo itemAt2       = client.Player.StoreBag.GetItemAt(2);
            ItemInfo itemInfo      = null;
            ItemInfo itemInfo2     = null;
            string   beginProperty = null;
            string   text          = null;

            using (ItemRecordBussiness itemRecordBussiness = new ItemRecordBussiness())
            {
                itemRecordBussiness.PropertyString(itemAt, ref beginProperty);
            }
            if (itemAt != null && itemAt2 != null && itemAt.Template.CanCompose && (itemAt.Template.CategoryID < 10 || (itemAt2.Template.CategoryID == 11 && itemAt2.Template.Property1 == 1)))
            {
                flag = (flag || itemAt.IsBinds);
                flag = (flag || itemAt2.IsBinds);
                stringBuilder.Append(string.Concat(new object[]
                {
                    itemAt.ItemID,
                    ":",
                    itemAt.TemplateID,
                    ",",
                    itemAt2.ItemID,
                    ":",
                    itemAt2.TemplateID,
                    ","
                }));
                bool   flag3 = false;
                byte   b     = 1;
                double num3  = ItemComposeHandler.composeRate[itemAt2.Template.Quality - 1] * 100.0;
                if (client.Player.StoreBag.GetItemAt(0) != null)
                {
                    itemInfo = client.Player.StoreBag.GetItemAt(0);
                    if (itemInfo != null && itemInfo.Template.CategoryID == 11 && itemInfo.Template.Property1 == 3)
                    {
                        flag = (flag || itemInfo.IsBinds);
                        object obj = text;
                        text = string.Concat(new object[]
                        {
                            obj,
                            "|",
                            itemInfo.ItemID,
                            ":",
                            itemInfo.Template.Name,
                            "|",
                            itemAt2.ItemID,
                            ":",
                            itemAt2.Template.Name
                        });
                        stringBuilder.Append(string.Concat(new object[]
                        {
                            itemInfo.ItemID,
                            ":",
                            itemInfo.TemplateID,
                            ","
                        }));
                        num3 += num3 * (double)itemInfo.Template.Property2 / 100.0;
                    }
                }
                else
                {
                    num3 += num3 * 1.0 / 100.0;
                }
                if (num2 != -1)
                {
                    itemInfo2 = client.Player.PropBag.GetItemAt(num2);
                    if (itemInfo2 != null && itemInfo2.Template.CategoryID == 11 && itemInfo2.Template.Property1 == 7)
                    {
                        flag = (flag || itemInfo2.IsBinds);
                        stringBuilder.Append(string.Concat(new object[]
                        {
                            itemInfo2.ItemID,
                            ":",
                            itemInfo2.TemplateID,
                            ","
                        }));
                        object obj2 = text;
                        text = string.Concat(new object[]
                        {
                            obj2,
                            ",",
                            itemInfo2.ItemID,
                            ":",
                            itemInfo2.Template.Name
                        });
                    }
                    else
                    {
                        itemInfo2 = null;
                    }
                }
                if (flag2)
                {
                    ConsortiaInfo             consortiaInfo        = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
                    ConsortiaBussiness        consortiaBussiness   = new ConsortiaBussiness();
                    ConsortiaEquipControlInfo consortiaEuqipRiches = consortiaBussiness.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);
                    if (consortiaInfo == null)
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail", new object[0]));
                    }
                    else
                    {
                        if (client.Player.PlayerCharacter.Riches < consortiaEuqipRiches.Riches)
                        {
                            client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission", new object[0]));
                            return(1);
                        }
                        num3 *= 1.0 + 0.1 * (double)consortiaInfo.SmithLevel;
                    }
                }
                num3 = Math.Floor(num3 * 10.0) / 10.0;
                int num4 = ItemComposeHandler.random.Next(100);
                switch (itemAt2.Template.Property3)
                {
                case 1:
                    if (itemAt2.Template.Property4 > itemAt.AttackCompose)
                    {
                        flag3 = true;
                        if (num3 > (double)num4)
                        {
                            b = 0;
                            itemAt.AttackCompose = itemAt2.Template.Property4;
                        }
                    }
                    break;

                case 2:
                    if (itemAt2.Template.Property4 > itemAt.DefendCompose)
                    {
                        flag3 = true;
                        if (num3 > (double)num4)
                        {
                            b = 0;
                            itemAt.DefendCompose = itemAt2.Template.Property4;
                        }
                    }
                    break;

                case 3:
                    if (itemAt2.Template.Property4 > itemAt.AgilityCompose)
                    {
                        flag3 = true;
                        if (num3 > (double)num4)
                        {
                            b = 0;
                            itemAt.AgilityCompose = itemAt2.Template.Property4;
                        }
                    }
                    break;

                case 4:
                    if (itemAt2.Template.Property4 > itemAt.LuckCompose)
                    {
                        flag3 = true;
                        if (num3 > (double)num4)
                        {
                            b = 0;
                            itemAt.LuckCompose = itemAt2.Template.Property4;
                        }
                    }
                    break;
                }
                if (flag3)
                {
                    itemAt.IsBinds = flag;
                    if (b != 0)
                    {
                        stringBuilder.Append("false!");
                        flag3 = false;
                    }
                    else
                    {
                        stringBuilder.Append("true!");
                        flag3 = true;
                        client.Player.OnItemCompose(itemAt2.TemplateID);
                    }
                    LogMgr.LogItemAdd(client.Player.PlayerCharacter.ID, LogItemType.Compose, beginProperty, itemAt, text, Convert.ToInt32(flag3));
                    client.Player.StoreBag.RemoveTemplate(itemAt2.TemplateID, 1);
                    if (itemInfo != null)
                    {
                        client.Player.StoreBag.RemoveTemplate(itemInfo.TemplateID, 1);
                    }
                    if (itemInfo2 != null)
                    {
                        client.Player.RemoveItem(itemInfo2);
                    }
                    client.Player.RemoveGold(pRICE_COMPOSE_GOLD);
                    client.Player.StoreBag.UpdateItem(itemAt);
                    gSPacketIn.WriteByte(b);
                    client.Out.SendTCP(gSPacketIn);
                    if (num < 31)
                    {
                        client.Player.MainBag.UpdatePlayerProperties();
                    }
                }
                else
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.NoLevel", new object[0]));
                }
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemComposeHandler.Fail", new object[0]));
            }
            return(0);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 移动物品
        /// </summary>
        /// <param name="fromSlot"></param>
        /// <param name="toSlot"></param>
        /// <returns></returns>
        public override bool MoveItem(int fromSlot, int toSlot, int count)
        {
            ItemInfo from = GetItemAt(fromSlot);
            ItemInfo to   = GetItemAt(toSlot);

            if (from == null || fromSlot == toSlot)
            {
                return(false);
            }

            if (_bagType == 11)
            {
                ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(_player.PlayerCharacter.ConsortiaID);
                if (info == null || toSlot >= info.StoreLevel * 10 || fromSlot >= info.StoreLevel * 10)
                {
                    return(false);
                }
            }

            if (to != null)
            {
                //合并物品
                if (from.IsCanWrap(to))
                {
                    int total = from.Count + to.Count;
                    if (total > to.Template.MaxCount)
                    {
                        to.Count   = to.Template.MaxCount;
                        from.Count = total - to.Count;
                        _player.Out.SendUpdateInventorySlot(to.Place, true, to, _bagType);
                        _player.Out.SendUpdateInventorySlot(from.Place, true, from, _bagType);
                    }
                    else
                    {
                        to.Count = total;
                        _player.Out.SendUpdateInventorySlot(to.Place, true, to, _bagType);
                        from.Count      = 0;
                        from.RemoveType = (int)ItemRemoveType.Fold;
                        from.IsExist    = false;
                        _player.Out.SendUpdateInventorySlot(fromSlot, false, null, _bagType);
                        RemoveItem(from);
                    }
                    return(true);
                }
                //交换物品
                else
                {
                    if (base.MoveItem(fromSlot, toSlot))
                    {
                        _player.Out.SendUpdateInventorySlot(from.Place, true, from, _bagType);
                        _player.Out.SendUpdateInventorySlot(to.Place, true, to, _bagType);
                        return(true);
                    }
                }
            }
            else
            {
                if (base.MoveItem(fromSlot, toSlot))
                {
                    _player.Out.SendUpdateInventorySlot(from.Place, true, from, _bagType);
                    _player.Out.SendUpdateInventorySlot(fromSlot, false, null, _bagType);
                    return(true);
                }
            }

            return(false);
        }