Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="UserID"></param>
        /// <returns></returns>
        public BullColorUser GetUserByRoomIDandTableIDandUserID(int RoomID, int TableID, int UserID)
        {
            BullColorTable _bftable = GetTableByRoomIDandTableID(RoomID, TableID);

            if (_bftable == null)
            {
                ErrorRecord.Record("21020726151103 RoomID:" + RoomID + ",  TableID:" + TableID + ",  UserID:" + UserID);
                return(null);
            }
            lock (_bftable)
            {
                return(_bftable.GetUserByID(UserID));
            }
        }
        private void AddOnlineInformation(object state)
        {
            var bll_online = new BLL_OnlineInformation();

            lock (_objLock)
            {
                try
                {
                    var data      = new List <tb_OnlineInformation>();
                    var _roomlist = BullColorRoom.roomCache.FindAll();
                    foreach (var _tempbfroom in _roomlist)
                    {
                        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();
                            BullColorTable _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.RoomId,
                                OnlineCount = userCount,
                                GameType    = _tempbfroom._currRoomInfo.gametype
                            });
                        }
                    }
                    bll_online.AddRange(data);
                }
                catch (Exception ex)
                {
                    ErrorRecord.Record(new Exception(), ex.Message);
                }
            }
        }
Beispiel #3
0
        public bool SendChat(int userid, cs_chat chat)
        {
            BullColorTable _bftable = GetTableByRoomIDandTableID(chat.levelid, chat.tableid);

            if (_bftable != null)
            {
                lock (_bftable)
                {
                    _bftable.SendChatBase(userid, chat.content, chat.type);
                }
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 自动2000000 机器人创建一个桌子唯一桌子,系统奖池也是用的这个ID
        /// </summary>
        /// <returns></returns>
        public int CreateTableByRobot( )
        {
            lock (objLock)
            {
                if (GMService.isStop)
                {
                    return(0);
                }
                BullColorRoom roomData;
                roomCache.TryGet(RoomId + "", 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, BullColorUser>();
                    return(0);
                }
                tb_User tbuser = tb_UserEx.GetFromCachebyUserID(2000000);
                if (tbuser == null)
                {
                    ErrorRecord.Record("没有特殊机器人了系 统不能开始牛牛时时彩");
                    return(0);
                }

                BullColorUser tempU = new BullColorUser();
                tempU.Initi(tbuser.UserID + "", RoomId, tbuser, true);              // 当成客户端 的IP:Port用
                roomData.EnterRoomBase(tempU._tbUser.UserID, _currRoomInfo.gameid); //处理状态的,不然一直找不到用户
                cs_enterroom _data = new cs_enterroom()
                {
                    baserate = _currRoomInfo.Baserate, gametype = _currRoomInfo.gametype, gameid = 4, gamemodel = 2, levelid = RoomId, numpertable = 500, roomcard = 0, rankertype = 1, tableCount = 1
                };
                List <BullColorUser> _tempfirstUser = new List <BullColorUser>();
                _tempfirstUser.Add(tempU);

                BullColorTable tab = new BullColorTable(_currRoomInfo.gameid, this, _tid, _tempfirstUser, _data);
                //添加到当前桌子列表,以便打牌过程好使用
                if (!DicTable.TryAdd(_tid, tab))
                {
                    ErrorRecord.Record("add _tableid fial maybe have exist... 201208241601BF");
                }
                return(_tid);
            }
        }
        /// <summary>
        ///  用户登录房间时调用
        /// </summary>
        /// <param name="roomID"></param>
        /// <param name="UserID"></param>
        /// <param name="ipport"></param>
        /// <returns></returns>
        public int EnterRoom(cs_enterroom _data, int UserID, string ipport)
        {
            lock (objLock)
            {
                if (GMService.isStop)
                {
                    return(-99);
                }
                BullColorRoom roomData;
                if (!roomCache.TryGet(RoomId + "", out roomData))
                {
                    return(-99);
                }

                roomData.EnterRoomBase(UserID, _data.gameid);
                tb_User tbuser = tb_UserEx.GetFromCachebyUserID(UserID);
                if (tbuser == null)
                {
                    ErrorRecord.Record("201208241558BF tbuser == null  userID:" + UserID);
                    return(0);
                }

                if (tbuser.UserMoney > _currRoomInfo._max || tbuser.UserMoney < _currRoomInfo._min)
                {
                    return(-99);
                }

                UserStatus _us = BaseLobby.instanceBase.GetUserStatusbyUserID(UserID);
                if (_us != null)
                {
                    if (_us.Status == UserStatusEnum.InTableDaiPai || _us.Status == UserStatusEnum.InTableDaiPaiDis || _us.Status == UserStatusEnum.InTableWaiting)
                    {
                        return(-1);
                    }
                }
                BullColorUser tempU = new BullColorUser();
                tempU.Initi(ipport, RoomId, tbuser, false);// 当成客户端 的IP:Port用

                if (!DicUser.TryAdd(UserID, tempU))
                {
                    ErrorRecord.Record("201208241155BF 已经存在ROOM内了, 添加不成功 逻辑需要处理");
                }
                BullColorTable _findtable = GetEmptyPosTable();
                if (_findtable != null)
                {
                    return(DicUser.Count); //直接进入 空桌子
                }
                return(DicUser.Count);     //金币模式 等5秒再一起分配
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private string EnterTableAdd(tb_User _user, cs_entertable_bfc _data)
        {
            sc_entertable_bfc _senddata = new sc_entertable_bfc()
            {
                result = 0, fn = "sc_entertable_bf", cc = 0
            };

            BullColorTable table = BullColorLobby.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);
        }
        /// <summary>
        /// 下注一次,只有升庄牛牛才会有的
        /// </summary>
        /// <returns></returns>
        private string GambleOne(tb_User _user, cs_gambleone_bfc _data)
        {
            sc_gambleone_bfc _senddata = new sc_gambleone_bfc()
            {
                result = 0, fn = "sc_gambleone_bfc", cc = 0
            };

            BullColorTable table = BullColorLobby.instance.GetTableByRoomIDandTableID(_data.levelid, _data.tableid);

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

            table.AddSendDataRecord(_user.UserID, _redata);
            return(_redata);
        }
 public BullColorJudge(BullColorTable myTable)
 {
     _myTable     = myTable;
     DicPosToType = new ConcurrentDictionary <int, int>();
 }
Beispiel #9
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已释放
            }
            BullColorUser myu = BullColorLobby.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;
            }
            int _waittime3000 = 4000;

            switch (_csdata.fn)
            {
            case "sc_entertable_n":     //自动 准备
                //Thread.Sleep(900);
                sc_entertable_n _entertable = JsonUtils.Deserialize <sc_entertable_n>(strMSG);
                BullColorTable  myt001      = BullColorLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);
                if (myt001 != null && myu._Pos == _entertable.pos)
                {
                    //// myt001.GetReady(myu._userid); //  自己的进房间通知才准备
                }
                break;

            case "sc_ready_bf_n":     //
                break;

            case "sc_tablestart_bf_n":
                int _waittimeStart = ToolsEx.GetRandomSys(600, 3000);
                Thread.Sleep(_waittimeStart);
                sc_tablestart_bfc_n _tablestart = JsonUtils.Deserialize <sc_tablestart_bfc_n>(strMSG);
                BullColorTable      myt         = BullColorLobby.instance.GetTableByRoomIDandTableID(myu._roomid, myu._tableID);

                //根据需求判断 是否抢庄
                if (myt != null && !_tablestart.closefun && _tablestart._canGetBanker)
                {
                }
                break;

            case "sc_gambleone_bfc_n":
                break;

            case "sc_setbulltype_bfc_n":         //无AI处理 直接等待摊牌

                break;

            case "sc_showone_bfc_n": break;

            case "sc_showdown_bfc_n":
                //Thread.Sleep(410);
                break;

            case "sc_end_bfc_n":
                break;

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

            case "sc_dealexittable_n": break;

            case "sc_one_exittable_n": break;

            case "sc_exittable_n":    //AI 在有人退出的情况下,全都退出
                ////sc_exittable  _exittable = JsonUtils.Deserialize<sc_exittable>(strMSG);
                ////Thread.Sleep(10);
                ////BullFightUser myu_exit;
                ////DicIDtoUser.TryGetValue(UserID, out myu_exit);
                ////if (_exittable.pos != myu_exit._Pos)
                ////{   //自己的退出消息不再处理  但是只能处理一次
                ////    ////BullColorTable mytexit = BullColorLobby.GetTableByRoomIDandTableID(myu_exit._roomid, _exittable.tableid);
                ////    ////if (mytexit != null) mytexit.ExitTable(myu_exit._userid); //
                ////}
                break;

            case "sc_chat_n": break;

            case "sc_disconnect_n": break;

            case "sc_warning_n": break;

            case "020":      //此桌结束了,正常结束
                break;

            default:
                ErrorRecord.Record("201206190957BF AI 未处理,strSID:" + _csdata.fn);
                break;
            }
        }