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); } }
public static async Task <string> getRecord(long uid) { string jsonData = ""; List <FriendRoomRecordInfo> listData = new List <FriendRoomRecordInfo>(); DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); DBComponent dbComponent = Game.Scene.GetComponent <DBComponent>(); string time = CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), -90); var filter1 = (Builders <Log_Game> .Filter.Gt("CreateTime", time) & Builders <Log_Game> .Filter.Eq("RoomName", "好友房")) & (Builders <Log_Game> .Filter.Eq("Player1_uid", uid) | Builders <Log_Game> .Filter.Eq("Player2_uid", uid) | Builders <Log_Game> .Filter.Eq("Player3_uid", uid) | Builders <Log_Game> .Filter.Eq("Player4_uid", uid)); List <Log_Game> list = await dbComponent.GetDBDataCollection <Log_Game>(typeof(Log_Game).Name).Find(filter1).ToListAsync(); Log.Debug(JsonHelper.ToJson(list) + "====="); int roomNum = -1; FriendRoomRecordInfo FriendRoomRecordInfo = null; for (int i = list.Count - 1; i >= 0; i--) { // 如果房间号跟之前的不一样,说明这是另一局的 if (list[i].RoomNum != roomNum) { // 最多显示50条 if (listData.Count >= 50) { break; } roomNum = list[i].RoomNum; FriendRoomRecordInfo = new FriendRoomRecordInfo(); listData.Add(FriendRoomRecordInfo); FriendRoomRecordInfo.result = 1; FriendRoomRecordInfo.allScore = 100; FriendRoomRecordInfo.roomNum = list[i].RoomNum; FriendRoomRecordInfo.time = list[i].CreateTime; } // 每一小局对局信息 { FriendRoomRecordInfo.gameList.Add(new FriendRoomRecordInfo.ResultDetails(new List <string>() { list[i].Player1_info, list[i].Player2_info, list[i].Player3_info, list[i].Player4_info, }, list[i].CreateTime)); } } jsonData = JsonConvert.SerializeObject(listData); Log.Debug("------------------" + jsonData); return(jsonData); }
public static async Task Start(string channelName) { try { string time = CommonUtil.timeAddDays(CommonUtil.getCurDataNormalFormat(), -1); time = Convert.ToDateTime(time).ToString("yyyy-MM-dd"); string logData = ""; if (string.IsNullOrEmpty(channelName)) { logData = "渠道:所有\r\n"; } else { logData = "渠道:" + channelName + "\r\n"; } logData += await NewUser(time, channelName); logData += await DailyLogin(time, channelName); logData += await LoadOldUserCount(time, channelName); logData += await CiLiu(time, channelName); logData += await RechargeNum(time, channelName); logData += await RechargeUserNum(time, channelName); logData += await GameCount(time, channelName); logData += await GameUserCount(time, channelName); writeLogToLocalNow(logData); } catch (Exception ex) { } }
public async Task useProp(G2C_UseItem response, long uid, int prop_id) { string endTime = ""; DBProxyComponent proxyComponent = Game.Scene.GetComponent <DBProxyComponent>(); List <PlayerBaseInfo> playerBaseInfoList = await proxyComponent.QueryJson <PlayerBaseInfo>($"{{_id:{uid}}}"); PlayerBaseInfo playerBaseInfo = playerBaseInfoList[0]; switch (prop_id) { // 表情包 case 104: { // 未过期 if (playerBaseInfo.EmogiTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0) { endTime = (CommonUtil.timeAddDays(playerBaseInfo.EmogiTime, 30)); } // 已过期 else { endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 30)); } playerBaseInfo.EmogiTime = endTime; response.time = endTime; await proxyComponent.Save(playerBaseInfo); } break; // VIP7天体验卡 case 107: { // 未过期 if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0) { endTime = (CommonUtil.timeAddDays(playerBaseInfo.VipTime, 7)); } // 已过期 else { endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 7)); } playerBaseInfo.VipTime = endTime; response.time = endTime; await proxyComponent.Save(playerBaseInfo); } break; // VIP月卡 case 108: { // 未过期 if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0) { endTime = (CommonUtil.timeAddDays(playerBaseInfo.VipTime, 30)); } // 已过期 else { endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 30)); } playerBaseInfo.VipTime = endTime; response.time = endTime; await proxyComponent.Save(playerBaseInfo); } break; // VIP季卡 case 109: { // 未过期 if (playerBaseInfo.VipTime.CompareTo(CommonUtil.getCurTimeNormalFormat()) > 0) { endTime = (CommonUtil.timeAddDays(playerBaseInfo.VipTime, 90)); } // 已过期 else { endTime = (CommonUtil.timeAddDays(CommonUtil.getCurTimeNormalFormat(), 90)); } playerBaseInfo.VipTime = endTime; response.time = endTime; await proxyComponent.Save(playerBaseInfo); } break; // 话费礼包 case 111: { int huafei = Common_Random.getRandom(5, 20); string reward = ("3:" + huafei); response.reward = reward; await DBCommonUtil.changeWealthWithStr(playerBaseInfo.Id, reward, "道具使用:拆话费礼包获得的话费"); } break; } }