public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int    bagType           = packet.ReadInt();
            int    num               = packet.ReadInt();
            string translateId       = null;
            List <ShopItemInfo> list = new List <ShopItemInfo>();

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                return(0);
            }
            ItemInfo itemInfo;

            if (num == -1)
            {
                int num2 = packet.ReadInt();
                int num3 = packet.ReadInt();
                int num4 = 0;
                int num5 = 0;
                ItemTemplateInfo goods = ItemMgr.FindItemTemplate(num2);
                itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102);
                list     = ShopMgr.FindShopbyTemplatID(num2);
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].APrice1 == -1 && list[i].AValue1 != 0)
                    {
                        num5 = list[i].AValue1;
                        itemInfo.ValidDate = list[i].AUnit;
                    }
                }
                if (itemInfo != null)
                {
                    if (num4 <= client.Player.PlayerCharacter.Gold && num5 <= client.Player.PlayerCharacter.Money)
                    {
                        client.Player.RemoveMoney(num5);
                        client.Player.RemoveGold(num4);
                        LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Card, client.Player.PlayerCharacter.ID, num5, client.Player.PlayerCharacter.Money, num4, 0, 0, 0, "牌子编号", itemInfo.TemplateID.ToString(), num3.ToString());
                        translateId = "CardUseHandler.Success";
                    }
                    else
                    {
                        itemInfo = null;
                    }
                }
            }
            else
            {
                itemInfo    = client.Player.PropBag.GetItemAt(num);
                translateId = "CardUseHandler.Success";
            }
            if (itemInfo != null)
            {
                string translateId2 = string.Empty;
                if (itemInfo.Template.Property1 != 21)
                {
                    AbstractBuffer abstractBuffer = BufferList.CreateBuffer(itemInfo.Template, itemInfo.ValidDate);
                    if (abstractBuffer != null)
                    {
                        abstractBuffer.Start(client.Player);
                        if (num != -1)
                        {
                            client.Player.PropBag.RemoveCountFromStack(itemInfo, 1);
                        }
                    }
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(translateId, new object[0]));
                }
                else
                {
                    if (itemInfo.IsValidItem())
                    {
                        client.Player.PlayerCharacter.GP += client.Player.AddGP(itemInfo.Template.Property2 * itemInfo.Count);//fix add nuoc kinh nghiem
                        if (itemInfo.Template.CanDelete)
                        {
                            client.Player.RemoveAt((eBageType)bagType, num);
                            translateId2 = "GPDanUser.Success";
                        }
                    }
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(translateId2, new object[]
                    {
                        itemInfo.Template.Property2 *itemInfo.Count
                    }));
                }
            }
            return(0);
        }
Example #2
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int  bagType       = packet.ReadInt();
            int  place         = packet.ReadInt();
            int  goodsID       = packet.ReadInt();
            int  type          = packet.ReadInt();
            bool ignoreBagLock = packet.ReadBoolean();
            int  result;

            if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked && !ignoreBagLock)
            {
                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                result = 0;
            }
            else
            {
                ItemInfo item;
                string   msg;
                if (place == -1)
                {
                    int          gold      = 0;
                    int          money     = 0;
                    int          offer     = 0;
                    int          gifttoken = 0;
                    ShopItemInfo info      = ShopMgr.GetShopItemInfoById(goodsID);
                    if (null == info)
                    {
                        result = 1;
                        return(result);
                    }
                    List <int> payGoods = ShopMgr.GetShopItemBuyConditions(info, type, ref gold, ref money, ref offer, ref gifttoken);
                    if (offer > 0 || payGoods.Count > 0)
                    {
                        result = 1;
                        return(result);
                    }
                    item = ShopMgr.CreateItem(info, 102, type, "", "", true);
                    if (item == null)
                    {
                        result = 1;
                        return(result);
                    }
                    player.RemoveMoney(money, LogMoneyType.Shop, LogMoneyType.Shop_Card);
                    player.RemoveGold(gold);
                    player.RemoveOffer(offer);
                    player.RemoveGiftToken(gifttoken);
                    //LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Card, player.PlayerCharacter.ID, money, gold, 0, 0, "", item.TemplateID, 1, item.Count);
                    msg = "CardUseHandler.Success";
                }
                else
                {
                    item = player.PropBag.GetItemAt(place);
                    msg  = "CardUseHandler.Success";
                }
                if (item != null)
                {
                    string msg2 = string.Empty;
                    if (item.Template.Property1 != 21)
                    {
                        AbstractBuffer buffer = BufferList.CreateBuffer(item.Template, item.ValidDate);
                        if (buffer != null)
                        {
                            buffer.Start(player);
                            if (place != -1)
                            {
                                player.OnUsingItem(item.TemplateID);
                                player.PropBag.RemoveItem(item, eItemRemoveType.Use);
                            }
                        }
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg, new object[0]));
                    }
                    else
                    {
                        if (item.IsValidItem())
                        {
                            player.AddGpDirect(item.Template.Property2);
                            player.OnUsingItem(item.TemplateID);
                            player.RemoveItem(item, eItemRemoveType.Use);
                            msg2 = "GPDanUser.Success";
                        }
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg2, new object[]
                        {
                            item.Template.Property2
                        }));
                    }
                }
                result = 0;
            }
            return(result);
        }
Example #3
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int    bagType = packet.ReadInt();
            int    place   = packet.ReadInt();
            string msg1    = null;

            ItemInfo            item     = null;
            List <ShopItemInfo> ShopItem = new List <ShopItemInfo>();

            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return(0);
            }
            if (place == -1)
            {
                int templateID = packet.ReadInt();
                int type       = packet.ReadInt();
                int gold       = 0;
                int money      = 0;



                ItemTemplateInfo template = Bussiness.Managers.ItemMgr.FindItemTemplate(templateID);
                item     = ItemInfo.CreateFromTemplate(template, 1, (int)ItemAddType.Buy);
                ShopItem = Bussiness.Managers.ShopMgr.FindShopbyTemplatID(templateID);
                for (int i = 0; i < ShopItem.Count; i++)
                {
                    if (ShopItem[i].APrice1 == -1 && ShopItem[i].AValue1 != 0)
                    {
                        money          = ShopItem[i].AValue1;
                        item.ValidDate = ShopItem[i].AUnit;
                    }
                }

                if (item != null)
                {
                    // item = ItemInfo.SetItemType(item, type, ref gold, ref money, ref offer);
                    if (gold <= client.Player.PlayerCharacter.Gold && money <= client.Player.PlayerCharacter.Money)
                    {
                        client.Player.RemoveMoney(money);
                        client.Player.RemoveGold(gold);
                        LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Card, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, 0, 0, "牌子编号", item.TemplateID.ToString(), type.ToString());
                        msg1 = "CardUseHandler.Success";
                    }
                    else
                    {
                        item = null;
                    }
                }
            }
            else
            {
                item = client.Player.PropBag.GetItemAt(place);
                msg1 = "CardUseHandler.Success";
            }

            if (item != null)
            {
                string msg = string.Empty;
                if (item.Template.Property1 != 21)
                {
                    AbstractBuffer buffer = BufferList.CreateBuffer(item.Template, item.ValidDate);
                    if (buffer != null)
                    {
                        buffer.Start(client.Player);
                        if (place != -1)
                        {
                            client.Player.PropBag.RemoveItem(item);
                        }
                    }
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg1));
                }
                else
                {
                    if (item.IsValidItem())
                    {
                        //client.Player.PlayerCharacter.GP += item.Template.Property1;
                        client.Player.AddGP(item.Template.Property2);

                        if (item.Template.CanDelete)
                        {
                            client.Player.RemoveItem(item);
                            msg = "GPDanUser.Success";
                        }
                    }
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(msg, item.Template.Property2));
                }
            }

            return(0);
        }