//修改:  Xiaov
        //时间:  2009-11-7
        //描述:  用户与用户之间私聊<已测试>
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int receiverID = packet.ReadInt();
            //int senderID = packet.ReadInt();
            string receiver = packet.ReadString();
            string sender = packet.ReadString();
            string msg = packet.ReadString();
            bool isAutoReply = packet.ReadBoolean();

            if (receiverID == 0)
            {
                using (PlayerBussiness db = new PlayerBussiness())
                {
                    PlayerInfo info = db.GetUserSingleByNickName(receiver);
                    if (info != null)
                        receiverID = info.ID;
                }
            }

            if (receiverID != 0)
            {
                GSPacketIn pkg = packet.Clone();
                pkg.ClearContext();
                pkg.WriteInt(receiverID);
                pkg.ClientID = (client.Player.PlayerCharacter.ID);
                //pkg.WriteInt(senderID);
                pkg.WriteString(receiver);
                pkg.WriteString(sender);
                pkg.WriteString(msg);
                pkg.WriteBoolean(false);

                GamePlayer player = Managers.WorldMgr.GetPlayerById(receiverID);

                if (player != null)
                {
                    if (player.IsBlackFriend(client.Player.PlayerCharacter.ID))
                        return 1;
                    player.Out.SendTCP(pkg);
                }
                else
                {

                    GameServer.Instance.LoginServer.SendPacket(pkg);
                }
                client.Out.SendTCP(pkg);
            }
            else
            {
                client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserPrivateChatHandler.NoUser"));
            }

            return 1;
        }
        public int KitoffUserByNickName(string name, string msg)
        {
            int result = 1;
            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo player = db.GetUserSingleByNickName(name);
                if (player == null)
                    return 2;

                result = KitoffUser(player.ID, msg);
            }
            return result;
        }
Exemple #3
0
        public int KitoffUserByNickName(string name, string msg)
        {
            int result = 1;

            using (PlayerBussiness playerBussiness = new PlayerBussiness())
            {
                PlayerInfo userSingleByNickName = playerBussiness.GetUserSingleByNickName(name);
                if (userSingleByNickName == null)
                {
                    return(2);
                }
                result = this.KitoffUser(userSingleByNickName.ID, msg);
            }
            return(result);
        }
        public int KitoffUserByNickName(string name, string msg)
        {
            int num = 1;

            using (PlayerBussiness playerBussiness = new PlayerBussiness())
            {
                PlayerInfo singleByNickName = playerBussiness.GetUserSingleByNickName(name);
                if (singleByNickName == null)
                {
                    return(2);
                }
                num = this.KitoffUser(singleByNickName.ID, msg);
            }
            return(num);
        }
Exemple #5
0
        public int KitoffUserByNickName(string name, string msg)
        {
            int result = 1;

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo player = db.GetUserSingleByNickName(name);
                if (player == null)
                {
                    return(2);
                }

                result = KitoffUser(player.ID, msg);
            }
            return(result);
        }
        public void ProcessRequest(HttpContext context)
        {
            LanguageMgr.Setup(ConfigurationManager.AppSettings["ReqPath"]);
            bool value = false;
            //string message = "Name is Exist!";
            string message = LanguageMgr.GetTranslation("Tank.Request.NickNameCheck.Exist");
            XElement result = new XElement("Result");

            try
            {
                string nickName = csFunction.ConvertSql(HttpUtility.UrlDecode(context.Request["NickName"]));
                if (System.Text.Encoding.Default.GetByteCount(nickName) <= 14)
                {
                    if (!string.IsNullOrEmpty(nickName))
                    {
                        using (PlayerBussiness db = new PlayerBussiness())
                        {
                            if (db.GetUserSingleByNickName(nickName) == null)
                            {
                                value = true;
                                //message = "You can register!";
                                message = LanguageMgr.GetTranslation("Tank.Request.NickNameCheck.Right",new object [0]);

                            }
                        }
                    }
                }
                else
                {
                    message = LanguageMgr.GetTranslation("Tank.Request.NickNameCheck.Long", new object[0]);
                }
            }
            catch(Exception ex)
            {
                log.Error("NickNameCheck", ex);
                value = false;
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            context.Response.ContentType = "text/plain";
            context.Response.Write(result.ToString(false));
        }
        // <summary>
        // 修改:  Xiaov 
        // 时间:  2009-11-7
        // 描述:  发送邮件<未测试>   
       
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {

           
            if (client.Player.PlayerCharacter.Gold < 100)
                return 1;

           

            string msg = "UserSendMailHandler.Success";
            eMessageType eMsg = eMessageType.Normal;
            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            string nickName = packet.ReadString().Trim();
            string title = packet.ReadString();
            string content = packet.ReadString();
            bool isPay = packet.ReadBoolean();
            int validDate = packet.ReadInt();
            int money = packet.ReadInt();

            eBageType bag1 = (eBageType)packet.ReadByte();
            int place1 = packet.ReadInt();
            eBageType bag2 = (eBageType)packet.ReadByte();
            int place2 = packet.ReadInt();
            eBageType bag3 = (eBageType)packet.ReadByte();
            int place3 = packet.ReadInt();
            eBageType bag4 = (eBageType)packet.ReadByte();
            int place4 = packet.ReadInt();

            if ((money!=0||place1!=-1||place2!=-1||place3!=-1||place4!=-1)&&(client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked))
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
                pkg.WriteBoolean(false);
                client.Out.SendTCP(pkg);
                return 1;
            }

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo user;
                GamePlayer player = Managers.WorldMgr.GetClientByPlayerNickName(nickName);
                if (player == null)
                {
                    user = db.GetUserSingleByNickName(nickName);
                }
                else
                {
                    user = player.PlayerCharacter;
                }

                if (user != null && !string.IsNullOrEmpty(nickName))
                {
                    if (user.NickName != client.Player.PlayerCharacter.NickName)
                    {
                        client.Player.SaveIntoDatabase();

                        //附件内容描述(例:邮件最后一行标注附件为:1、大喇叭x5;2、强化石4级x1;3、极•烈火x1;4、点券999999;5、强化公式-朱雀x5
                        MailInfo message = new MailInfo();
                        message.SenderID = client.Player.PlayerCharacter.ID;
                        message.Sender = client.Player.PlayerCharacter.NickName;
                        message.ReceiverID = user.ID;
                        message.Receiver = user.NickName;
                        message.IsExist = true;
                        message.Gold = 0;
                        message.Money = 0;

                        message.Title = title;
                        message.Content = content;
                        List<ItemInfo> items = new List<ItemInfo>();
                        List<eBageType> bagType = new List<eBageType>();
                        StringBuilder annexRemark = new StringBuilder();
                        annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.AnnexRemark"));
                        int index = 0;

                        if (place1 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag1, place1);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex1Name = goods.Template.Name;
                                message.Annex1 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag1);
                                //annexRemark = message.Annex1Name + "x" + goods.Count;
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                //annexRemark.Append(annexRemark.Length);
                                annexRemark.Append(message.Annex1Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                                //goods.UserID = 0;
                                //client.Player.RemoveAllItem(goods, true, ItemRemoveType.Mail);
                            }
                        }

                        if (place2 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag2, place2);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex2Name = goods.Template.Name;
                                message.Annex2 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag2);
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(message.Annex2Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                                //goods.UserID = 0;
                                //client.Player.RemoveAllItem(goods, true, ItemRemoveType.Mail);
                            }
                        }

                        if (place3 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag3, place3);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex3Name = goods.Template.Name;
                                message.Annex3 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag3);
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(message.Annex3Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                            }
                        }

                        if (place4 != -1)
                        {
                            ItemInfo goods = client.Player.GetItemAt(bag4, place4);
                            if (goods != null && !goods.IsBinds)
                            {
                                message.Annex4Name = goods.Template.Name;
                                message.Annex4 = goods.ItemID.ToString();
                                items.Add(goods);
                                bagType.Add(bag4);
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(message.Annex4Name);
                                annexRemark.Append("x");
                                annexRemark.Append(goods.Count);
                                annexRemark.Append(";");
                            }
                        }

                        if (isPay)
                        {
                            if (money <= 0 || (string.IsNullOrEmpty(message.Annex1) && string.IsNullOrEmpty(message.Annex2) && string.IsNullOrEmpty(message.Annex3) && string.IsNullOrEmpty(message.Annex4)))
                                return 1;

                            message.ValidDate = validDate == 1 ? 1 : 6;
                            message.Type = (int)eMailType.Payment;
                            if (money > 0)
                            {
                                message.Money = money;
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.PayMoney"));
                                annexRemark.Append(money);
                                annexRemark.Append(";");
                            }
                        }
                        else
                        {
                            message.Type = (int)eMailType.Common;
                            if (client.Player.PlayerCharacter.Money >= money && money > 0)
                            {
                                message.Money = money;
                                client.Player.RemoveMoney(money);
                                LogMgr.LogMoneyAdd(LogMoneyType.Mail, LogMoneyType.Mail_Send, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, 0, 0, 0, "", "", "");
                                index++;
                                annexRemark.Append(index);
                                annexRemark.Append("、");
                                annexRemark.Append(LanguageMgr.GetTranslation("UserSendMailHandler.Money"));
                                annexRemark.Append(money);
                                annexRemark.Append(";");
                            }
                        }

                        if (annexRemark.Length > 1)
                        {
                            message.AnnexRemark = annexRemark.ToString();
                        }

                        if (db.SendMail(message))
                        {
                            client.Player.RemoveGold(100);
                            for(int i=0;i<items.Count;i++)
                            {
                                items[i].UserID = 0;
                                client.Player.RemoveItem(items[i]);
                                items[i].IsExist = true;
                            }
                        }

                        client.Player.SaveIntoDatabase();
                        pkg.WriteBoolean(true);

                        //发送通知
                        if (user.State != 0)
                        {
                            client.Player.Out.SendMailResponse(user.ID, eMailRespose.Receiver);
                        }
                        client.Player.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Send);
                    }
                    else
                    {
                        msg = "UserSendMailHandler.Failed1";
                        pkg.WriteBoolean(false);
                    }
                }
                else
                {   
                     
                    eMsg = eMessageType.ERROR;
                    msg = "UserSendMailHandler.Failed2";
                    pkg.WriteBoolean(false);
                }
            }
            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            client.Out.SendTCP(pkg);
            
            return 0;
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            int gold = 0;            //表示金币
            int money = 0;           //表示点券
            int offer = 0;           //表示功勋
            int gifttoken = 0;       //表示礼劵
            StringBuilder payGoods = new StringBuilder();                    //表示支付物品ID
            eMessageType eMsg = eMessageType.Normal;
            string msg = "GoodsPresentHandler.Success";

            string content = packet.ReadString();       //赠送人留言
            string nickName = packet.ReadString();      //购买人昵称
            List<int> needitemsinfo = new List<int>();  //存放兑换物品的templateID,Count

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

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo receiver = db.GetUserSingleByNickName(nickName);
                if (receiver != null)
                {
                    List<ItemInfo> items = new List<ItemInfo>();
                    StringBuilder types = new StringBuilder();

                    int count = packet.ReadInt();
                    for (int i = 0; i < count; i++)
                    {
                        int GoodsID = packet.ReadInt();         //序号
                        int type = packet.ReadInt();       //购买方式
                        string color = packet.ReadString();//颜色
                        string skin = packet.ReadString(); //皮肤

                        ShopItemInfo shopItem = Bussiness.Managers.ShopMgr.GetShopItemInfoById(GoodsID);                   //获取商品信息

                        if (shopItem == null)                                                                              //商品不存在
                        {
                            continue;
                        }

                        ItemTemplateInfo goods = Bussiness.Managers.ItemMgr.FindItemTemplate(shopItem.TemplateID);              //查找物品属性
                        ItemInfo item = ItemInfo.CreateFromTemplate(goods, 1, (int)ItemAddType.Gift);                           //构建物品临时属性

                        if (item == null)
                            continue;

                        //未开始
                        //if (shopitem.AValue1 <= 0 || shopitem.Beat <= 0)
                        //    continue;

                        item.Color = color == null ? "" : color;
                        item.Skin = skin == null ? "" : skin;

                        if (item == null)
                            continue;

                        types.Append(type);
                        types.Append(",");
                        items.Add(item);

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

                    if (items.Count == 0)
                        return 1;

                    //////////////////////////////////////////////////////////////////////////////////////
                    //玩家背包中是否有兑换物品所需要的物品
                    int icount = client.Player.MainBag.GetItems().Count;       //获取个数
                    bool result = true;
                    for (int j = 0; j < needitemsinfo.Count; j += 2)
                    {
                        if (client.Player.GetItemCount(needitemsinfo[j]) < needitemsinfo[j + 1])
                        {
                            result = false;
                        }
                    }

                    if (!result)
                    {
                        eMsg = eMessageType.ERROR;
                        msg = "UserBuyItemHandler.NoBuyItem";
                        return 1;
                    }
                    /////////////////////////////////////////////////////////////

                    if (gold <= client.Player.PlayerCharacter.Gold && money <= client.Player.PlayerCharacter.Money && offer <= client.Player.PlayerCharacter.Offer && gifttoken <= client.Player.PlayerCharacter.GiftToken)
                    {

                        types.Remove(types.Length - 1, 1);
                        client.Player.RemoveMoney(money);
                        client.Player.RemoveGold(gold);
                        client.Player.RemoveOffer(offer);
                        client.Player.RemoveGiftToken(gifttoken);
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        //从玩家背包中删除兑换所需要的物品
                        for (int j = 0; j < needitemsinfo.Count; j += 2)
                        {
                            client.Player.RemoveTemplate(needitemsinfo[j], needitemsinfo[j + 1]);
                            payGoods.Append(needitemsinfo[j].ToString() + ":");
                        }
                        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

                        foreach (ItemInfo item in items)
                        {
                            itemIDs += (itemIDs == "" ? item.TemplateID.ToString() : "," + item.TemplateID.ToString());
                            item.UserID = 0;
                            db.AddGoods(item);

                            annexIndex++;
                            annexRemark.Append(annexIndex);
                            annexRemark.Append("、");
                            annexRemark.Append(item.Template.Name);
                            annexRemark.Append("x");
                            annexRemark.Append(item.Count);
                            annexRemark.Append(";");

                            switch (annexIndex)
                            {
                                case 1:
                                    message.Annex1 = item.ItemID.ToString();
                                    message.Annex1Name = item.Template.Name;
                                    break;
                                case 2:
                                    message.Annex2 = item.ItemID.ToString();
                                    message.Annex2Name = item.Template.Name;
                                    break;
                                case 3:
                                    message.Annex3 = item.ItemID.ToString();
                                    message.Annex3Name = item.Template.Name;
                                    break;
                                case 4:
                                    message.Annex4 = item.ItemID.ToString();
                                    message.Annex4Name = item.Template.Name;
                                    break;
                                case 5:
                                    message.Annex5 = item.ItemID.ToString();
                                    message.Annex5Name = item.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 = content;
                                message.Gold = 0;
                                message.Money = 0;
                                message.Receiver = receiver.NickName;
                                message.ReceiverID = receiver.ID;
                                message.Sender = client.Player.PlayerCharacter.NickName;
                                message.SenderID = client.Player.PlayerCharacter.ID;
                                message.Title = message.Sender + LanguageMgr.GetTranslation("GoodsPresentHandler.Content") + message.Annex1Name + "]";
                                message.Type = (int)eMailType.PresentItem;
                                db.SendMail(message);

                                message.Revert();
                            }
                        }

                        if (annexIndex > 0)
                        {
                            message.AnnexRemark = annexRemark.ToString();
                            message.Content = content;
                            message.Gold = 0;
                            message.Money = 0;
                            message.Receiver = receiver.NickName;
                            message.ReceiverID = receiver.ID;
                            message.Sender = client.Player.PlayerCharacter.NickName;
                            message.SenderID = client.Player.PlayerCharacter.ID;
                            message.Title = message.Sender + LanguageMgr.GetTranslation("GoodsPresentHandler.Content") + message.Annex1Name + "]";
                            message.Type = (int)eMailType.PresentItem;
                            db.SendMail(message);
                        }
                        LogMgr.LogMoneyAdd(LogMoneyType.Shop, LogMoneyType.Shop_Present, client.Player.PlayerCharacter.ID, money, client.Player.PlayerCharacter.Money, gold, gifttoken, offer, payGoods.ToString(), itemIDs, types.ToString());
                        client.Out.SendMailResponse(receiver.ID, eMailRespose.Receiver);
                        client.Out.SendMailResponse(client.Player.PlayerCharacter.ID, eMailRespose.Send);
                    }
                    else
                    {
                        eMsg = eMessageType.ERROR;
                        msg = "GoodsPresentHandler.NoMoney";
                    }
                }
                else
                {
                    eMsg = eMessageType.ERROR;
                    msg = "GoodsPresentHandler.NoUser";
                }
            }
            client.Out.SendMessage(eMsg, LanguageMgr.GetTranslation(msg));
            return 0;
        }
        //0友好,1黑名单
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg = packet.Clone();
            pkg.ClearContext();

            string nickName = packet.ReadString();
            int relation = packet.ReadInt();
            if (relation < 0 || relation > 1)
                return 1;

            using (PlayerBussiness db = new PlayerBussiness())
            {
                PlayerInfo user = null;
                GamePlayer player = Managers.WorldMgr.GetClientByPlayerNickName(nickName);
                if (player != null)
                    user = player.PlayerCharacter;
                else
                    user = db.GetUserSingleByNickName(nickName);
                if (!string.IsNullOrEmpty(nickName) && user != null)
                {
                    if (!client.Player.Friends.ContainsKey(user.ID) || client.Player.Friends[user.ID] != relation)
                    {
                        FriendInfo friend = new FriendInfo();
                        friend.FriendID = user.ID;
                        friend.IsExist = true;
                        friend.Remark = "";
                        friend.UserID = client.Player.PlayerCharacter.ID;
                        friend.Relation = relation;
                        if (db.AddFriends(friend))
                        {
                            client.Player.FriendsAdd(user.ID, relation);
                            pkg.WriteInt(user.ID);
                            pkg.WriteString(user.NickName);
                            pkg.WriteBoolean(user.Sex);
                            pkg.WriteString(user.Style);
                            pkg.WriteString(user.Colors);
                            pkg.WriteString(user.Skin);
                            pkg.WriteInt(user.State == 1 ? 1 : 0);
                            pkg.WriteInt(user.Grade);
                            pkg.WriteInt(user.Hide);
                            pkg.WriteString(user.ConsortiaName);
                            pkg.WriteInt(user.Total);
                            pkg.WriteInt(user.Escape);
                            pkg.WriteInt(user.Win);
                            pkg.WriteInt(user.Offer);
                            pkg.WriteInt(user.Repute);
                            pkg.WriteInt(relation);
                            pkg.WriteString(user.UserName);
                            pkg.WriteInt(user.Nimbus);
                            pkg.WriteInt(user.FightPower);
                            pkg.WriteInt(500);
                            pkg.WriteString("Honor");
                            if (relation != 1 && user.State != 0)
                            {
                                GSPacketIn response = new GSPacketIn((byte)ePackageType.FRIEND_RESPONSE, client.Player.PlayerCharacter.ID);
                                response.WriteInt(user.ID);
                                response.WriteString(client.Player.PlayerCharacter.NickName);
                                if (player != null)
                                    player.Out.SendTCP(response);
                                else
                                    GameServer.Instance.LoginServer.SendPacket(response);
                            }
                            client.Out.SendTCP(pkg);
                        }
                    }
                    else
                    {
                        client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("FriendAddHandler.Falied"));
                    }
                }
                else
                {
                    client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("FriendAddHandler.Success"));
                }
            }
            return 0;
        }