/// <summary>
        /// 非房主进入桌子 房间模式的
        /// </summary>
        /// <param name="userid"></param>
        public bool EnterTableAdditive(tb_User tbUser)
        {
            //不限制客户端的个数 可能 有破坏的外挂===========
            if (_numpertable >= _num_max)
            {
                return(false);
            }
            BullFight100User myu = new BullFight100User();

            myu.Initi(tbUser.IP, _roomid, tbUser, false);// 当成客户端 的IP:Port用
            AllocationtoTable(myu);
            return(true);
        }
Example #2
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);
            }
        }
Example #3
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();
                }
            }
        }
Example #4
0
        /// <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);
                }
                base.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);
                    }
                }
                BullFight100User tempU = new BullFight100User();
                tempU.Initi(ipport, mRoomID, tbuser, false);// 当成客户端 的IP:Port用

                ////if (!DicUser.TryAdd(UserID, tempU)) ErrorRecord.Record("201208241155BF 已经存在ROOM内了, 添加不成功 逻辑需要处理");
                if (!DicUser.ContainsKey(UserID))
                {
                    DicUser.TryAdd(UserID, tempU);
                }

                return(DicUser.Count);//直接进入 空桌子
            }
        }