示例#1
0
        /// <summary>
        /// Give a card to a player from the top of some deck (with animation)
        /// </summary>
        /// <param name="nPlayer">The ordinal number of a player to give card to</param>
        private void MoveCardToPlayer(int nPlayer)
        {
            int  nDeck;
            Card card = game.PopCardFromDeck(out nDeck);

            //Animate
            cardtable.DrawCard(card, nDeck);
            Thread.Sleep(300);                      // yeah, I know (((
            cardtable.DrawShoes();

            // Player can get busted or get a score of 21 after receiving new card
            try
            {
                game.GetPlayer(nPlayer).TakeCard(card);
            }
            catch (BustException)
            {
                // setting the BUST state and indicating LOSE right away (no matter what the dealer will get)
                game.SetPlayerState(nPlayer, PlayerState.BUST);
                game.GetPlayer(nPlayer).PlayResult = PlayerResult.LOSE;
            }
            catch (BlackjackException)
            {
                game.SetPlayerState(nPlayer, PlayerState.BLACKJACK);
            }
            finally
            {
                cardtable.Invalidate();
            }
        }