Пример #1
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            eMessageType eMsg         = eMessageType.Normal;
            string       msg          = "UserChangeItemColorHandler.Success";
            int          Card_bagType = packet.ReadInt();
            int          Card_place   = packet.ReadInt();
            int          bagType      = packet.ReadInt();
            int          place        = packet.ReadInt();
            string       color        = packet.ReadString();
            string       skin         = packet.ReadString();
            int          templateID   = packet.ReadInt();
            ItemInfo     item         = player.MainBag.GetItemAt(place);
            ItemInfo     card         = player.PropBag.GetItemAt(Card_place);

            if (item != null)
            {
                player.BeginChanges();
                try
                {
                    bool changed = false;
                    if (card != null && card.IsValidItem())
                    {
                        player.PropBag.RemoveItem(card, eItemRemoveType.Use);
                        changed = true;
                    }
                    else
                    {
                        ItemTemplateInfo    template = ItemMgr.FindItemTemplate(templateID);
                        List <ShopItemInfo> Template = ShopMgr.FindShopbyTemplatID(templateID);
                        int Money = 0;
                        for (int i = 0; i < Template.Count; i++)
                        {
                            if (Template[i].APrice1 == -1 && Template[i].AValue1 != 0)
                            {
                                Money = Template[i].AValue1;
                            }
                        }
                        if (Money <= player.PlayerCharacter.Money)
                        {
                            player.RemoveMoney(Money, LogMoneyType.Item, LogMoneyType.Item_Color);
                            changed = true;
                        }
                    }
                    if (changed)
                    {
                        item.Color = ((color == null) ? "" : color);
                        item.Skin  = ((skin == null) ? "" : skin);
                        player.MainBag.UpdateItem(item);
                    }
                }
                finally
                {
                    player.CommitChanges();
                }
            }
            player.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg, new object[0]));
            return(0);
        }
Пример #2
0
        public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet)
        {
            bool result;

            if (player.CurrentMarryRoom != null)
            {
                int          userID     = packet.ReadInt();
                int          templateID = packet.ReadInt();
                ShopItemInfo temp       = ShopMgr.FindShopbyTemplatID(templateID).FirstOrDefault <ShopItemInfo>();
                if (temp != null)
                {
                    if (temp.APrice1 == -2)
                    {
                        if (player.PlayerCharacter.Gold >= temp.AValue1)
                        {
                            player.RemoveGold(temp.AValue1);
                            player.CurrentMarryRoom.ReturnPacketForScene(player, packet);
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed1", new object[]
                            {
                                temp.AValue1
                            }));
                            player.OnUsingItem(temp.TemplateID);
                            result = true;
                            return(result);
                        }
                        player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserFirecrackersCommand.GoldNotEnough", new object[0]));
                    }
                    if (temp.APrice1 == -1)
                    {
                        if (player.PlayerCharacter.Money >= temp.AValue1)
                        {
                            player.RemoveMoney(temp.AValue1, LogMoneyType.Marry, LogMoneyType.Marry_Flower);
                            player.CurrentMarryRoom.ReturnPacketForScene(player, packet);
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed2", new object[]
                            {
                                temp.AValue1
                            }));
                            player.OnUsingItem(temp.TemplateID);
                            result = true;
                            return(result);
                        }
                        player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0]));
                    }
                }
            }
            result = false;
            return(result);
        }
Пример #3
0
        public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet)
        {
            if (player.CurrentMarryRoom != null /* && player.CurrentMarryRoom.RoomState == eRoomState.FREE*/)
            {
                int userID     = packet.ReadInt();
                int templateID = packet.ReadInt();

                //ItemTemplateInfo template = ItemMgr.FindItemTemplate(templateID);
                ShopItemInfo temp = ShopMgr.FindShopbyTemplatID(templateID).FirstOrDefault();
                if (temp != null)
                {
                    if (temp.APrice1 == -2)
                    {
                        if (player.PlayerCharacter.Gold >= temp.AValue1)
                        {
                            player.RemoveGold(temp.AValue1);
                            //0 player.CurrentMarryRoom.ReturnPacket(player, packet);
                            player.CurrentMarryRoom.ReturnPacketForScene(player, packet);
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed1", temp.AValue1));
                            return(true);
                        }
                        else
                        {
                            player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserFirecrackersCommand.GoldNotEnough"));
                        }
                    }
                    if (temp.APrice1 == -1)
                    {
                        if (player.PlayerCharacter.Money >= temp.AValue1)
                        {
                            player.RemoveMoney(temp.AValue1);
                            LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Flower, player.PlayerCharacter.ID, temp.AValue1, player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                            player.CurrentMarryRoom.ReturnPacketForScene(player, packet);
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed2", temp.AValue1));
                            return(true);
                        }
                        else
                        {
                            player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough"));
                        }
                    }
                }
            }
            return(false);
        }
 public bool HandleCommand(TankMarryLogicProcessor process, GamePlayer player, GSPacketIn packet)
 {
     if (player.CurrentMarryRoom != null)
     {
         packet.ReadInt();
         int          templatID    = packet.ReadInt();
         ShopItemInfo shopItemInfo = ShopMgr.FindShopbyTemplatID(templatID).FirstOrDefault <ShopItemInfo>();
         if (shopItemInfo != null)
         {
             if (shopItemInfo.APrice1 == -2)
             {
                 if (player.PlayerCharacter.Gold >= shopItemInfo.AValue1)
                 {
                     player.RemoveGold(shopItemInfo.AValue1);
                     player.CurrentMarryRoom.ReturnPacketForScene(player, packet);
                     player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed1", new object[]
                     {
                         shopItemInfo.AValue1
                     }));
                     return(true);
                 }
                 player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserFirecrackersCommand.GoldNotEnough", new object[0]));
             }
             if (shopItemInfo.APrice1 == -1)
             {
                 if (player.PlayerCharacter.Money >= shopItemInfo.AValue1)
                 {
                     player.RemoveMoney(shopItemInfo.AValue1);
                     LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Flower, player.PlayerCharacter.ID, shopItemInfo.AValue1, player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                     player.CurrentMarryRoom.ReturnPacketForScene(player, packet);
                     player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("UserFirecrackersCommand.Successed2", new object[]
                     {
                         shopItemInfo.AValue1
                     }));
                     return(true);
                 }
                 player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("UserFirecrackersCommand.MoneyNotEnough", new object[0]));
             }
         }
     }
     return(false);
 }
Пример #5
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eMessageType eMsg = eMessageType.Normal;
            string       msg  = "UserChangeItemColorHandler.Success";

            int    Card_bagType = packet.ReadInt();
            int    Card_place   = packet.ReadInt();
            int    bagType      = packet.ReadInt();
            int    place        = packet.ReadInt();
            string color        = packet.ReadString();
            string skin         = packet.ReadString();
            int    templateID   = packet.ReadInt();

            ItemInfo item = client.Player.MainBag.GetItemAt(place);
            ItemInfo card = client.Player.PropBag.GetItemAt(Card_place);

            if (item != null)
            {
                client.Player.BeginChanges();

                try
                {
                    bool changed = false;
                    if (card != null && card.IsValidItem())
                    {
                        client.Player.PropBag.RemoveItem(card);
                        changed = true;
                    }
                    else
                    {
                        ItemTemplateInfo    template = ItemMgr.FindItemTemplate(templateID);
                        List <ShopItemInfo> Template = ShopMgr.FindShopbyTemplatID(templateID);
                        int Money = 0;
                        for (int i = 0; i < Template.Count; i++)
                        {
                            if (Template[i].APrice1 == -1 && Template[i].AValue1 != 0)
                            {
                                Money = Template[i].AValue1;
                            }
                        }
                        if (Money <= client.Player.PlayerCharacter.Money)
                        {
                            client.Player.RemoveMoney(Money);
                            LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Color, client.Player.PlayerCharacter.ID, Money, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                            // client.Player.RemoveGold(template.Gold, GoldRemoveType.Other);

                            changed = true;
                        }
                    }
                    if (changed)
                    {
                        item.Color = color == null ? "" : color;
                        item.Skin  = skin == null ? "" : skin;
                        client.Player.MainBag.UpdateItem(item);
                    }
                }
                finally
                {
                    client.Player.CommitChanges();
                }
            }
            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            return(0);
        }
Пример #6
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.IsMarried)
            {
                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);
            }
            int    num = packet.ReadInt();
            string loveProclamation = packet.ReadString();

            packet.ReadBoolean();
            bool flag = true;

            using (PlayerBussiness playerBussiness = new PlayerBussiness())
            {
                PlayerInfo userSingleByUserID = playerBussiness.GetUserSingleByUserID(num);
                if (userSingleByUserID == null || userSingleByUserID.Sex == client.Player.PlayerCharacter.Sex)
                {
                    int result = 1;
                    return(result);
                }
                if (userSingleByUserID.IsMarried)
                {
                    client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg2", new object[0]));
                    int result = 1;
                    return(result);
                }
                ItemInfo itemByTemplateID = client.Player.PropBag.GetItemByTemplateID(0, 11103);
                if (itemByTemplateID == null)
                {
                    ShopItemInfo shopItemInfo = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault <ShopItemInfo>();
                    if (shopItemInfo == null)
                    {
                        client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg6", new object[0]));
                        int result = 1;
                        return(result);
                    }
                    if (client.Player.PlayerCharacter.Money < shopItemInfo.AValue1)
                    {
                        client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg1", new object[0]));
                        int result = 1;
                        return(result);
                    }
                    flag = false;
                }
                MarryApplyInfo marryApplyInfo = new MarryApplyInfo();
                marryApplyInfo.UserID           = num;
                marryApplyInfo.ApplyUserID      = client.Player.PlayerCharacter.ID;
                marryApplyInfo.ApplyUserName    = client.Player.PlayerCharacter.NickName;
                marryApplyInfo.ApplyType        = 1;
                marryApplyInfo.LoveProclamation = loveProclamation;
                marryApplyInfo.ApplyResult      = false;
                int iD = 0;
                if (playerBussiness.SavePlayerMarryNotice(marryApplyInfo, 0, ref iD))
                {
                    if (flag)
                    {
                        client.Player.RemoveItem(itemByTemplateID);
                    }
                    else
                    {
                        ShopItemInfo shopItemInfo2 = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault <ShopItemInfo>();
                        client.Player.RemoveMoney(shopItemInfo2.AValue1);
                        LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Spark, client.Player.PlayerCharacter.ID, shopItemInfo2.AValue1, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", shopItemInfo2.TemplateID.ToString(), "1");
                    }
                    client.Player.Out.SendPlayerMarryApply(client.Player, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, loveProclamation, iD);
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(num);
                    string arg_2BA_0 = userSingleByUserID.NickName;
                    client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg3", new object[0]));
                }
            }
            return(0);
        }
Пример #7
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            //判断是否结婚
            if (client.Player.PlayerCharacter.IsMarried)
            {
                return(1);
            }
            //是否有二级密码
            if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                return(1);
            }
            //开始求婚,购买戒指
            int    SpouseID         = packet.ReadInt();
            string loveProclamation = packet.ReadString();
            bool   Broadcast        = packet.ReadBoolean();
            bool   result           = false;
            bool   removeRing       = true;
            string SpouseName       = "";

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo tempSpouse = db.GetUserSingleByUserID(SpouseID);
                if (tempSpouse == null || tempSpouse.Sex == client.Player.PlayerCharacter.Sex)
                {
                    return(1);
                }
                if (tempSpouse.IsMarried)
                {
                    client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg2"));
                    return(1);
                }
                ItemInfo WeddingRing = client.Player.PropBag.GetItemByTemplateID(0, 11103);
                if (WeddingRing == null)
                {
                    ShopItemInfo tempRing = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault();
                    if (tempRing != null)
                    {
                        //玩家身上钱是否足够。
                        if (client.Player.PlayerCharacter.Money >= tempRing.AValue1)
                        {
                            removeRing = false;
                        }
                        else
                        {
                            client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg1"));
                            return(1);
                        }
                    }
                    else
                    {
                        client.Player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg6"));
                        return(1);
                    }
                }
                //插入结婚消息
                MarryApplyInfo info = new MarryApplyInfo();
                info.UserID           = SpouseID;
                info.ApplyUserID      = client.Player.PlayerCharacter.ID;
                info.ApplyUserName    = client.Player.PlayerCharacter.NickName;
                info.ApplyType        = 1;
                info.LoveProclamation = loveProclamation;
                info.ApplyResult      = false;
                int id = 0;
                if (db.SavePlayerMarryNotice(info, 0, ref id))
                {
                    if (removeRing)
                    {
                        client.Player.RemoveItem(WeddingRing);
                    }
                    else
                    {
                        //未开始
                        ShopItemInfo tempRing = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault();
                        client.Player.RemoveMoney(tempRing.AValue1);
                        LogMgr.LogMoneyAdd(LogMoneyType.Marry, LogMoneyType.Marry_Spark, client.Player.PlayerCharacter.ID, tempRing.AValue1, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", tempRing.TemplateID.ToString(), "1");
                    }
                    client.Player.Out.SendPlayerMarryApply(client.Player, client.Player.PlayerCharacter.ID, client.Player.PlayerCharacter.NickName, loveProclamation, id);  //发送求婚信息
                    //发送消息给中心服务器
                    GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(SpouseID);
                    SpouseName = tempSpouse.NickName;
                    result     = true;

                    client.Player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg3"));
                }
            }
            if (result && Broadcast && SpouseName != "")
            {
                string     msg = LanguageMgr.GetTranslation("MarryApplyHandler.Msg5", client.Player.PlayerCharacter.NickName, SpouseName);
                GSPacketIn pkg = new GSPacketIn((byte)ePackageType.SYS_NOTICE);
                pkg.WriteInt(2);
                pkg.WriteString(msg);
                GameServer.Instance.LoginServer.SendPacket(pkg);
                GamePlayer[] players = WorldMgr.GetAllPlayers();
                foreach (GamePlayer p in players)
                {
                    p.Out.SendTCP(pkg);
                }
            }
            return(0);
        }
Пример #8
0
        public override int HandlePacket(GamePlayer player, GSPacketIn packet)
        {
            int result2;

            if (player.PlayerCharacter.IsMarried)
            {
                result2 = 1;
            }
            else
            {
                if (player.PlayerCharacter.HasBagPassword && player.PlayerCharacter.IsLocked)
                {
                    player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked", new object[0]));
                    result2 = 1;
                }
                else
                {
                    int    SpouseID         = packet.ReadInt();
                    string loveProclamation = packet.ReadString();
                    bool   Broadcast        = packet.ReadBoolean();
                    bool   result           = false;
                    bool   removeRing       = true;
                    string SpouseName       = "";
                    using (PlayerBussiness db = new PlayerBussiness())
                    {
                        PlayerInfo tempSpouse = db.GetUserSingleByUserID(SpouseID);
                        if (tempSpouse == null || tempSpouse.Sex == player.PlayerCharacter.Sex)
                        {
                            result2 = 1;
                            return(result2);
                        }
                        if (tempSpouse.IsMarried)
                        {
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg2", new object[0]));
                            result2 = 1;
                            return(result2);
                        }
                        ItemInfo WeddingRing = player.PropBag.GetItemByTemplateID(0, 11103);
                        if (WeddingRing == null)
                        {
                            ShopItemInfo tempRing = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault <ShopItemInfo>();
                            if (tempRing == null)
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg6", new object[0]));
                                result2 = 1;
                                return(result2);
                            }
                            if (player.PlayerCharacter.Money < tempRing.AValue1)
                            {
                                player.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg1", new object[0]));
                                result2 = 1;
                                return(result2);
                            }
                            removeRing = false;
                        }
                        MarryApplyInfo info = new MarryApplyInfo();
                        info.UserID           = SpouseID;
                        info.ApplyUserID      = player.PlayerCharacter.ID;
                        info.ApplyUserName    = player.PlayerCharacter.NickName;
                        info.ApplyType        = 1;
                        info.LoveProclamation = loveProclamation;
                        info.ApplyResult      = false;
                        int id = 0;
                        if (db.SavePlayerMarryNotice(info, 0, ref id))
                        {
                            if (removeRing)
                            {
                                player.RemoveItem(WeddingRing, eItemRemoveType.Wedding);
                            }
                            else
                            {
                                ShopItemInfo tempRing = ShopMgr.FindShopbyTemplatID(11103).FirstOrDefault <ShopItemInfo>();
                                player.OnUsingItem(tempRing.TemplateID);
                                player.RemoveMoney(tempRing.AValue1, LogMoneyType.Marry, LogMoneyType.Marry_Spark);
                            }
                            player.Out.SendPlayerMarryApply(player, player.PlayerCharacter.ID, player.PlayerCharacter.NickName, loveProclamation, id);
                            GameServer.Instance.LoginServer.SendUpdatePlayerMarriedStates(SpouseID);
                            SpouseName = tempSpouse.NickName;
                            result     = true;
                            player.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("MarryApplyHandler.Msg3", new object[0]));
                        }
                    }
                    if (result && Broadcast && SpouseName != "")
                    {
                        string msg = LanguageMgr.GetTranslation("MarryApplyHandler.Msg5", new object[]
                        {
                            player.PlayerCharacter.NickName,
                            SpouseName
                        });
                        GSPacketIn pkg = new GSPacketIn(10);
                        pkg.WriteInt(2);
                        pkg.WriteString(msg);
                        GameServer.Instance.LoginServer.SendPacket(pkg);
                        GamePlayer[] players = WorldMgr.GetAllPlayers();
                        GamePlayer[] array   = players;
                        for (int i = 0; i < array.Length; i++)
                        {
                            GamePlayer p = array[i];
                            p.Out.SendTCP(pkg);
                        }
                    }
                    result2 = 0;
                }
            }
            return(result2);
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eMessageType type        = eMessageType.Normal;
            string       translateId = "UserChangeItemColorHandler.Success";

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

            packet.ReadInt();
            int      slot2   = packet.ReadInt();
            string   text    = packet.ReadString();
            string   text2   = packet.ReadString();
            int      num     = packet.ReadInt();
            ItemInfo itemAt  = client.Player.MainBag.GetItemAt(slot2);
            ItemInfo itemAt2 = client.Player.PropBag.GetItemAt(slot);

            if (itemAt != null)
            {
                client.Player.BeginChanges();
                try
                {
                    bool flag = false;
                    if (itemAt2 != null && itemAt2.IsValidItem())
                    {
                        client.Player.PropBag.RemoveItem(itemAt2);
                        flag = true;
                    }
                    else
                    {
                        ItemMgr.FindItemTemplate(num);
                        List <ShopItemInfo> list = ShopMgr.FindShopbyTemplatID(num);
                        int num2 = 0;
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (list[i].APrice1 == -1 && list[i].AValue1 != 0)
                            {
                                num2 = list[i].AValue1;
                            }
                        }
                        if (num2 <= client.Player.PlayerCharacter.Money)
                        {
                            client.Player.RemoveMoney(num2);
                            LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Color, client.Player.PlayerCharacter.ID, num2, client.Player.PlayerCharacter.Money, 0, 0, 0, 0, "", "", "");
                            flag = true;
                        }
                    }
                    if (flag)
                    {
                        itemAt.Color = ((text == null) ? "" : text);
                        itemAt.Skin  = ((text2 == null) ? "" : text2);
                        client.Player.MainBag.UpdateItem(itemAt);
                    }
                }
                finally
                {
                    client.Player.CommitChanges();
                }
            }
            client.Out.SendMessage(type, LanguageMgr.GetTranslation(translateId, new object[0]));
            return(0);
        }
Пример #10
0
        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);
        }
Пример #11
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            eBageType           bagType   = (eBageType)packet.ReadInt();
            int                 place     = packet.ReadInt();
            eBageType           bagType2  = (eBageType)packet.ReadInt();
            List <ShopItemInfo> list      = new List <ShopItemInfo>();
            int                 num       = packet.ReadInt();
            int                 operation = packet.ReadInt();
            ItemInfo            itemInfo;

            if (num == -1)
            {
                packet.ReadInt();
                int num2 = packet.ReadInt();
                int num3 = 0;
                int num4 = 0;
                ItemTemplateInfo goods = ItemMgr.FindItemTemplate(34101);
                itemInfo = ItemInfo.CreateFromTemplate(goods, 1, 102);
                list     = ShopMgr.FindShopbyTemplatID(34101);
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].APrice1 == -1 && list[i].AValue1 != 0)
                    {
                        num4 = list[i].AValue1;
                        itemInfo.ValidDate = list[i].AUnit;
                    }
                }
                if (itemInfo != null)
                {
                    if (num3 <= client.Player.PlayerCharacter.Gold && num4 <= client.Player.PlayerCharacter.Money)
                    {
                        client.Player.RemoveMoney(num4);
                        client.Player.RemoveGold(num3);
                        LogMgr.LogMoneyAdd(LogMoneyType.Item, LogMoneyType.Item_Move, client.Player.PlayerCharacter.ID, num4, client.Player.PlayerCharacter.Money, num3, 0, 0, 0, "牌子编号", itemInfo.TemplateID.ToString(), num2.ToString());
                    }
                    else
                    {
                        itemInfo = null;
                    }
                }
            }
            else
            {
                itemInfo = client.Player.GetItemAt(bagType2, num);
            }
            ItemInfo      itemAt        = client.Player.GetItemAt(bagType, place);
            StringBuilder stringBuilder = new StringBuilder();

            if (itemInfo == null || itemAt == null)
            {
                return(1);
            }
            bool             flag             = false;
            ItemTemplateInfo itemTemplateInfo = RefineryMgr.RefineryTrend(operation, itemAt, ref flag);

            if (flag && itemTemplateInfo != null)
            {
                ItemInfo          itemInfo2     = ItemInfo.CreateFromTemplate(itemTemplateInfo, 1, 115);
                AbstractInventory itemInventory = client.Player.GetItemInventory(itemTemplateInfo);
                if (itemInventory.AddItem(itemInfo2, itemInventory.BeginSlot))
                {
                    client.Player.UpdateItem(itemInfo2);
                    client.Player.RemoveItem(itemAt);
                    itemInfo.Count--;
                    client.Player.UpdateItem(itemInfo);
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Success", new object[0]));
                }
                else
                {
                    stringBuilder.Append("NoPlace");
                    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation(itemInfo2.GetBagName(), new object[0]) + LanguageMgr.GetTranslation("ItemFusionHandler.NoPlace", new object[0]));
                }
                return(1);
            }
            client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemTrendHandle.Fail", new object[0]));
            return(1);
        }