Пример #1
0
        /// <summary>
        /// 进入房间中的指定桌子
        /// </summary>
        /// <returns></returns>
        public string EnterRoomTable(tb_User _user, cs_enterroomtable _data)
        {
            sc_enterroomtable _senddata = new sc_enterroomtable()
            {
                result = 0, fn = "sc_enterroomtable", cc = 0
            };

            int _tablenum = 0;

            if (int.TryParse(_data.tablenum, out _tablenum))
            {
                BullFight100Table _findtable = BullFight100Lobby.instance.GetTableByTableNum(_tablenum);
                if (_findtable == null)
                {
                    return(JsonUtils.Serialize(_senddata));
                }
                BullFight100Room room = BullFight100Lobby.instance.GetRoomByRoomID(_findtable._roomid);
                if (room == null)
                {
                    return(JsonUtils.Serialize(_senddata));
                }
                int WaitUserCount = room.EnterRoomTable(_findtable._roomid, _user);
                _senddata.result      = WaitUserCount;
                _senddata.tableid     = _findtable._tableid;
                _senddata.levelid     = _findtable._roomid;
                _senddata.numpertable = _findtable._num_max;
                _senddata.gametype    = _findtable._judge._gametype;
                _senddata.gameModel   = _findtable._judge._gameCoin2Room1;
            }
            return(JsonUtils.Serialize(_senddata));
        }
Пример #2
0
        public bool SendChat(int userid, cs_chat chat)
        {
            BullFight100Table _bftable = GetTableByRoomIDandTableID(chat.levelid, chat.tableid);

            if (_bftable != null)
            {
                lock (_bftable)
                {
                    _bftable.SendChatBase(userid, chat.content, chat.type);
                }
                return(true);
            }
            return(false);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public BullFight100User GetUserByRoomIDandTableIDandUserID(int RoomID, int TableID, int UserID)
        {
            BullFight100Table _bftable = GetTableByRoomIDandTableID(RoomID, TableID);

            if (_bftable == null)
            {
                ErrorRecord.Record("21020726151103 RoomID:" + RoomID + ",  TableID:" + TableID + ",  UserID:" + UserID);
                return(null);
            }
            lock (_bftable)
            {
                return(_bftable.GetUserByID(UserID));
            }
        }
Пример #4
0
        /// <summary>
        /// 自动分配 1个人机器人创建一个桌子 仅金币模式
        /// </summary>
        /// <returns></returns>
        public int CreateTableByRobot()
        {
            lock (objLock)
            {
                if (GMService.isStop)
                {
                    return(0);
                }
                BullFight100Room roomData;
                roomCache.TryGet(mRoomID + "", out roomData);
                if (roomData == null)
                {
                    return(0);
                }

                int _tid = 0;
                //只有一个桌子 所有不用生产桌子
                if (!unusedTableQue.TryDequeue(out _tid))
                {
                    ErrorRecord.Record("201704011350BFC unusedQue.Count <= 0   桌子不够了,,只是能等待排队...");
                    DicUser = new ConcurrentDictionary <int, BullFight100User>();
                    return(0);
                }
                tb_User tbuser = tb_UserEx.GetFromCachebyUserID(2000000);
                if (tbuser == null)
                {
                    ErrorRecord.Record("没有特殊机器人了系 统不能开始牛牛时时彩");
                    return(0);
                }
                tbuser.UserMoney = 2345;                                            //===================================测试
                BullFight100User tempU = new BullFight100User();
                tempU.Initi(tbuser.UserID + "", mRoomID, tbuser, true);             // 当成客户端 的IP:Port用
                roomData.EnterRoomBase(tempU._tbUser.UserID, _currRoomInfo.gameid); //处理状态的,不然一直找不到用户
                cs_enterroom _data = new cs_enterroom()
                {
                    baserate = _currRoomInfo.Baserate, gametype = _currRoomInfo.gametype, gameid = 42, gamemodel = 2, levelid = mRoomID, numpertable = 500, roomcard = 0, rankertype = 1, tableCount = 1
                };


                BullFight100Table tab = new BullFight100Table(_currRoomInfo.gameid, this, _tid, tempU, _data);
                //添加到当前桌子列表,以便打牌过程好使用
                if (!DicTable.TryAdd(_tid, tab))
                {
                    ErrorRecord.Record("add _tableid fial maybe have exist... 201208241601BF");
                }
                return(_tid);
            }
        }
Пример #5
0
        private void AddOnlineInformation(object state)
        {
            var bll_online = new BLL_OnlineInformation();

            lock (_objLock)
            {
                try
                {
                    var data   = new List <tb_OnlineInformation>();
                    var brlist = BullFight100Room.roomCache.FindAll();
                    foreach (var _tempbfroom in brlist)
                    {
                        int gameModel = 2;
                        int userCount = 0;
                        // var count = _tempbfroom.DicTable.Count * 4 + _tempbfroom.DicUser.Count;
                        if (_tempbfroom.DicTable.Count > 0)
                        {
                            _tempbfroom.DicTable.Values.ToList().ForEach(d =>
                            {
                                userCount += d._pos2userbase.Values.Where(w => !w._isRobot).Count();
                            });
                            //._pos2userbase.Values.Where(w => !w._isRobot).Count();
                            BullFight100Table _tempbfTable = _tempbfroom.DicTable.Values.FirstOrDefault();
                            if (_tempbfTable != null && _tempbfTable._judge != null)
                            {
                                gameModel = _tempbfTable._judge._gameCoin2Room1;
                            }
                        }
                        if (userCount > 0)
                        {
                            data.Add(new tb_OnlineInformation()
                            {
                                CreateTime  = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"),
                                GameModel   = gameModel,
                                RoomId      = _tempbfroom.mRoomID,
                                OnlineCount = userCount,
                                GameType    = 1
                            });
                        }
                    }
                    bll_online.AddRange(data);
                }
                catch (Exception ex)
                {
                    ErrorRecord.Record(new Exception(), ex.Message);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// 进入房间 返回现在等待用户数
        /// </summary>
        /// <returns></returns>
        private string ApplyExitTable(tb_User _user, cs_applyexittable _data)
        {
            sc_applyexittable _senddata = new sc_applyexittable()
            {
                result = 1, fn = "sc_applyexittable", cc = 0
            };

            switch (_data.gameid)
            {
            case 42:
                BullFight100Room _bfroom = BullFight100Lobby.instance.GetRoomByRoomID(_data.levelid);
                if (_bfroom != null)
                {
                    BullFight100Table _bftable = _bfroom.GetTableByTableID(_data.tableid);
                    if (_bftable != null)
                    {
                        lock (_bftable)
                        {
                            _bftable.ApplyExitTable(_user.UserID);
                        }
                    }
                }
                break;

            case 41:
                ////BullColorRoom _bfcroom = BullColorLobby.instance.GetRoomByRoomID(_data.levelid);
                ////if (_bfcroom != null)
                ////{
                ////    BullColorTable _bftable = _bfcroom.GetTableByTableID(_data.tableid);
                ////    if (_bftable != null)
                ////    {
                ////        lock (_bftable)
                ////        {
                ////            _bftable.ApplyExitTable(_user.UserID);
                ////        }
                ////    }
                ////}
                break;

            default:
                break;
            }

            return(JsonUtils.Serialize(_senddata));
        }
Пример #7
0
        /// <summary>
        /// 进入房间 返回现在等待用户数
        /// </summary>
        /// <returns></returns>
        public static void ExitRoomByDisConnect(int userid)
        {
            UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(userid);

            if (_us == null)
            {
                return;
            }
            if (_us.Status == UserStatusEnum.InTableDaiPai || _us.Status == UserStatusEnum.InTableWaiting)
            {
                _us.Status = UserStatusEnum.InTableDaiPaiDis;
                switch (_us.Gameid)
                {
                case 42:
                    _us.Status = UserStatusEnum.InLobby;
                    BullFight100Room _bfroom = BullFight100Lobby.instance.GetRoomByRoomID(_us.RoomID);
                    if (_bfroom == null)
                    {
                        return;
                    }
                    BullFight100Table _bftable = _bfroom.GetTableByTableID(_us.TableID);
                    if (_bftable == null)
                    {
                        return;
                    }
                    lock (_bftable)
                    {
                        _bftable.NotifyDis(userid);
                    }
                    break;

                case 20:
                    ////LandLordRoom _llroom = LandLordLobby.instance.GetRoomByRoomID(_us.RoomID);
                    ////if (_llroom == null) return;
                    ////LandLordTable _lltable = _llroom.GetTableByTableID(_us.TableID);
                    ////if (_lltable == null) return;
                    ////_lltable.NotifyDis(userid);
                    break;

                default:
                    break;
                }
            }
        }
Пример #8
0
        /// <summary>
        /// 自动分配人 到一桌  1.玩家进入房间触发。 分配机器人也在这儿处理
        /// </summary>
        /// <returns></returns>
        private void AutoAlloc2TableByRobot(BullFight100Table _bftable)
        {
            lock (objLock)
            {
                if (!_openRobot)
                {
                    return;
                }

                //一次性分配足额机器人
                int _needCount = _bftable._num_min - _bftable._pos2userbase.Count;//一般最多为2人
                if (BF100SendDataServer.instance.QueRobotUser.Count < _needCount)
                {
                    return;
                }
                for (int i = 0; i < _needCount; i++)
                {
                    tb_User tbRobotuser;
                    if (!BF100SendDataServer.instance.QueRobotUser.TryDequeue(out tbRobotuser))
                    {
                        return;
                    }
                    //把tbuser 机器在的金币限制在当前Level内,,,
                    if (tbRobotuser.UserMoney < _currRoomInfo._min || tbRobotuser.UserMoney > _currRoomInfo._max)
                    {
                        if (tbRobotuser.isRobot == 1)
                        {
                            var temp    = tbRobotuser.UserMoney;
                            var raMoney = ToolsEx.GetRandomSys(_currRoomInfo._min, _currRoomInfo._max);
                            tbRobotuser.UserMoney = raMoney;
                            ////var cacheUserSet = new ShareCacheStruct<tb_User>();  //100MS会自动存库
                            ////cacheUserSet.AddOrUpdate(tbuser);
                        }
                    }

                    BullFight100User tempU = new BullFight100User();
                    tempU.Initi(tbRobotuser.UserID + "", mRoomID, tbRobotuser, true);// 当成客户端 的IP:Port用
                    base.EnterRoomBase(tbRobotuser.UserID, _gameid);
                    _bftable.AllocationtoTable(tempU);
                    BF100SendDataServer.instance.RobotExistNumAddOne();
                }
            }
        }
Пример #9
0
        /// <summary>
        /// 返回 断线重连消息
        /// </summary>
        /// <returns></returns>
        public string ReEnterRoom(tb_User _tempuser, cs_reenterroom _data)
        {
            //自动找到gameid,levelid,tableid;
            UserStatus     _curStatus = BaseLobby.instanceBase.GetUserStatusbyUserID(_tempuser.UserID);
            sc_reenterroom _senddata  = new sc_reenterroom()
            {
                result = 0, fn = "sc_reenterroom"
            };

            if (_curStatus != null)
            {
                if (_curStatus.Gameid == 42)
                {
                    BullFight100Table _bftable = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_curStatus.RoomID, _curStatus.TableID);
                    if (_bftable != null)
                    {
                        lock (_bftable)
                        {
                            _senddata.result              = 1;
                            _senddata.gameid              = _curStatus.Gameid;
                            _senddata.levelid             = _curStatus.RoomID;
                            _senddata.tableid             = _curStatus.TableID;
                            _senddata._tableEnterSendData = _bftable.GetEnterDisList(_tempuser.UserID);
                            _senddata._tableSendData      = _bftable.GetDisList(_tempuser.UserID);
                            _senddata._pos2Gold           = _bftable._judge.GetCurrentPosGold();
                            _senddata._numpertable        = _bftable._numpertable;
                            _senddata._isStarted          = _bftable._haveCheckRoomCard;
                            _senddata.gametype            = _bftable._judge._gametype;
                            _senddata.gameModel           = _bftable._judge._gameCoin2Room1;
                            _bftable.NotifyReConnect(_tempuser.UserID);
                        }
                    }
                    else
                    {
                        _curStatus.Status = UserStatusEnum.InLobby;
                        BaseLobby.instanceBase.AddorUpdateUserStatus(_curStatus);
                    }
                }
            }

            return(JsonUtils.Serialize(_senddata));
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private string EnterTableAdd(tb_User _user, cs_entertable_bf100 _data)
        {
            sc_entertable_bf100 _senddata = new sc_entertable_bf100()
            {
                result = 0, fn = "sc_entertable_bf100", cc = 0
            };

            BullFight100Table table = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_data.levelid, _data.tableid);

            if (table == null)
            {
                return(JsonUtils.Serialize(_senddata));
            }
            bool _succes = table.EnterTableAdditive(_user);

            _senddata.result = _succes?1:0;
            string _redata = JsonUtils.Serialize(_senddata);

            table.AddSendDataRecord(_user.UserID, _redata);
            return(_redata);
        }
Пример #11
0
        /// <summary>
        /// 下注一次,只有升庄牛牛才会有的
        /// </summary>
        /// <returns></returns>
        private string GambleOne(tb_User _user, cs_gambleone_bf100 _data)
        {
            sc_gambleone_bf100 _senddata = new sc_gambleone_bf100()
            {
                result = 0, fn = "sc_gambleone_bf100", cc = 0
            };

            BullFight100Table table = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_data.levelid, _data.tableid);

            if (table == null)
            {
                return(JsonUtils.Serialize(_senddata));
            }
            if (table.GambleOne(_user.UserID, _data.targetpos, _data.gamble))
            {
                _senddata.result = 1;
            }
            string _redata = JsonUtils.Serialize(_senddata);

            table.AddSendDataRecord(_user.UserID, _redata);
            return(_redata);
        }
Пример #12
0
        /// <summary>
        /// 自动分配人 到一桌  1.玩家进入房间触发。
        /// </summary>
        /// <returns></returns>
        private void AutoAlloc2TableForHuman(BullFight100Table _bftable, BullFight100User tempU)
        {
            lock (objLock)
            {
                if (!_openRobot)
                {
                    return;
                }

                if (_bftable._judge._gameCoin2Room1 == 1)
                {
                    return;                                      //房卡模式不能进机器人了
                }
                base.EnterRoomBase(tempU._tbUser.UserID, _gameid);

                //移出已经分配了的用户
                BullFight100User temp02 = null;// new BullFightUser();
                DicUser.TryRemove(tempU._userid, out temp02);
                _bftable.AllocationtoTable(tempU);
                BF100SendDataServer.instance.RobotExistNumAddOne();
            }
        }
Пример #13
0
        /// <summary>
        /// 进入房间 返回现在等待用户数
        /// </summary>
        /// <returns></returns>
        private string BankerGetBonusPot(tb_User _user, cs_bankergetbonuspot_bf100 _data)
        {
            sc_bankergetbonuspot_bf100 _senddata = new sc_bankergetbonuspot_bf100()
            {
                result = 0, fn = "sc_bankergetbonuspot_bf100", cc = 0
            };

            BullFight100Table table = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_data.levelid, _data.tableid);

            if (table == null)
            {
                return(JsonUtils.Serialize(_senddata));
            }
            if (table.BankerGetBonusPot(_user.UserID))
            {
                _senddata.result = 1;
            }
            string _redata = JsonUtils.Serialize(_senddata);

            table.AddSendDataRecord(_user.UserID, _redata);
            return(_redata);
        }
Пример #14
0
        public void SetNotifyReConnect(int userid)
        {
            UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(userid);

            if (_us == null)
            {
                return;
            }
            if (_us.TableID == 0)
            {
                return;
            }

            if (_us.Gameid == 42)
            {   //如果 在房间里,打牌需要处理状态
                BullFight100Table _bftable = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                if (_bftable == null)
                {
                    return;
                }
                _bftable.NotifyReConnect(userid);
            }
        }
Пример #15
0
        /// <summary>
        /// 摹仿客户端 消息处理  不加锁
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="strMSG"></param>
        private static void RobotDealMSG(int UserID, string strMSG)
        {
            UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(UserID);

            if (_us == null)
            {
                ErrorRecord.Record(" 201611301728BF " + UserID);
                return;
            }
            if (_us.Status == UserStatusEnum.InLobby)
            {
                return;                                      //一局结算了,收到的消息需要处理,也处理不了,Table已释放
            }
            BullFight100User myu = BullFight100Lobby.instance.GetUserByRoomIDandTableIDandUserID(_us.RoomID, _us.TableID, UserID);

            if (myu == null)
            {
                ErrorRecord.Record(" 201611301729BF " + UserID + ",_us.Status:" + _us.Status + " strMSG:" + strMSG);
                return;
            }
            sc_base _csdata = JsonUtils.Deserialize <sc_base>(strMSG);

            if (_csdata == null)
            {
                ErrorRecord.Record(" 201206062216BF " + UserID);
                return;
            }

            switch (_csdata.fn)
            {
            case "sc_entertable_n":     //自动 准备
                //Thread.Sleep(900);
                break;

            case "sc_tablestart_bf100_n":
                break;

            case "sc_applybanker_bf100_n":      //如果 自己是庄,需要执行庄下注
                int _waittimeStart = ToolsEx.GetRandomSys(600, 3000);
                Thread.Sleep(_waittimeStart);
                sc_tablestart_bf100_n _tablestart = JsonUtils.Deserialize <sc_tablestart_bf100_n>(strMSG);
                BullFight100Table     myt         = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                if (myt != null)
                {
                    lock (myt)
                    {
                        myt.GambleOne(myu._userid, 2, 10);     //下注
                    }
                }
                break;

            case "sc_getbankerone_bf_n":      //客户端显示 OK手势
                break;

            case "sc_gambleone_bf100_n":
                break;

            case "sc_end_bf100_n":
                sc_end_bf100_n _showdown = JsonUtils.Deserialize <sc_end_bf100_n>(strMSG);
                if (_showdown._OverTable == 1 || _showdown.gamemodel == 2)
                {
                    return;                                                           //OVer了
                }
                BullFight100Table _myt_showdown = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                BullFight100Table myt0014       = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                if (myt0014 != null && myt0014._judge._gameCoin2Room1 == 1)
                {
                }
                break;

            case "cs_bankergetbonuspot_bf100":     //有人下庄了

                break;

            case "sc_applyexittable_n":    //AI 都同意所有游戏解散
                Thread.Sleep(550);
                sc_applyexittable_n _applyExit      = JsonUtils.Deserialize <sc_applyexittable_n>(strMSG);
                BullFight100Table   _applyexitTable = BullFight100Lobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                if (_applyexitTable != null)
                {
                    lock (_applyexitTable)
                    {
                        _applyexitTable.DealExitTable(myu._userid, true);
                    }
                }
                break;

            case "sc_showdown_bf100_n": break;

            case "sc_dealexittable_n": break;

            case "sc_one_exittable_n": break;

            case "sc_exittable_n":    //AI 在有人退出的情况下,全都退出

                break;

            case "sc_chat_n": break;

            case "sc_disconnect_n": break;

            case "sc_warning_n": break;

            default:
                ErrorRecord.Record("201206190957BF AI 未处理,strSID:" + _csdata.fn);
                break;
            }
        }
Пример #16
0
 public BullFight100Judge(BullFight100Table myTable)
 {
     _myTable     = myTable;
     DicPosToType = new ConcurrentDictionary <int, int>();
 }
Пример #17
0
        /// <summary>
        /// 执行指令 格式 "001|1,2,3"
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public string DoExecCmd(string address, string json)
        {
            TraceLog.WriteInfo("{0}执行指令:{1}", address, json);
            cs_base_gm _basegm = null;

            try
            {
                _basegm = JsonUtils.Deserialize <cs_base_gm>(json);
            }
            catch (Exception ex)
            {
                return("0");
            }
            string errorCode = "0";

            switch (_basegm.fn)
            {
            case "0001":    //通知所有玩家 ?CMD=0001|玩家1524879,获得了以排行榜一等级奖!
                //sc_getnotice_n _getnotice = new sc_getnotice_n() { result = 1, fn = "_getnotice", noticelist = new List<string>() };
                //_getnotice.noticelist.Add(cmds[1]);
                //BaseSendDataServer.AutoNotifySendData(JsonUtils.Serialize((_getnotice)));
                errorCode = "1";
                break;

            case "0002":    //踢出游戏 ?CMD=0002|1524879

                errorCode = "1";
                break;

            case "0003":    //充值 ?CMD=0002|1524879|5000


                //int userId = 0;
                //int diamond = 0;
                //if(int.TryParse(cmds[1],out userId) && int.TryParse(cmds[2],out diamond))
                //{
                //    var user = tb_UserEx.GetFromCachebyUserID(userId);
                //    if(user != null)
                //    {
                //        user.ModifyLocked(() =>
                //            {
                //                user.diamond += diamond;
                //            });
                //    }
                //    errorCode = "1";
                //}
                break;

            case "0004":    //设置指定玩家的当前分数     ?CMD=0004|1380162|99     http://127.0.0.1:8080/Service/?CMD=0004|2000001|-9999|4
                //if (cmds.Length != 4) break;
                //int _userId004 = 0;
                //int _money = 0;
                //int _gameid = 0;
                //if (int.TryParse(cmds[1], out _userId004) && int.TryParse(cmds[2], out _money) && int.TryParse(cmds[3], out _gameid))
                //{
                //    if (_gameid == BullFightLobby.instance.Gameid)
                //    {
                //        //只修改内存数据,不做持久化
                //        UserStatus _us = BullFightLobby.instance.GetUserStatusbyUserID(_userId004);
                //        if (_us == null) break;
                //        BullFightTable _bftable = BullFightLobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                //        if (_bftable == null) break;


                //        BullFightUser _bfuser = _bftable.GetUserByID(_userId004);
                //        if (_bfuser == null) break;
                //        _bfuser._moneyaddorreduce = _money;
                //        //_bfuser.UpdateMoney(99);            被覆盖了,无效
                //        errorCode = "1";
                //    }
                //    else if (_gameid == LandLordLobby.instance.Gameid)
                //    {   //只修改内存数据,不做持久化
                //        UserStatus _us = LandLordLobby.instance.GetUserStatusbyUserID(_userId004);
                //        if (_us == null) break;
                //        LandLordTable _bftable = LandLordLobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                //        if (_bftable == null) break;


                //        LandLordUser _bfuser = _bftable.GetUserByID(_userId004);
                //        if (_bfuser == null) break;
                //        _bfuser._moneyaddorreduce = _money;
                //        //_bfuser.UpdateMoney(99);            被覆盖了,无效
                //        errorCode = "1";
                //    }
                //}
                break;

            case "0005":    //设置指定玩家申请解散游戏     ?CMD=0005|1380162     http://127.0.0.1:8080/Service/?CMD=0004|2000001|4
                //if (cmds.Length != 3) break;
                //int _userId005 = 0;
                //int _gamedi5 = 0;
                //if (int.TryParse(cmds[1], out _userId005) && int.TryParse(cmds[2], out _gamedi5))
                //{
                //    if (_gamedi5 == BullFightLobby.instance.Gameid)
                //    {
                //        //只修改内存数据,不做持久化
                //        UserStatus _us = BullFightLobby.instance.GetUserStatusbyUserID(_userId005);
                //        if (_us == null) break;
                //        BullFightTable _bftable = BullFightLobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                //        if (_bftable == null) break;
                //        _bftable.ApplyExitTable(_userId005);

                //        //_bfuser.UpdateMoney(99);            被覆盖了,无效
                //        errorCode = "1";
                //    }
                //    else if (_gamedi5 == LandLordLobby.instance.Gameid)
                //    {
                //        //只修改内存数据,不做持久化
                //        UserStatus _us = LandLordLobby.instance.GetUserStatusbyUserID(_userId005);
                //        if (_us == null) break;
                //        LandLordTable _bftable = LandLordLobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                //        if (_bftable == null) break;
                //        _bftable.ApplyExitTable(_userId005);

                //        //_bfuser.UpdateMoney(99);            被覆盖了,无效
                //        errorCode = "1";
                //    }
                //    }
                break;

            case "cs_setcard_ll_gm":    //设置指定玩家牌型最小    ?CMD=1001|1380162     http://127.0.0.1:8080/Service/?CMD=cs_setcard_ll_gm|1380162|4
                cs_setcard_ll_gm _setcard = JsonUtils.Deserialize <cs_setcard_ll_gm>(json);
                if (_setcard != null)
                {
                    int _userId1001             = _setcard.userid;
                    int _gameid1001             = _setcard.gameid;
                    sc_setcard_ll_gm _scSetcard = new sc_setcard_ll_gm()
                    {
                        fn = "sc_setcard_ll_gm", _good = true, _info = "", _ret = 1
                    };
                    if (_gameid1001 == BullFight100Lobby.instance.Gameid)
                    {
                        //只修改内存数据,不做持久化
                        UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(_userId1001);
                        if (_us != null)
                        {
                            BullFight100Table _bftable = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                            if (_bftable != null)
                            {
                                ////_bftable.ForeashAllDo((i) =>
                                ////{
                                ////    if (_bftable._DicPos2User[i]._userid == _userId1001)
                                ////    {
                                ////        _bftable._DicPos2User[i]._shouPaiArr = new List<int>() { 103, 103, 202, 203, 201 };
                                ////    }
                                ////});
                                _scSetcard._ret = 0;
                            }
                        }
                    }
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_settb_user_gm":
                cs_settb_user_gm _settb_user = JsonUtils.Deserialize <cs_settb_user_gm>(json);
                if (_settb_user != null)
                {
                    tb_User _user = JsonUtils.Deserialize <tb_User>(_settb_user._userjson);
                    tb_UserEx.UpdateData(_user);
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_settb_user_gm", _info = "", _ret = 0
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_settb_user_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_setuserdes_gm":
                cs_setuserdes_gm _setuserinfo = JsonUtils.Deserialize <cs_setuserdes_gm>(json);
                if (_setuserinfo != null)
                {
                    int        _userId1001 = _setuserinfo.userid;
                    sc_base_gm _scResult   = new sc_base_gm()
                    {
                        fn = "cs_setuserdes_gm", _info = "", _ret = 0
                    };
                    tb_User _user = tb_UserEx.GetFromCachebyUserID(_userId1001);
                    if (_user != null)
                    {
                        if (_user.wechatName != _setuserinfo.webname ||
                            _user.wechatHeadIcon != _setuserinfo.headinfo || _user.AgentId != Convert.ToInt32(_setuserinfo.AgentId))
                        {
                            _user.wechatName     = _setuserinfo.webname;
                            _user.wechatHeadIcon = _setuserinfo.headinfo;
                            _user.AgentId        = Convert.ToInt32(_setuserinfo.AgentId);
                            tb_UserEx.UpdateData(_user);
                        }
                        else
                        {
                            _scResult._ret  = 1;
                            _scResult._info = "无需重新设置";
                        }
                    }
                    else
                    {
                        _scResult._ret  = 1;
                        _scResult._info = "会员不存在";
                    }
                    errorCode = JsonUtils.Serialize(_scResult);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_setuserdes_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_setagent_ll_gm":    //设置代理
                cs_setagent_ll_gm _setagent = JsonUtils.Deserialize <cs_setagent_ll_gm>(json);
                if (_setagent != null)
                {
                    int        _userId1001 = _setagent.userid;
                    sc_base_gm _scResult   = new sc_base_gm()
                    {
                        fn = "sc_setagent_ll_gm", _info = "", _ret = 0
                    };
                    tb_User _user = tb_UserEx.GetFromCachebyUserID(_userId1001);
                    if (_user != null)
                    {
                        if (_user.isagent != _setagent.agentid)
                        {
                            _user.isagent = _setagent.agentid;
                            tb_UserEx.UpdateData(_user);
                        }
                        else
                        {
                            _scResult._ret  = 1;
                            _scResult._info = "无需重新设置";
                        }
                    }
                    else
                    {
                        _scResult._ret  = 1;
                        _scResult._info = "会员不存在";
                    }
                    errorCode = JsonUtils.Serialize(_scResult);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_setagent_ll_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_setrobot_gm":    //设置机器人
                cs_setrobot_gm _setrobot = JsonUtils.Deserialize <cs_setrobot_gm>(json);
                if (_setrobot != null)
                {
                    int        _userId1001 = _setrobot.userid;
                    sc_base_gm _scResult   = new sc_base_gm()
                    {
                        fn = "sc_setagent_ll_gm", _info = "", _ret = 0
                    };
                    tb_User _user = tb_UserEx.GetFromCachebyUserID(_userId1001);
                    if (_user != null)
                    {
                        if (_user.isRobot != _setrobot.isrobot ||
                            _user.winpercent != _setrobot.winpercent ||
                            _user.RobotLevel != _setrobot.robotlevel)
                        {
                            _user.isRobot    = _setrobot.isrobot;
                            _user.RobotLevel = _setrobot.robotlevel;
                            _user.winpercent = _setrobot.winpercent;
                            tb_UserEx.UpdateData(_user);
                        }
                        else
                        {
                            _scResult._ret  = 1;
                            _scResult._info = "无需重新设置";
                        }
                    }
                    else
                    {
                        _scResult._ret  = 1;
                        _scResult._info = "会员不存在";
                    }
                    errorCode = JsonUtils.Serialize(_scResult);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_setagent_ll_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_setlocktime_gm":    //锁定账号
                cs_setlocktime_gm _setlocktime = JsonUtils.Deserialize <cs_setlocktime_gm>(json);
                if (_setlocktime != null)
                {
                    int        _userId1001 = _setlocktime.userid;
                    sc_base_gm _scResult   = new sc_base_gm()
                    {
                        fn = "sc_setagent_ll_gm", _info = "", _ret = 0
                    };
                    tb_User _user = tb_UserEx.GetFromCachebyUserID(_userId1001);
                    if (_user != null)
                    {
                        _user.lockTime = _setlocktime.locktime;
                        tb_UserEx.UpdateData(_user);
                    }
                    else
                    {
                        _scResult._ret  = 1;
                        _scResult._info = "会员不存在";
                    }
                    errorCode = JsonUtils.Serialize(_scResult);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_setlocktime_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_charge_gm":    //修改充值金额或钻石
                cs_charge_gm _charge = JsonUtils.Deserialize <cs_charge_gm>(json);
                if (_charge != null)
                {
                    sc_charge_gm _scResult = new sc_charge_gm()
                    {
                        fn = "sc_charge_gm", _info = "", _ret = 0, UserMoney = 0
                    };
                    tb_User _user = tb_UserEx.GetFromCachebyUserID(_charge.userid);
                    if (_user != null)
                    {
                        if (_charge.type == 1)
                        {
                            _scResult.UserMoney = _user.UserMoney;
                            _user.UserMoney    += (decimal)_charge.money;
                            _user.TotalMoney   += (decimal)_charge.money;
                        }
                        else
                        {
                            _scResult.UserMoney = (decimal)_user.diamond;
                            _user.diamond      += _charge.money;
                            _user.totaldiamond += (decimal)_charge.money;
                        }
                        tb_UserEx.UpdateData(_user);
                    }
                    else
                    {
                        _scResult._ret  = 1;
                        _scResult._info = "会员不存在";
                    }
                    errorCode = JsonUtils.Serialize(_scResult);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "sc_charge_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_setNotice_gm":
                cs_setnotice_gm _setnotice = JsonUtils.Deserialize <cs_setnotice_gm>(json);
                if (_setnotice != null)
                {
                    //播放消息还没做好  BullFightLobby.SendChat(_user.UserID, gm);
                }
                break;

            case "cs_applyexittable_gm":        //tick somebody
                cs_applyexittable_gm _applyexit = JsonUtils.Deserialize <cs_applyexittable_gm>(json);
                if (_applyexit != null)
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "sc_base_gm", _info = "", _ret = 0
                    };

                    if (_applyexit.gameid == BullFight100Lobby.instance.Gameid)
                    {
                        //只修改内存数据,不做持久化
                        UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(_applyexit.userid);
                        if (_us != null)
                        {
                            BullFight100Table _bftable = BullFight100Lobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
                            if (_bftable != null)
                            {
                                _bftable.ApplyExitTable(_applyexit.userid);
                            }
                            _scSetcard._ret = 1;
                        }
                    }

                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                else
                {
                    sc_base_gm _scSetcard = new sc_base_gm()
                    {
                        fn = "cs_applyexittable_gm", _info = "参数错误", _ret = 1
                    };
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_createtable_gm":
                ////cs_createtable_gm _createtable = JsonUtils.Deserialize<cs_createtable_gm>(json);
                ////if (_createtable != null)
                ////{
                ////    sc_base_gm _scSetcard = new sc_base_gm() { fn = "sc_base_gm", _info = "", _ret = 0 };

                ////    if (_createtable.gameid == BullFightLobby.instance.Gameid)
                ////    {
                ////        cs_enterroom _enterroomdata = new cs_enterroom();
                ////        _enterroomdata.gameid = _createtable.gameid;   //暂时写固定
                ////        _enterroomdata.levelid = 1;   //暂时写固定
                ////        _enterroomdata.gametype = 1;
                ////        _enterroomdata.baseallmoney = 10000;
                ////        _enterroomdata.numpertable = 4;
                ////        _enterroomdata.roomcard = 2;
                ////        _enterroomdata.tableCount = 3;
                ////        _enterroomdata.rankertype = 2;

                ////    }
                ////    errorCode = JsonUtils.Serialize(_scSetcard);
                ////}
                break;
            //case "cs_getonlinecount_gm":
            //    ////cs_getonlinecount_gm _getonline = JsonUtils.Deserialize<cs_getonlinecount_gm>(json);
            //    ////if (_getonline != null)
            //    ////{
            //    ////    sc_getonlinecount_gm _scSetcard = new sc_getonlinecount_gm() { fn = "sc_getonlinecount_gm", _info = "", _ret = 0 };

            //    ////    if (_getonline.gameid == BullFightLobby.instance.Gameid)
            //    ////    {
            //    ////        //只修改内存数据,不做持久化
            //    ////        UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(_applyexit.userid);
            //    ////        if (_us != null)
            //    ////        {
            //    ////            BullFightTable _bftable = BullFightLobby.instance.GetTableByRoomIDandTableID(_us.RoomID, _us.TableID);
            //    ////            if (_bftable != null) _bftable.ApplyExitTable(_applyexit.userid);
            //    ////            _scSetcard._ret = 1;
            //    ////        }
            //    ////    }
            //    ////    else if (_applyexit.gameid == LandLordLobby.instance.Gameid)
            //    ////    {

            //    ////    }
            //    ////    errorCode = JsonUtils.Serialize(_scSetcard);
            //    ////}
            //    break;
            case "cs_enterroom_gm":
                cs_enterroom_gm _createroomtable = JsonUtils.Deserialize <cs_enterroom_gm>(json);
                if (_createroomtable != null)
                {
                    sc_enterroom_gm _scSetcard = new sc_enterroom_gm()
                    {
                        fn = "sc_enterroom_gm", _info = "", _ret = 0
                    };
                    //只修改内存数据,不做持久化
                    UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(_createroomtable.userid);
                    if (_us == null)
                    {
                        var     cacheSet  = new PersonalCacheStruct <tb_User>();
                        tb_User _tempuser = cacheSet.FindKey(_createroomtable.userid.ToString());
                        if (cacheSet.Count == 0 || _tempuser == null)
                        {
                            SchemaTable    schema   = EntitySchemaSet.Get <tb_User>();
                            DbBaseProvider provider = DbConnectionProvider.CreateDbProvider(schema);
                            DbDataFilter   filter   = new DbDataFilter(0);
                            filter.Condition = provider.FormatFilterParam("UserId");
                            filter.Parameters.Add("UserId", _createroomtable.userid);
                            cacheSet.TryRecoverFromDb(filter);                                //从数据库中恢复数据
                            ////cacheSet.TryRecoverFromDb(new DbDataFilter(0));//all
                            _tempuser = cacheSet.FindKey(_createroomtable.userid.ToString()); //
                        }
                        if (_tempuser == null)
                        {
                            ErrorRecord.Record("CommonLogic 201611051736 User数据找不到SessionUserID:" + _createroomtable.userid);
                            return("");
                        }
                        cs_enterroom _enterData = new cs_enterroom()
                        {
                            cc          = 0,
                            fn          = "cs_enterroom",
                            gameid      = _createroomtable.gameid,
                            levelid     = _createroomtable.levelid,
                            gametype    = _createroomtable.gametype,
                            numpertable = _createroomtable.numpertable,
                            rankertype  = _createroomtable.rankertype,
                            roomcard    = _createroomtable.roomcard,
                            tableCount  = _createroomtable.tableCount,
                            _userid     = _createroomtable.userid
                        };
                        CommonLogic _commonLogic = new CommonLogic();
                        _scSetcard.tablenum = _commonLogic.EnterRoom(_tempuser, _enterData);
                    }
                    errorCode = JsonUtils.Serialize(_scSetcard);
                }
                break;

            case "cs_maintain_operation":
                cs_maintain_operation data = JsonUtils.Deserialize <cs_maintain_operation>(json);
                _syncTimer.Start();
                sc_maintain_operation sedata = new sc_maintain_operation {
                    fn = "sc_maintain_operation", _ret = 1, _info = "操作成功"
                };
                int tableCount = 0;
                var brlist     = BullFight100Room.roomCache.FindAll();
                foreach (var bullfightroom in brlist)
                {
                    tableCount += bullfightroom.DicTable.Count;
                }
                sedata.tableCount = tableCount;
                errorCode         = JsonUtils.Serialize(sedata);
                break;

            case "cs_getonlinecount_gm":
                sc_getonlinecount senddata = new sc_getonlinecount {
                    fn = "sc_getonlinecount", _ret = 1, _info = "获取成功"
                };
                senddata.userCount = GameSession.Count;
                errorCode          = JsonUtils.Serialize(senddata);
                break;

            case "cs_closetable":
                cs_closetable receiveData = JsonUtils.Deserialize <cs_closetable>(json);
                // receiveData.
                sc_closetable sendData = new sc_closetable {
                    fn = "sc_closetable", _ret = 1, _info = "操作成功"
                };
                if (receiveData.userNo <= 0)
                {
                    sendData._ret  = -1;
                    sendData._info = "用户名错误";
                    errorCode      = JsonUtils.Serialize(sendData);
                    break;
                }
                var userStatus = BullFight100Lobby.instanceBase.GetUserStatusbyUserID(receiveData.userNo);
                if (userStatus == null)
                {
                    sendData._ret  = -1;
                    sendData._info = "用户不存在";
                    errorCode      = JsonUtils.Serialize(sendData);
                    break;
                }
                lock (tablelock)
                {
                    var table = BullFight100Lobby.instance.GetTableByRoomIDandTableID(userStatus.RoomID, userStatus.TableID);
                    table._gameover = true;
                }
                errorCode = JsonUtils.Serialize(sendData);
                break;

            case "cs_updatePro":    //更新机器人获胜几率
                cs_updatePro data1         = JsonUtils.Deserialize <cs_updatePro>(json);
                sc_updatePro sendUpdatePro = new sc_updatePro {
                    fn = "", _ret = 1, _info = "成功"
                };
                var cacheUser = new GameDataCacheSet <tb_User>();
                cacheUser.ReLoad();
                if (cacheUser.Count == 0)
                {
                    DbDataFilter filter = new DbDataFilter();
                    filter.Condition = "isRobot=@isRobot";
                    filter.Parameters.Add("@isRobot", 1);
                    cacheUser.TryRecoverFromDb(filter);
                }
                List <tb_User> userList = new List <tb_User>();
                var            robotId  = tb_UserEx.GetUserIdListByRobot(1);
                robotId.ForEach(d =>
                {
                    tb_User user;
                    cacheUser.TryFindKey(d.ToString(), out user);
                    if (user != null)
                    {
                        user.winpercent = data1.probability;
                        userList.Add(user);
                    }
                });
                cacheUser.AddOrUpdate(userList);
                errorCode = JsonUtils.Serialize(sendUpdatePro);
                break;

            case "cs_updateRobot":    //更新机器人头像名称信息
                cs_updateRobot robotData  = JsonUtils.Deserialize <cs_updateRobot>(json);
                var            result     = UpdateRobotImgAndName(robotData);
                sc_updateRobot sendUpdate = new sc_updateRobot {
                    fn = "", _ret = 1
                };
                sendUpdate._ret = result ? 1 : -1;
                errorCode       = JsonUtils.Serialize(sendUpdate);
                break;

            case "cs_gameinfo":

                sc_gameInfo sendgameinfo = new sc_gameInfo {
                    _ret = 1
                };
                try
                {
                    tb_gamelevelinfo gameinfo = JsonUtils.Deserialize <tb_gamelevelinfo>(json);
                    var gameCache             = new ShareCacheStruct <tb_gamelevelinfo>();
                    gameCache.AddOrUpdate(gameinfo);
                }
                catch (Exception)
                {
                    sendgameinfo._ret = -1;
                }
                errorCode = JsonUtils.Serialize(sendgameinfo);
                break;
            }
            return(errorCode);
        }