Exemplo n.º 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));
        }
        /// <summary>
        ///
        /// 进入2~6人后处理的
        /// </summary>
        /// <param name="tablenum"></param>
        /// <param name="userList"></param>
        public BullFight100Table(int gameid, BaseRoom _room2, int tablenum, BullFight100User _firstUser, cs_enterroom _data)
        {
            _numpertable = 1;
            _roomid      = _room2.mRoomID;
            _room        = _room2 as BullFight100Room;
            _tableid     = tablenum;
            _baseMoney   = 1;
            _bankpos     = 1;
            if (_DicPos2User == null)
            {
                _DicPos2User = new ConcurrentDictionary <int, BullFight100User>();
            }
            ConcurrentDictionary <int, BaseUser> _temppos2user = new ConcurrentDictionary <int, BaseUser>();

            _quePosGetBanker = new ConcurrentQueue <int>();
            _quePosGetBanker.Enqueue(_bankpos); //================测试数据
            _firstUser._tableID = tablenum;     //赋值桌子号

            _DicPos2User.TryAdd(1, _firstUser); //1~3表示位置
            _temppos2user.TryAdd(1, _firstUser);
            _masterPos = 1;                     //房主,只做建房用

            _judge = new BullFight100Judge(this);
            _judge.InitiArgs(_data);
            base._gametype = _judge._gametype;
            _tableMaxCount = _judge.GetTableorBankerMaxCount;

            _TurnWaitTime = 15;

            base.Initi(_temppos2user, _judge._minLimit, _judge._maxLimit, gameid, BF100SendDataServer.instance, DoTableTimer);
            base.EnterTable();

            _strStatus = "BullFightTable...1";
        }
 /// <summary>
 /// 重置此桌信息
 /// </summary>
 public void Reset(bool _no_again)
 {
     lock (objLock)
     {
         _strStatus = "Reset...     ";
         ForeashAllDo((i) =>
         {
             BullFight100User _tempuser     = _DicPos2User[i];
             _tempuser._isBanker            = false;
             _tempuser._isGetBanker         = false;
             _tempuser._bulltype            = PokerBullFightType.Bull_No;
             _tempuser._pos2Gameble         = new Dictionary <int, int>();
             _tempuser._gambleTotal         = 0;
             _tempuser._showCardList        = new List <int>();
             _tempuser._SysDealTimeOutCount = 0;
             _tempuser._gambletime          = DateTime.Now.AddYears(100);
             // _tempuser._WaitClientLimitCount = 0;
         });
         base.ResetBase(_no_again);
         ForeashAllDo((i) =>
         {
             if (i <= 2)
             {
                 return;
             }
             BullFight100User _tempu;
             _DicPos2User.TryRemove(i, out _tempu);
         });
         //不在的用户处理掉
         ForeashAllDo((i) =>
         {
             if (!_pos2userbase.ContainsKey(i))
             {
                 BullFight100User _tempu;
                 _DicPos2User.TryRemove(i, out _tempu);
             }
         });
         if (_numpertable < base._num_min)
         {
             _tablestatus = TableStatusEnum.WaitforReady;  //人数不够了,,停止下局的自动准备
         }
         if (_no_again)
         {
             _DicPos2User = null;
             _judge       = null;
             BullFight100Room myr = BullFight100Lobby.instance.GetRoomByRoomID(_roomid);
             if (myr != null)
             {
                 myr.ResetTableByTableID(_tableid);
             }
             _tableid = 0;
         }
         else
         {                                                                                              //金币模式 才需要自动开始
             ForeashAllDo((i) => { _DicPos2User[i].SetTimeOutAction(1, "sc_tablestart_bf100_n", 1); }); //自动开始下一步         Start();
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 返回指定房间的在线人数
        /// </summary>
        /// <param name="levelid"></param>
        /// <returns></returns>
        public int GetOnlineCount(int levelid)
        {
            BullFight100Room room = BullFight100Lobby.instance.GetRoomByRoomID(levelid);

            if (room == null)
            {
                return(0);
            }
            return(room._curNumberInRoom);
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="RoomID"></param>
        /// <param name="TableID"></param>
        /// <returns></returns>
        public BullFight100Table GetTableByRoomIDandTableID(int RoomID, int TableID)
        {
            BullFight100Room tempR = GetRoomByRoomID(RoomID);

            if (tempR == null)
            {
                return(null);
            }

            return(tempR.GetTableByTableID(TableID));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 初始化大厅
        /// </summary>
        public void Initi()
        {
            Gameid = 42;
            var roomInfo = new ShareCacheStruct <tb_GameInfo>();

            //DOTO 取了一个房间配置 后面在根据情况在来处理
            //====================begin============================================
            BullFight100Room._instance.Awake();
            tb_gamelevelinfoEx.TryRecoverFromDb();//先从数据库恢复一次
            var roomList = new ShareCacheStruct <tb_gamelevelinfo>().FindAll((g) => { return(g.gameid == Gameid); });

            foreach (var _roomInfo in roomList)
            {
                var roomData = new BullFight100Room(_roomInfo);
                BullFight100Room.roomCache.TryAdd(roomData.mRoomID + "", roomData);
                roomData.CreateTableByRobot();
            }
            //===================end
            BullFight.InitRate();
            _dicUserStatus = new ConcurrentDictionary <int, UserStatus>();
        }
Exemplo n.º 9
0
        /// <summary>
        /// 进入房间 1.如果是房卡模式就直接进入房间,2.如果是金币模式就返回现在等待用户数
        /// </summary>
        /// <returns></returns>
        public string EnterRoom(tb_User _user, cs_enterroom _data)
        {
            sc_enterroom _senddata = new sc_enterroom()
            {
                result = 0, fn = "sc_enterroom", cc = 0
            };
            BullFight100Room room = BullFight100Lobby.instance.GetRoomByRoomID(_data.levelid);

            if (room == null)
            {
                return(JsonUtils.Serialize(_senddata));
            }
            int WaitUserCount = room.EnterRoom(_data, _user.UserID, _strIPandPort);

            _senddata.waitcount   = WaitUserCount;
            _senddata.result      = 1;
            _senddata.gameid      = _data.gameid;
            _senddata.levelid     = _data.levelid;
            _senddata.gamemodel   = _data.gamemodel;
            _senddata.numpertable = _data.numpertable;
            return(JsonUtils.Serialize(_senddata));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 进入房间 返回现在等待用户数
        /// </summary>
        /// <returns></returns>
        private string ExitRoom(tb_User _user, cs_exitroom _data)
        {
            sc_exitroom _senddata = new sc_exitroom()
            {
                result = 0, fn = "sc_exitroom", cc = 0
            };

            switch (_data.gameid)
            {
            case 42:
                BullFight100Room _bfroom = BullFight100Lobby.instance.GetRoomByRoomID(_data.levelid);
                if (_bfroom != null)
                {
                    if (_bfroom.ExitRoom(_user.UserID))
                    {
                        _senddata.result = 1;
                    }
                }
                break;

            case 41:
                ////BullColorRoom _bfcroom = BullColorLobby.instance.GetRoomByRoomID(_data.levelid);
                ////if (_bfcroom != null)
                ////{
                ////    if (_bfcroom.ExitRoom(_user.UserID))
                ////    {
                ////        _senddata.result = 1;
                ////    }
                ////}
                break;

            default:
                break;
            }

            return(JsonUtils.Serialize(_senddata));
        }