Exemple #1
0
        /// <summary>
        /// Method analyzes and forms the results of the game for a particular player
        /// </summary>
        /// <param name="nPlayer">Player</param>
        /// <returns>1 - Player wins; 0 - Stay; -1 - Player loses</returns>
        public int GameResults(int nPlayer)
        {
            // recalculate total lose for casino if some of the players loses

            // first check for player's bust
            if (GetPlayerState(nPlayer) == PlayerState.BUST)
            {
                players[nPlayer].LoseStake();
                TotalLose -= players[nPlayer].Stake;
                return(-1);
            }

            // first, set bonuses (if there are any) to the player
            SetBonuses(nPlayer);


            // then check for dealer's bust
            if (dealer.CountScore() > 21)
            {
                // additional check!
                if (GetPlayer(nPlayer).PlayResult != PlayerResult.WIN)
                {
                    TotalLose += players[nPlayer].Stake;
                }
                players[nPlayer].WinStake();
                return(1);
            }

            // then simply compare the score:

            // DEALER WINS
            if (players[nPlayer].CountScore() < dealer.CountScore())
            {
                players[nPlayer].LoseStake();
                TotalLose -= players[nPlayer].Stake;
                return(-1);
            }
            // PLAYER WINS
            else if (players[nPlayer].CountScore() > dealer.CountScore())
            {
                // additional check if the player has already taken the win
                if (GetPlayer(nPlayer).PlayResult != PlayerResult.WIN)
                {
                    TotalLose += players[nPlayer].Stake;
                }
                players[nPlayer].WinStake();
                return(1);
            }
            // STAY
            else
            {
                // it can happen if afer the 1st dealer hit player already chose win 1-to-1
                if (players[nPlayer].PlayResult != PlayerResult.WIN)
                {
                    players[nPlayer].PlayResult = PlayerResult.STAY;
                }

                return(0);
            }
        }
Exemple #2
0
        /// <summary>
        /// Method checks if a card holder's got the BlackJack with "777" combination
        /// </summary>
        /// <param name="cardHolder">Card holder</param>
        /// <returns>true if a cardholder's got the "777" combination; false - otherwise</returns>
        public bool Check777(CardHolder cardHolder)
        {
            if (cardHolder.CountScore() == 21)
            {
                CardSet hand = cardHolder.PlayerHand;

                if (hand.GetCardsNumber() == 3)
                {
                    if (hand[0].Rank == 7 && hand[1].Rank == 7 && hand[2].Rank == 7)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #3
0
        /// <summary>
        /// Method checks if a card holder's got the BlackJack with "777" combination
        /// </summary>
        /// <param name="cardHolder">Card holder</param>
        /// <returns>true if a cardholder's got the "777" combination; false - otherwise</returns>
        public bool Check777( CardHolder cardHolder )
        {
            if (cardHolder.CountScore() == 21)
            {
                CardSet hand = cardHolder.PlayerHand;

                if (hand.GetCardsNumber() == 3)
                    if (hand[0].Rank == 7 && hand[1].Rank == 7 && hand[2].Rank == 7)
                        return true;
            }

            return false;
        }
Exemple #4
0
        /// <summary>
        /// Method checks if a card holder's got the BlackJack
        /// </summary>
        /// <param name="cardHolder">Card holder</param>
        /// <returns>true if a cardholder's got the BlackJack; false - otherwise</returns>
	    public bool CheckBlackJack( CardHolder cardHolder )
        {
            return (cardHolder.CountScore() == 21);
        }
Exemple #5
0
 /// <summary>
 /// Method checks if a card holder's got the BlackJack
 /// </summary>
 /// <param name="cardHolder">Card holder</param>
 /// <returns>true if a cardholder's got the BlackJack; false - otherwise</returns>
 public bool CheckBlackJack(CardHolder cardHolder)
 {
     return(cardHolder.CountScore() == 21);
 }