Пример #1
0
 void dealer_GameOver(Dealer dealer, List<Player> winnerPlayers, Dealer.GameResultType result)
 {
     if (player.Hand.HandStatus == BlackJackHand.HandStatusTypes.Busted && (player.SplittedHand == null || player.SplittedHand.HandStatus == BlackJackHand.HandStatusTypes.Busted))
     {
         PrintToConsole("You busted!", ConsoleColor.Red);
     }
     else if (result == Dealer.GameResultType.DealerWins)
     {
         PrintToConsole("You loose!", ConsoleColor.Red);
     }
     else if (result == Dealer.GameResultType.Push)
     {
         PrintToConsole("Game push", ConsoleColor.Green);
         PrintToConsole("Your Status : " + (winnerPlayers.Contains(player) ? "Push" : "Lost"), (winnerPlayers.Contains(player) ? ConsoleColor.Green : ConsoleColor.Red));
     }
     else if (winnerPlayers.Contains(player))
     {
         PrintToConsole("You win!", ConsoleColor.Green);
     }
     else
     {
         PrintToConsole("You loose!", ConsoleColor.Green);
     }
 }
Пример #2
0
 void dealer_UpdateScoreBoard(Dealer dealer)
 {
     PrintToConsole(dealer.GetScoreCard(), null);
 }
Пример #3
0
 /// <summary>
 /// Constructor to instantiate BlackJack game instance.
 /// </summary>
 public BlackJack()
 {
     dealer = new Dealer(this);
 }
Пример #4
0
        void PlayGame()
        {
            try
            {
                dealer = new Dealer();
                dealer.UpdateScoreBoard += dealer_UpdateScoreBoard;
                dealer.GameOver += dealer_GameOver;

                player = new Player("Rumit");
                player.ActionRequested += player_ActionRequested;
                dealer.RegisterPlayer(player);

                bool blnReplay = false;
                do
                {
                    dealer.NewGame();

                    dealer.StartPlay();

                    Console.Write("Want to replay? ('y' to replay, any other character to exit.) : ");
                    string strReplayInput = Console.ReadLine();
                    blnReplay = (strReplayInput.Equals("y", StringComparison.InvariantCultureIgnoreCase));
                } while (blnReplay);
            }
            catch (Exception ex)
            {
                PrintExceptionTrace(ex);
            }
        }
Пример #5
0
 /// <summary>
 /// Registers the player with dealer.
 /// </summary>
 /// <param name="dealer">Dealer with which the player is being registered.</param>
 public void RegisterToDealer(Dealer dealer)
 {
     this.dealer = dealer;
 }