Example #1
0
        /// <summary>
        /// Method is called when the game's over and adds its result to the stats table
        /// </summary>
        public void FixGameResults()
        {
            // ... after the game is over
            for (int i = 0; i < game.GetPlayersCount(); i++)
            {
                statistics.AddShuffleResult(game.GetPlayer(i), curShuffle);
            }

            curShuffle++;
        }
Example #2
0
 /// <summary>
 /// Method draws all cards in player's hand (shifted vaertically by 30 pixels)
 /// </summary>
 /// <param name="nPlayer"></param>
 public void ShowPlayerHand(int nPlayer)
 {
     for (int i = 0; i < game.GetPlayer(nPlayer).PlayerHand.GetCardsNumber(); i++)
     {
         g.DrawImage(cardImages[game.GetPlayer(nPlayer).PlayerHand[i].getNumber()],
                     playerCoords[nPlayer].X, playerCoords[nPlayer].Y + 30 * i,
                     drawCardWidth, drawCardHeight);
     }
 }
        /// <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();
            }
        }