Beispiel #1
0
        public override bool Action(NotifyType notifyType, BaseInfo baseInfo, UserInfo userInfo)
        {
            switch (notifyType)
            {
            case NotifyType.Request_Betting:
            {
                SicboInfo sicboInfo = (SicboInfo)_GameTable.GetTableInfo();

                int playerIndex = _GameTable.GetPlayerIndex(userInfo);

                if (playerIndex < 0)
                {
                    return(false);
                }

                BettingInfo bettingInfo = (BettingInfo)baseInfo;

                if (userInfo.nCashOrPointGame == 0)
                {
                    if (userInfo.Cash < bettingInfo._Score)
                    {
                        BaseInfo.SetError(ErrorType.Notenough_Cash, "베팅할 금액이 부족합니다");
                        return(false);
                    }
                }
                else
                {
                    if (userInfo.Point < bettingInfo._Score)
                    {
                        BaseInfo.SetError(ErrorType.Notenough_Cash, "베팅할 금액이 부족합니다");
                        return(false);
                    }
                }

                //Cash.GetInstance().GiveCash(userInfo.Id, -bettingInfo._Score);
                //Cash.GetInstance().GiveGameSum(userInfo, -bettingInfo._Score);
                //Cash.GetInstance().GiveGameSum(Database.GetInstance().GetManager(UserKind.Manager), bettingInfo._Score);

                sicboInfo.m_lUserScore[bettingInfo._Area, playerIndex] += bettingInfo._Score;

                _GameTable.BroadCastGame(NotifyType.Reply_Betting, baseInfo);
            }
            break;

            default:
                return(base.Action(notifyType, baseInfo, userInfo));

                break;
            }

            return(true);
        }
Beispiel #2
0
        public override void CheckWinner()
        {
            SicboInfo tableInfo = (SicboInfo)_GameTable.GetTableInfo();

            // 查看是否需要控制
            E_CARD_TYPE[] enCardType = new E_CARD_TYPE[SicboDefine.COUNT_AZIMUTH];

            int iCardTypeCount = 0;
            int i = 0;

            for (i = 0; i < SicboDefine.COUNT_AZIMUTH; ++i)
            {
                enCardType[i] = E_CARD_TYPE.enCardType_Illegal;
            }

            int[] cards = tableInfo.m_enCards;

            do
            {
                Random random = new Random();

                cards[0] = (random.Next() % 6 + 1);
                cards[1] = (random.Next() % 6 + 1);
                cards[2] = (random.Next() % 6 + 1);

                int iCountNum = cards[0] + cards[1] + cards[2];

                if (((cards[0] == cards[1]) && (cards[1] == cards[2])) ||     // 三个相同
                    ((int)E_CARD_TYPE.enCardType_NumberFour == iCountNum) || ((int)E_CARD_TYPE.enCardType_NumberSeventeen == iCountNum))
                {
                    ++tableInfo.m_iSameCount;
                    if (tableInfo.m_iSameCount < 30)
                    {
                        System.Threading.Thread.Sleep(10);
                        continue;
                    }
                    tableInfo.m_iSameCount = 0;
                }
            } while (false);

            _GameLogic.GetCardType(cards, enCardType, ref iCardTypeCount);

            for (i = 0; i < iCardTypeCount; ++i)
            {
                if (E_CARD_TYPE.enCardType_Illegal != enCardType[i])
                {
                    tableInfo.m_bWinner[(int)enCardType[i]] = 1;
                }
            }
        }
Beispiel #3
0
        public SicboTable(string tableId)
        {
            _TableInfo          = new SicboInfo();
            _TableInfo._TableId = tableId;

            _Rounds.Add(new ReadyRound());
            _Rounds.Add(new SicboJoinRound());
            _Rounds.Add(new SicboBettingRound());
            _Rounds.Add(new SicboEndRound());

            for (int i = 0; i < _Rounds.Count; i++)
            {
                _Rounds[i]._GameTable = this;
            }
        }
Beispiel #4
0
        public override void InitTableData(TableInfo tableInfo)
        {
            SicboInfo sicboInfo = (SicboInfo)tableInfo;

            //变量定义
            //tableInfo.m_wCurrentBanker = null;	             // 当前庄家

            Array.Clear(sicboInfo.m_bWinner, 0, sicboInfo.m_bWinner.Length);        // 输赢结果
            Array.Clear(sicboInfo.m_lUserScore, 0, sicboInfo.m_lUserScore.Length);
            Array.Clear(sicboInfo.m_lUserWinScore, 0, sicboInfo.m_lUserWinScore.Length);
            Array.Clear(sicboInfo.m_lUserReturnScore, 0, sicboInfo.m_lUserReturnScore.Length);
            Array.Clear(sicboInfo.m_lUserRevenue, 0, sicboInfo.m_lUserRevenue.Length);

            _TimerId = TimerID.Betting;
            _GameTable.AddGameTimer(TimerID.Betting, sicboInfo.m_BettingTimeLeave);
        }
Beispiel #5
0
        public override bool PlayerOutTable(BaseInfo baseInfo, UserInfo userInfo)
        {
            int seaterIndex = GetPlayerIndex(userInfo);

            if (seaterIndex >= 0)
            {
                if (_Rounds[_TableInfo._RoundIndex] is SicboBettingRound)
                {
                    SicboInfo sicboInfo = (SicboInfo)_TableInfo;

                    int lAllScore = 0;

                    for (int i = 0; i < SicboDefine.COUNT_AZIMUTH; i++)
                    {
                        lAllScore += sicboInfo.m_lUserScore[i, seaterIndex];
                    }

                    if (lAllScore > 0)
                    {
                        sicboInfo.m_lUserWinScore[seaterIndex] = -lAllScore;
                        Cash.GetInstance().ProcessGameCash(seaterIndex, _GameInfo, _TableInfo);

                        sicboInfo.m_lUserWinScore[seaterIndex] = 0;
                    }

                    for (int i = seaterIndex; i < _TableInfo._Players.Count; i++)
                    {
                        for (int k = 0; k < SicboDefine.COUNT_AZIMUTH; k++)
                        {
                            sicboInfo.m_lUserScore[k, i] = sicboInfo.m_lUserScore[k, i + 1];
                        }
                    }
                }
            }

            return(base.PlayerOutTable(baseInfo, userInfo));
        }
Beispiel #6
0
        public override void CheckScore()
        {
            SicboInfo tableInfo   = (SicboInfo)_GameTable.GetTableInfo();
            int       gamePercent = _GameTable._GameInfo.Commission;

            int[] lUserLostScore  = new int[GameDefine.GAME_PLAYER];
            int   lBankerWinScore = 0;

            for (int j = 0; j < SicboDefine.COUNT_AZIMUTH; ++j)
            {
                for (int k = 0; k < GameDefine.GAME_PLAYER; k++)
                {
                    lBankerWinScore += tableInfo.m_lUserScore[j, k];
                }
            }

            //计算金币
            for (int i = 0; i < tableInfo._Players.Count; ++i)
            {
                //庄家判断
                //if (m_wCurrentBanker==i) continue;

                //获取用户
                for (int j = 0; j < SicboDefine.COUNT_AZIMUTH; ++j)
                {
                    lUserLostScore[i] -= tableInfo.m_lUserScore[j, i];

                    // 该区域是否赢了
                    if (tableInfo.m_bWinner[j] > 0)
                    {
                        int i64WinScore = 0;
                        int i64TmpScore = 0;

                        if ((j < (int)E_CARD_TYPE.enCardType_SicboOne) || (j > (int)E_CARD_TYPE.enCardType_SicboSix))
                        {
                            if (tableInfo.m_lUserScore[j, i] > 0)
                            {
                                i64WinScore = (tableInfo.m_lUserScore[j, i] * SicboLogic.m_i64Loss_Percent[j]);
                            }
                            else
                            {
                                i64TmpScore = -(tableInfo.m_lUserScore[j, i]) * SicboLogic.m_i64Loss_Percent[j];
                            }
                        }
                        else
                        {
                            // 需要换算个数
                            int   enSicboNum = (j - (int)E_CARD_TYPE.enCardType_SicboOne + 1);
                            int   iCountNum  = _GameLogic.GetSicboCountByNumber(tableInfo.m_enCards, enSicboNum);
                            int[] iMuti      = new int[] { 0, 2, 3, 4 };

                            if (tableInfo.m_lUserScore[j, i] > 0)
                            {
                                i64WinScore = (tableInfo.m_lUserScore[j, i] * iMuti[iCountNum]);
                            }
                            else
                            {
                                i64TmpScore = -(tableInfo.m_lUserScore[j, i]) * iMuti[iCountNum];
                            }
                        }

                        tableInfo.m_lUserWinScore[i]    += i64WinScore;
                        tableInfo.m_lUserReturnScore[i] += (tableInfo.m_lUserScore[j, i] > 0) ? tableInfo.m_lUserScore[j, i] : 0;
                        lBankerWinScore -= i64WinScore - i64TmpScore;
                    }
                    //else
                    //{
                    //    __int64 i64LoseScore = m_lUserScore[j][i];
                    //    lUserLostScore[i] -= i64LoseScore;
                    //    lBankerWinScore  += i64LoseScore;
                    //}
                }

                //计算税收
                //if (0 < tableInfo.m_lUserWinScore[i])
                //{
                //    tableInfo.m_lUserRevenue[i]  = (tableInfo.m_lUserWinScore[i]*gamePercent)/1000;
                //    tableInfo.m_lUserWinScore[i] -= tableInfo.m_lUserRevenue[i];
                //}

                //总的分数
                tableInfo.m_lUserWinScore[i] += lUserLostScore[i];
            }
        }