コード例 #1
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn gSPacketIn = new GSPacketIn(61, client.Player.PlayerCharacter.ID);

            new StringBuilder();
            int      num            = 40000;
            bool     tranHole       = packet.ReadBoolean();
            bool     tranHoleFivSix = packet.ReadBoolean();
            ItemInfo itemInfo       = client.Player.StoreBag.GetItemAt(0);
            ItemInfo itemInfo2      = client.Player.StoreBag.GetItemAt(1);

            if (itemInfo != null && itemInfo2 != null && itemInfo.Template.CategoryID == itemInfo2.Template.CategoryID && itemInfo2.Count == 1 && itemInfo.Count == 1 && itemInfo.IsValidItem() && itemInfo2.IsValidItem())
            {
                if (client.Player.PlayerCharacter.Gold < num)
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nogold", new object[0]));
                    return(1);
                }
                client.Player.RemoveGold(num);
                if (itemInfo.Template.CategoryID == 7 || itemInfo2.Template.CategoryID == 7)
                {
                    ItemInfo itemInfo3   = null;
                    ItemInfo itemInfo4   = null;
                    int      templateID  = itemInfo.TemplateID;
                    int      templateID2 = itemInfo2.TemplateID;
                    this.GetWeaponID(ref templateID, ref templateID2);
                    ItemTemplateInfo itemTemplateInfo  = ItemMgr.FindItemTemplate(templateID);
                    ItemTemplateInfo itemTemplateInfo2 = ItemMgr.FindItemTemplate(templateID2);
                    if (itemTemplateInfo != null)
                    {
                        itemInfo3 = ItemInfo.CreateWeapon(itemTemplateInfo, itemInfo, 116);
                    }
                    itemInfo = itemInfo3;
                    if (itemTemplateInfo2 != null)
                    {
                        itemInfo4 = ItemInfo.CreateWeapon(itemTemplateInfo2, itemInfo2, 116);
                    }
                    itemInfo2 = itemInfo4;
                }
                StrengthenMgr.InheritTransferProperty(ref itemInfo, ref itemInfo2, tranHole, tranHoleFivSix);
                client.Player.StoreBag.ClearBag();
                client.Player.StoreBag.AddItemTo(itemInfo, 0);
                client.Player.StoreBag.AddItemTo(itemInfo2, 1);
                gSPacketIn.WriteByte(0);
                client.Out.SendTCP(gSPacketIn);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nocondition", new object[0]));
            }
            return(0);
        }
コード例 #2
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();

            pkg.ClearContext();

            StringBuilder str             = new StringBuilder();
            int           mustGold        = 40000;
            bool          _moveHole       = packet.ReadBoolean();
            bool          _moveFivSixHole = packet.ReadBoolean();

            ItemInfo transferBefore = client.Player.StoreBag2.GetItemAt(0);
            ItemInfo transferAfter  = client.Player.StoreBag2.GetItemAt(1);

            //未开始
            if (transferBefore != null && transferAfter != null &&
                transferBefore.Template.CategoryID == transferAfter.Template.CategoryID &&
                //transferBefore.Template.CategoryID < 10 &&
                transferAfter.Count == 1 && transferBefore.Count == 1 &&
                transferBefore.IsValidItem() && transferAfter.IsValidItem())
            {
                if (client.Player.PlayerCharacter.Gold < mustGold)
                {
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nogold"));
                    return(1);
                }
                client.Player.RemoveGold(mustGold);

                if (transferBefore.Template.CategoryID == 7 || transferAfter.Template.CategoryID == 7)
                {
                    ItemTemplateInfo newTemp0 = null;
                    ItemTemplateInfo newTemp1 = null;
                    ItemInfo         newItem0 = null;
                    ItemInfo         newItem1 = null;
                    int _temID0 = transferBefore.TemplateID;
                    int _temID1 = transferAfter.TemplateID;

                    GetWeaponID(ref _temID0, ref _temID1);

                    newTemp0 = Bussiness.Managers.ItemMgr.FindItemTemplate(_temID0);
                    newTemp1 = Bussiness.Managers.ItemMgr.FindItemTemplate(_temID1);
                    if (newTemp0 != null)
                    {
                        newItem0 = ItemInfo.CreateWeapon(newTemp0, transferBefore, (int)ItemAddType.Strengthen);
                    }
                    transferBefore = newItem0;
                    if (newTemp1 != null)
                    {
                        newItem1 = ItemInfo.CreateWeapon(newTemp1, transferAfter, (int)ItemAddType.Strengthen);
                    }
                    transferAfter = newItem1;
                }

                StrengthenMgr.InheritTransferProperty(ref transferBefore, ref transferAfter, _moveHole, _moveFivSixHole);

                client.Player.StoreBag2.ClearBag();
                client.Player.StoreBag2.AddItemTo(transferBefore, 0);
                client.Player.StoreBag2.AddItemTo(transferAfter, 1);
                client.Player.SaveIntoDatabase();
                pkg.WriteByte(0);
                client.Out.SendTCP(pkg);
            }
            else
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("itemtransferhandler.nocondition"));
            }

            return(0);
        }