Example #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();
            }
        }
Example #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);
        }