Exemplo n.º 1
0
        /// <summary>
        /// Method starts new game (new shuffle).
        /// Method checks if particular player has enough money to proceed and proposes to make bets
        /// </summary>
        private void NewGame()
        {
            // exclude all those players who have not enough money to cannot pay
            game.RemovePlayersMinStake();

            // check if there's at least one player who can do minimal bet
            if (game.GetPlayersCount() == 0)
            {
                MessageBox.Show("There are no more players or all players have not enough money to play!");
                gamevisualizer.Invalidate();
                return;
            }

            // propose to do the bet for each player
            for (int i = 0; i < game.GetPlayersCount(); i++)
            {
                MakeBetForm makeBetForm = new MakeBetForm(game.GetPlayer(i));
                makeBetForm.ShowDialog();
            }

            // Redraw the form
            gamevisualizer.Invalidate();

            // ...And start new game
            gamecontroller.StartNewShuffle();
        }
Exemplo n.º 2
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();
            }
        }