예제 #1
0
 public Room()
 {
     bankerSeat = new BankerSeat(0, this);
     for (int i = 0; i < 4; i++)
     {
         playerSeats.Add(new PlayerSeat(i + 1, this));
     }
     //bankerSeat.PlayerSitIn(new AIPlayer());
 }
예제 #2
0
        /// <summary>
        /// 主要的比较牌型大小逻辑
        /// </summary>
        /// <param name="playerSeat">玩家座位</param>
        /// <param name="bankerSeat">庄家座位</param>
        /// <returns>比较结果</returns>
        private CompeteResultEnum Compete(PlayerSeat playerSeat, BankerSeat bankerSeat)
        {
            IList <Card> playerCards = playerSeat.Cards, bankerCards = bankerSeat.Cards;

            FlipCards(playerCards);
            FlipCards(bankerCards);
            int bet = playerSeat.Bet;

            if (IsBlackJack(playerCards) && !IsBlackJack(bankerCards))
            {
                bet = bet * 3 / 2;
                return(CompeteResultEnum.PlayerBlackJackWin);
            }
            int playerSum = BestSum(playerCards), bankerSum = BestSum(bankerCards);

            if (playerSum > 21)
            {
                return(CompeteResultEnum.BankerWin);
            }
            else if (bankerSum > 21 && playerSum <= 21)
            {
                return(CompeteResultEnum.PlayerPlainWin);
            }
            else
            {
                if (playerSum < bankerSum || (playerSum == bankerSum && bankerSum < 17))
                {
                    return(CompeteResultEnum.BankerWin);
                }
                else if (playerSum == bankerSum)
                {
                    return(CompeteResultEnum.Draw);
                }
                else
                {
                    return(CompeteResultEnum.PlayerPlainWin);
                }
            }
        }