예제 #1
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);
                }
                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秒再一起分配
            }
        }
예제 #2
0
파일: Action100.cs 프로젝트: ioying/Scut
        public override bool TakeAction()
        {
            string host     = httpGet.RemoteAddress ?? "";
            string bindHost = ContextUser != null ? ContextUser.RemoteAddress : "";

            if (!string.IsNullOrEmpty(host) && !host.Equals(bindHost))
            {
                UserConnection con;
                if (_roomStruct.TryGet(host, out con))
                {
                    var tempUser = new GameDataCacheSet <GameUser>().FindKey(Uid);
                    if (tempUser != null)
                    {
                        tempUser.RemoteAddress = string.Empty;
                        Console.WriteLine("玩家:{0}-{1} Socket通道被解绑", tempUser.UserId, tempUser.NickName);
                    }
                    con.UserId = UserId;
                }
                else
                {
                    _roomStruct.TryAdd(host, new UserConnection()
                    {
                        UserId = UserId, LocalHost = host
                    });
                }
                if (ContextUser != null)
                {
                    ContextUser.RemoteAddress = host;
                }
            }
            //Console.WriteLine(httpGet.RemoteAddress);
            return(true);
        }
예제 #3
0
        public T GetData(int key)
        {
            T data;

            m_Table.TryGet(key.ToString(), out data);
            return(data);
        }
예제 #4
0
 private string GetUserName(int userId)
 {
     var cache = new MemoryCacheStruct<ChatUser>();
     ChatUser user;
     if (cache.TryGet(userId.ToString(), out user))
     {
         return user.UserName;
     }
     return string.Empty;
 }
예제 #5
0
파일: GameRoom.cs 프로젝트: ioying/Scut
        /// <summary>
        /// 进入房间
        /// </summary>
        public void Enter(GameUser user, RoomInfo roomInfo)
        {
            List <PositionData> list = new List <PositionData>();
            string   key             = roomInfo.Id.ToString();
            RoomData roomData;

            if (_roomStruct.TryGet(key, out roomData))
            {
                var tableData = GameTable.Current.SelectTable(user, roomData, roomInfo);
                if (tableData != null && tableData.Positions.Length > 0)
                {
                    GameTable.Current.SyncNotifyAction(ActionIDDefine.Cst_Action2003, tableData, null,
                                                       c =>
                    {
                        GameTable.Current.CheckStart(tableData);
                    });
                }
            }
        }
예제 #6
0
 private ChatUser GetUser(int userId)
 {
     var cache = new MemoryCacheStruct<ChatUser>();
     ChatUser chatUser;
     if (cache.TryGet(userId.ToString(), out chatUser))
     {
         return chatUser;
     }
     return null;
 }
예제 #7
0
파일: GameTable.cs 프로젝트: zhukaixy/Scut
        private RoomData GetRoomData(int roomId)
        {
            string   key = roomId.ToString();
            RoomData roomData;

            if (_roomStruct.TryGet(key, out roomData))
            {
                return(roomData);
            }
            return(null);
        }
예제 #8
0
        private ChatUser GetUser(int userId)
        {
            var      cache = new MemoryCacheStruct <ChatUser>();
            ChatUser chatUser;

            if (cache.TryGet(userId.ToString(), out chatUser))
            {
                return(chatUser);
            }
            return(null);
        }
예제 #9
0
        private string GetUserName(int userId)
        {
            var      cache = new MemoryCacheStruct <ChatUser>();
            ChatUser user;

            if (cache.TryGet(userId.ToString(), out user))
            {
                return(user.UserName);
            }
            return(string.Empty);
        }
예제 #10
0
        /// <summary>
        /// 开启通用方法
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>
        public static string ReadTemp(string fileName)
        {
            string       code = Path.GetFileName(fileName);
            TemplateInfo tempInfo;

            if (!_tempCacheSet.TryGet(code, out tempInfo))
            {
                tempInfo         = new TemplateInfo();
                tempInfo.Content = File.ReadAllText(fileName, Encoding.UTF8);
                _tempCacheSet.TryAdd(code, tempInfo);
            }
            return(tempInfo.Content);
        }
예제 #11
0
        /// <summary>
        /// 进入房间
        /// </summary>
        public void Enter(GameUser user, RoomInfo roomInfo)
        {
            string   key = roomInfo.Id.ToString();
            RoomData roomData;

            if (_roomStruct.TryGet(key, out roomData))
            {
                var cacheSet = new GameDataCacheSet <GameUser>();
                var userTemp = cacheSet.FindKey(user.PersonalId, user.UserId);
                var list     = cacheSet.FindGlobal(t => true);


                var tableData = GameTable.Current.SelectTable(userTemp, roomData, roomInfo);
                if (tableData != null && tableData.Positions.Length > 0)
                {
                    GameTable.Current.SyncNotifyAction(ActionIDDefine.Cst_Action2003, tableData, null,
                                                       c =>
                    {
                        GameTable.Current.CheckStart(tableData);
                    });
                }
            }
        }
예제 #12
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);
            }
        }
예제 #13
0
        int mRole;//0:地主 -1:上家 1:下家

        public CardAILogic(int roomID, int tableID, int posID)
        {
            var      roomStruct = new MemoryCacheStruct <RoomData>();
            RoomData roomData;

            if (roomStruct.TryGet(roomID.ToString(), out roomData))
            {
                if (roomData.Tables.TryGetValue(tableID, out mTableData))
                {
                    mPlayerNum = mTableData.PlayerNum;
                }
            }

            if (null != mTableData && posID < mTableData.Positions.Length)
            {
                int tempCard = 0;
                foreach (var pos in mTableData.Positions)
                {
                    if (pos.IsLandlord)
                    {
                        mLandlordData = pos;
                    }
                    if (pos.Id == posID)
                    {
                        mSelfData = pos;
                    }

                    if (null != pos.CardData && pos.CardData.Count > 0)
                    {
                        int lastCardVal = pos.CardData[pos.CardData.Count - 1] % 100;
                        if (lastCardVal > tempCard)
                        {
                            tempCard = lastCardVal;
                        }
                    }
                }

                if (tempCard > 0)
                {
                    mLargestCardSize = (CardSize)tempCard;
                }
            }

            if (null != mLandlordData && null != mSelfData)
            {
                int nextIndex = (mSelfData.Id + 1) % mPlayerNum;
                mNextPos = mTableData.Positions[nextIndex];
                int preIndex = (mSelfData.Id + mPlayerNum - 1) % mPlayerNum;
                mPrePos = mTableData.Positions[preIndex];

                if (mLandlordData.Id == mSelfData.Id)
                {
                    mRole = 0;
                }
                else if (mLandlordData.Id == mNextPos.Id)
                {
                    mRole = -1;
                }
                else
                {
                    mRole = 1;
                }
            }
        }