protected override async void Run(Session session, C2G_FriendRoomInfo message, Action <G2C_FriendRoomInfo> reply)
        {
            G2C_FriendRoomInfo response = new G2C_FriendRoomInfo();

            try
            {
                //获取房间信息
                DBProxyComponent      proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
                User                  user           = session.GetComponent <SessionUserComponent>().User;
                List <PlayerBaseInfo> playerInfoList = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{message.UId}}}");

                if (playerInfoList.Count > 0)
                {
                    response.Score = playerInfoList[0].Score;
                    if (!playerInfoList[0].IsGiveFriendKey)
                    {
                        string endTime = CommonUtil.timeAddDays(CommonUtil.getCurDataNormalFormat(), 1);

                        //每天赠送好友房钥匙
                        await DBCommonUtil.AddFriendKey(message.UId, 3, endTime, "每天赠送3把好友房钥匙");

                        playerInfoList[0].IsGiveFriendKey = true;
                        response.IsGiveFriendKey          = true;
                        Log.Debug(response.IsGiveFriendKey + "bool");
                        await proxyComponent.Save(playerInfoList[0]);
                    }
                    else
                    {
                        //今天已经赠送好友房钥匙
                    }
                }

                {
                    //向map服务器发送请求
                    ConfigComponent      configCom     = Game.Scene.GetComponent <ConfigComponent>();
                    StartConfigComponent _config       = Game.Scene.GetComponent <StartConfigComponent>();
                    IPEndPoint           mapIPEndPoint = _config.MapConfigs[0].GetComponent <InnerConfig>().IPEndPoint;
                    Session mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapIPEndPoint);

                    M2G_FriendRoomInfo m2GFriendRoomInfo = (M2G_FriendRoomInfo)await mapSession.Call(new G2M_FriendRoomInfo()
                    {
                    });

                    response.Info = m2GFriendRoomInfo.Info;

                    int keyCount = await DBCommonUtil.GetUserFriendKeyNum(message.UId);

                    response.KeyCount = keyCount;
                }

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Example #2
0
        protected override async void Run(Session session, C2G_BagOperation message, Action <G2C_BagOperation> reply)
        {
            G2C_BagOperation response = new G2C_BagOperation();

            try
            {
                DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
                List <UserBag>   bagInfoList    = await proxyComponent.QueryJson <UserBag>($"{{UId:{message.UId}}}");

                response.ItemList = new List <Bag>();
                List <Bag> itemList = new List <Bag>();
                for (int i = 0; i < bagInfoList.Count; ++i)
                {
                    if (bagInfoList[i].Count <= 0)
                    {
                        continue;
                    }
                    Bag item = new Bag();
                    item.ItemId = bagInfoList[i].BagId;
                    item.Count  = bagInfoList[i].Count;
                    itemList.Add(item);
                }


                int fKeyCount = await DBCommonUtil.GetUserFriendKeyNum(message.UId);

                if (fKeyCount > 0)
                {
                    Bag keyItem = new Bag();
                    keyItem.ItemId = 112;
                    keyItem.Count  = fKeyCount;
                    itemList.Add(keyItem);
                }

                response.ItemList = itemList;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Example #3
0
        protected override async void Run(Session session, C2G_CreateFriendRoom message, Action <G2C_CreateFriendRoom> reply)
        {
            G2C_CreateFriendRoom response = new G2C_CreateFriendRoom();

            try
            {
                User user     = session.GetComponent <SessionUserComponent>().User;
                int  keyCount = await DBCommonUtil.GetUserFriendKeyNum(user.UserID);

                if (keyCount < message.FriendRoomInfo.KeyCount)
                {
                    response.Error   = ErrorCode.ERR_Common;
                    response.Message = "钥匙数量不够!";
                    reply(response);
                    return;
                }
                //向map服务器发送请求
                StartConfigComponent config        = Game.Scene.GetComponent <StartConfigComponent>();
                IPEndPoint           mapIPEndPoint = config.MapConfigs[0].GetComponent <InnerConfig>().IPEndPoint;
                Session mapSession = Game.Scene.GetComponent <NetInnerComponent>().Get(mapIPEndPoint);

                M2G_CreateFriendRoom m2G_CreateFriendRoom = (M2G_CreateFriendRoom)await mapSession.Call(new G2M_CreateFriendRoom()
                {
                    UserId         = message.UserId,
                    FriendRoomInfo = message.FriendRoomInfo
                });

                response.RoomId  = m2G_CreateFriendRoom.RoomId;
                response.Error   = m2G_CreateFriendRoom.Error;
                response.Message = m2G_CreateFriendRoom.Message;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }

            await Task.CompletedTask;
        }
Example #4
0
        protected override async void Run(Session session, C2G_PlayerInfo message, Action <G2C_PlayerInfo> reply)
        {
//            Log.Info(JsonHelper.ToJson(message));
            G2C_PlayerInfo response = new G2C_PlayerInfo();

            try
            {
                User user = session.GetComponent <SessionUserComponent>()?.User;

                if (user == null)
                {
                    response.Error = ErrorCode.ERR_Common;
                    reply(response);
                    session.Dispose();
                    return;
                }
                DBProxyComponent      proxyComponent = Game.Scene.GetComponent <DBProxyComponent>();
                List <PlayerBaseInfo> playerInfo     = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{user.UserID}}}");

                List <OtherData> otherDatas = await proxyComponent.QueryJson <OtherData>($"{{UId:{user.UserID}}}");

                response.PlayerInfo = new PlayerInfo();
                int fKeyCount = await DBCommonUtil.GetUserFriendKeyNum(user.UserID);

                if (playerInfo != null)
                {
                    response.Message               = "数据库里已存在玩家的基本信息,返回玩家信息";
                    response.PlayerInfo.Name       = playerInfo[0].Name;
                    response.PlayerInfo.GoldNum    = playerInfo[0].GoldNum;
                    response.PlayerInfo.WingNum    = playerInfo[0].WingNum;
                    response.PlayerInfo.HuaFeiNum  = playerInfo[0].HuaFeiNum;
                    response.PlayerInfo.Icon       = playerInfo[0].Icon;
                    response.PlayerInfo.IsRealName = playerInfo[0].IsRealName;
                    AccountInfo accountInfo = await DBCommonUtil.getAccountInfo(user.UserID);

                    response.PlayerInfo.Phone               = accountInfo.Phone;
                    response.PlayerInfo.PlayerSound         = playerInfo[0].PlayerSound;
                    response.PlayerInfo.RestChangeNameCount = playerInfo[0].RestChangeNameCount;
                    response.PlayerInfo.VipTime             = playerInfo[0].VipTime;
                    response.PlayerInfo.EmogiTime           = playerInfo[0].EmogiTime;
                    response.PlayerInfo.MaxHua              = playerInfo[0].MaxHua;
                    response.PlayerInfo.WinGameCount        = playerInfo[0].WinGameCount;
                    response.PlayerInfo.IsGiveFriendKey     = playerInfo[0].IsGiveFriendKey;
                    response.PlayerInfo.FriendKeyCount      = fKeyCount;
                    response.PlayerInfo.Score               = playerInfo[0].Score;
                    List <ChengjiuInfo> infos =
                        await proxyComponent.QueryJson <ChengjiuInfo>($"{{UId:{user.UserID},TaskId:{102}}}");

                    if (infos.Count > 0)
                    {
                        response.PlayerInfo.TotalGameCount = infos[0].CurProgress;
                    }
                    if (otherDatas.Count > 0)
                    {
                        response.OwnIcon = otherDatas[0].OwnIcon;
                    }

                    // 今天是否签到过
                    {
                        List <DailySign> dailySigns = await proxyComponent.QueryJson <DailySign>($"{{CreateTime:/^{DateTime.Now.GetCurrentDay()}/,Uid:{user.UserID}}}");

                        if (dailySigns.Count == 0)
                        {
                            response.PlayerInfo.IsSign = false;
                        }
                        else
                        {
                            response.PlayerInfo.IsSign = true;
                        }
                    }

                    {
                        //端午节活动是否结束
//                        List<DuanwuDataBase> duanwuDataBases = await proxyComponent.QueryJson<DuanwuDataBase>($"{{UId:{user.UserID}}}");
//                        string curTime = CommonUtil.getCurTimeNormalFormat();
//                        if (string.CompareOrdinal(curTime, duanwuDataBases[0].EndTime) >= 0)
//                        {
//                            long goldNum = 0;
//                            if (duanwuDataBases[0].ZongziCount > 0)
//                            {
//                                goldNum = duanwuDataBases[0].ZongziCount * 100;
//                                duanwuDataBases[0].ZongziCount = 0;
//                                //添加邮件
//                                await DBCommonUtil.SendMail(user.UserID, "端午粽香", $"端午活动已结束,剩余粽子已转换为金币存入您的账号,兑换比例:一个粽子=100金币,您获得{goldNum}金币", $"1:{goldNum}");
//                                await proxyComponent.Save(duanwuDataBases[0]);
//                            }
//                        }
                    }

                    reply(response);
                    return;
                }

                response.Message    = "Account数据库里不存在该用户";
                response.PlayerInfo = null;
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }