Exemplo n.º 1
0
        /// <summary>
        /// 请求比牌  结算条件在此处理
        /// </summary>
        public void Compare(int userID, int targetpos)
        {
            lock (objLock)
            {
                TCUser myu = GetUserByID(userID);
                if (myu == null)
                {
                    return;
                }
                if (!myu.CheckFirstDeal())
                {
                    return;
                }

                _allMoney      += _baseMoney * 2;   //比牌暂时扣2倍基础的钱
                myu._tempMoney -= _baseMoney * 2;   //比牌暂时扣2倍基础的钱  ====================

                int applypos = myu._Pos;
                int fialpos;
                if (ThreeCard.ComparePoker(_DicPos2User[applypos]._shouPaiArr, _DicPos2User[targetpos]._shouPaiArr))
                {
                    fialpos = targetpos;
                }
                else
                {
                    fialpos = applypos;
                }
                _DicPos2User[fialpos]._isgiveup = true;

                List <UserIDMSG> imList = new List <UserIDMSG>();
                ForeashAllDo((i) =>
                {
                    TCUser tempUser = _DicPos2User[i];

                    sc_compare_tc_n _compare_n = new sc_compare_tc_n()
                    {
                        fn = "sc_compare_tc_n", result = 1
                    };
                    _compare_n.failpos = fialpos;
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_compare_n), tempUser._isRobot, tempUser._isDisconnet));
                });

                TCSendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);

                MoveNextToken(); _DicPos2User[_userTokenPos].SetTimeOutAction(1, "sc_compare_tc_n");//下把的自动开始功能           MoveTableToken();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 所有人进行比牌, 按顺序自动进行比牌
        /// </summary>
        private TCUser CompareAll()
        {
            List <TCUser> _tempall = new List <TCUser>();

            ForeashAllDo((i) =>
            {
                if (_DicPos2User[i]._isgiveup)
                {
                    return;
                }
                _tempall.Add(_DicPos2User[i]);
            });
            if (_tempall.Count == 0)
            {
                ErrorRecord.Record(" 201610281559TC  到达最大TOKEN,比牌user个数为0 ");
                return(null);
            }

            TCUser _tempfirstUser = _tempall[0];

            if (_tempall.Count > 1)
            {
                for (int i = 1; i < _tempall.Count; i++)
                {
                    if (ThreeCard.ComparePoker(_tempfirstUser._shouPaiArr, _tempall[i]._shouPaiArr))
                    {
                        _tempall[i]._isgiveup = true;
                    }
                    else
                    {
                        _tempfirstUser           = _tempall[i];
                        _tempfirstUser._isgiveup = true;
                    }
                }
            }
            return(_tempfirstUser);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 至少两人到位了进行 开局,开局就会扣掉配置钱===============================================
        /// </summary>
        public void Start(int userid)
        {
            lock (objLock)
            {
                TCUser myu = GetUserByID(userid);
                if (myu == null)
                {
                    return;
                }
                if (myu.CheckisWatch())
                {
                    return;
                }
                if (!myu.CheckFirstDeal())
                {
                    return;
                }
                if (HaveSomeBodyUnDeal())
                {
                    return;
                }
                if (_numpertable < _num_min)
                {
                    return;
                }

                base.StartBase(60 * 10);
                //第一次随机庄
                _bankpos = new Random().Next(1, _numpertable + 1); //BankerPos = 1;

                Queue <int> _tcardLeft = new Queue <int>();
                Dictionary <int, List <int> > _pokerList = ThreeCard.DistributePoker(out _tcardLeft, _numpertable);   //分牌


                List <UserIDMSG>      imList  = new List <UserIDMSG>();
                List <CommonPosValSD> _uplist = new List <CommonPosValSD>();
                ForeashAllDo((i) =>
                {
                    _uplist.Add(new CommonPosValSD()
                    {
                        pos = i, val = _DicPos2User[i]._userid
                    });
                });
                // 同时把每位玩家的数据确认修改了 //发送消息到所有玩家
                ForeashAllDo((i) =>
                {
                    TCUser tempUser = _DicPos2User[i];

                    tempUser._isPlaying  = true;
                    tempUser._Pos        = i;
                    tempUser._shouPaiArr = _pokerList[i];

                    _DicPos2User[i] = tempUser;//必须要赋值回去 要求有3个返馈才处理

                    _tablRecord.MatchCode = _tableMathCode;
                    _tablRecord._guid     = _guid;
                    _tablRecord.StartTime = DateTime.Now;

                    //发送通知消息
                    sc_tablestart_tc_n _start = new sc_tablestart_tc_n()
                    {
                        result = 1, fn = "sc_tablestart_tc_n"
                    };
                    _start.tableid   = _tableid;
                    _start.pos       = i;
                    _start.BankerPos = _bankpos;
                    _start._user2pos = _uplist;//所有玩家及对应 的位置信息
                    imList.Add(new UserIDMSG(tempUser._userid, JsonUtils.Serialize(_start), tempUser._isRobot, tempUser._isDisconnet));
                });

                TCSendDataServer.instance.SendDataDelay(imList);
                _tableSendData.Add(imList);
                AutoBaseGamble();

                // ,只有庄的下一个位置有超时处理
                MoveNextToken();
                _DicPos2User[_userTokenPos].SetTimeOutAction(1, "sc_tablestart_tc_n");//下一位的处理 令牌功能           MoveTableToken();
            }
        }