示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Grand Hotel and Casino. Let's start by telling me your name.");
            string playerName = Console.ReadLine();

            Console.WriteLine("\nAnd how much money did you bring today?");
            int bank = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine($"\nHello, {playerName}. Would you like to join a game of Black Jack right now?");
            string answer = Console.ReadLine().ToLower();

            if (answer == "yes" || answer == "yeah" || answer == "y" || answer == "ya")
            {
                Player player = new Player(playerName, bank);
                Game   game   = new BlackJackGame();
                Console.WriteLine($"\nYour current balance is: {player.Balance}");
                game += player;
                player.isActivelyPlaying = true;
                while (player.isActivelyPlaying && player.Balance > 0)
                {
                    game.Play();
                }
                game -= player;
                Console.WriteLine("\nThank you for playing!");
            }
            Console.WriteLine("\nFeel free to look around the casino. Bye for now.");
            Console.ReadLine();
        }
示例#2
0
        private void Btn_newGame_Click(object sender, EventArgs e)
        {
            game                    = new BlackJackGame(Properties.Settings.Default.InitBalance);
            game.DealEvent         += UpdateUIAfterDeal;
            game.PlayerFinishEvent += CurrentPlayerFinishToPlay;
            game.PlayerEndEvent    += CurrentPlayerEndGame;
            game.HitEvent          += UpdateUIAfterHit;
            game.GameCloseEvent    += AnyGameClosed;

            for (int i = 0; i < gameForms.Length; i++)
            {
                gameForms[i] = new GameForm(game, UpdateUINames);
                gameForms[i].Show();
            }
        }
示例#3
0
        static void Main(string[] args)
        {
            var menu = new Menu_Files.Menu();


            menu.Start();

            while (menu.start == true)
            {
                var blackJack = new BlackJackGame();


                menu.Setup(110, 36);
                menu.CreateBoarder(37, 35);
                menu.CreateTableBoarder();
                //menu.TestShowCard(0);
                //menu.TestShowCard(1);
                //menu.TestShowCard(2);

                menu.Write(0, 1, "Enter your name: ");
                blackJack.player.name = Console.ReadLine();

                blackJack.StartNewGame();
                Console.SetCursorPosition(0, 30);
                Console.WriteLine("Press Enter to restart. ");
                Console.WriteLine("Press ESC to enter menu.");
                Console.WriteLine("Press any button to Exit.");
                var input = Console.ReadKey();
                if (input.Key == ConsoleKey.Enter)
                {
                    Console.Clear();
                    menu.Write(47, 10, "RESTARTING....");
                    System.Threading.Thread.Sleep(2500);
                }
                else if (input.Key == ConsoleKey.Escape)
                {
                    Console.Clear();
                    menu.Start();
                }
                else
                {
                    break;
                }
            }
            Console.Clear();
            menu.Write(44, 10, "Thanks for playing BlackJack!");
            System.Threading.Thread.Sleep(2500);
        }
示例#4
0
        // Constractor
        public GameForm(BlackJackGame theGame, AddNameEventHandler addNameEventHandler)
        {
            game = theGame;
            InitializeComponent();

            LoadPictureBox();
            InitializeUI();
            SetUpNewGame();

            // Get player name.
            newPlayerForm = new NewPlayerForm();
            newPlayerForm.AddNameEvent += EnterPlayerName;
            newPlayerForm.AddNameEvent += addNameEventHandler;
            Hide();
            newPlayerForm.ShowDialog();
            Show();

            this.FormClosed += GameFormClosed;
        }
示例#5
0
        public Game ChooseGame(Person player)
        {
            Game   game;
            string choice = "";

            do
            {
                Console.WriteLine("What game would you like to play? BlackJack, Slots, Craps, Go Fish, or War?");
                choice = Console.ReadLine().ToLower();
                if (choice == "blackjack" || choice == "black jack")
                {
                    game = new BlackJackGame(player);
                }
                else if (choice == "go fish" || choice == "gofish")
                {
                    game = new GoFishGame(player);
                }
                else if (choice == "war")
                {
                    game = new War(player);
                }
                else if (choice == "craps")
                {
                    game = new Craps(player);
                }
                else if (choice == "slots")
                {
                    game = new Slots(player);
                }
                else
                {
                    game = null;
                }
            } while(choice != "blackjack" && choice != "black jack" && choice != "go fish" && choice != "gofish" && choice != "war" &&
                    choice != "slots" && choice != "craps");
            Console.WriteLine("Going to " + choice + "!");
            return(game);
        }
        static void Main(string[] args)
        {
            const string casinoName = "Erics Casino";

            Guid identifier = Guid.NewGuid();


            // Constructor Chaining Demo
            Player newPlayer = new Player("Eric");

            // Welcome and get player name and bank
            Console.WriteLine("Welcome to the {0}! Please enter your name", casinoName);
            string playerName = Console.ReadLine();

            // if admin query exceptions
            if (playerName.ToLower() == "admin")
            {
                List <ExceptionEntity> Exceptions = ReadExceptions();
                foreach (var exception in Exceptions)
                {
                    Console.Write(exception.Id + " | ");
                    Console.Write(exception.ExceptionType + " | ");
                    Console.Write(exception.ExceptionMessage + " | ");
                    Console.Write(exception.TimeStamp + " | ");
                    Console.WriteLine();
                }
                Console.ReadLine();
            }


            int  bank        = 0;
            bool validAnswer = false;

            while (!validAnswer)
            {
                Console.WriteLine("How much money did you bring today?: ");
                validAnswer = int.TryParse(Console.ReadLine(), out bank);
                if (!validAnswer)
                {
                    Console.WriteLine("Pleas only enter digits");
                }
            }


            Console.WriteLine("Hello {0}, whould you like to play Black Jack", playerName);
            string answer = Console.ReadLine().ToLower();

            if (answer == "y" || answer == "yes")
            {
                // Initalize Player and Game, enter game loop.
                Player player = new Player(playerName, bank);
                // Log A GUID for player
                player.Id = Guid.NewGuid();
                Game game = new BlackJackGame();
                using (StreamWriter file = new StreamWriter(@"..\..\logs\cards_dealt.txt", true))
                {
                    file.WriteLine(player.Id);
                }


                game += player;                                        // operator overload, add player to "Game.Players" list
                player.isActivelyPlaying = true;
                while (player.isActivelyPlaying && player.Balance > 0) // wants to play and has money
                {
                    try
                    {
                        game.Play(); // Main Game Loop, represents one hand
                    }
                    catch (FraudException ex)
                    {
                        Console.WriteLine("SECURITY, KICK THIS PERSON OUT!!!");
                        UpdateDBWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine("An argument was entered incorrectly");
                        UpdateDBWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("ERROR ERROR ERROR ERROR ERROR");
                        UpdateDBWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                }
                game -= player; // operator overload, remove player from game object
                Console.WriteLine("Thank you for playing!");
            }

            Console.WriteLine("Feel free to look around the casino, have a nice day");

            // Hold
            Console.Read();
        }
示例#7
0
        static void Main(string[] args)
        {
            Game game = new BlackJackGame();

            game.Start();
        }
示例#8
0
        static void Main(string[] args)
        {
            const string casinoName = "World Underground Gambling Ring";

            Console.WriteLine("Welcome to the {0}, What is your name?", casinoName);
            string playerName = Console.ReadLine();

            if (playerName.ToLower() == "admin")
            {
                List <ExceptionEntity> Exceptions = ReadExceptions();
                foreach (var exception in Exceptions)
                {
                    Console.Write(exception.Id + " | ");
                    Console.Write(exception.ExceptionType + " | ");
                    Console.Write(exception.ExceptionMessage + " | ");
                    Console.Write(exception.TimeStamp + " | ");
                    Console.WriteLine();
                }
                Console.ReadLine();
                return;
            }
            bool validAnswer = false;
            int  bank        = 0;

            while (!validAnswer)
            {
                Console.WriteLine("Hello, {0} how much money did you bring today?", playerName);
                validAnswer = int.TryParse(Console.ReadLine(), out bank);
                if (!validAnswer)
                {
                    Console.WriteLine("Please enter digits only, no decimals.");
                }
            }

            Console.WriteLine("{0}, would you like to play a game of BlackJack? ", playerName);
            string answer = Console.ReadLine().ToLower();

            if (answer == "yes" || answer == "yeah" || answer == "y" || answer == "ya")
            {
                Player player = new Player(playerName, bank);
                player.Id = Guid.NewGuid();
                using (StreamWriter file = new StreamWriter(@"C:\Users\Grady Mellin\Desktop\C#_course\TA_C#_Projects\BlackJack\log.txt", true))
                {
                    file.WriteLine(player.Id);
                }
                Game game = new BlackJackGame();
                game += player;
                player.isActivelyPlaying = true;
                while (player.isActivelyPlaying && player.Balance > 0)
                {
                    try
                    {
                        game.Play();
                    }
                    catch (FraudException ex)
                    {
                        Console.WriteLine(ex.Message);
                        UpdateDbWithExceptions(ex);
                        Console.ReadLine();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("An error occurred. Please contact your System Administrator.");
                        UpdateDbWithExceptions(ex);
                        Console.ReadLine();
                        return;
                    }
                }
                game -= player;
                Console.WriteLine("Thank you for playing!");
            }
            Console.WriteLine("Feel Free to look around the casino. Bye for now.");
            Console.Read();
        }
示例#9
0
 public Client(BlackJackGame game)
 {
     _game = game;
 }
示例#10
0
        static void Main(string[] args)
        {
            const string casinoName = "Grand Hotel and Casino";

            Guid identifier = Guid.NewGuid();

            Console.WriteLine("Welcome to the {0}. Let's start by telling me your name.", casinoName);
            string playerName = Console.ReadLine();

            if (playerName == "admin")
            {
                List <ExceptionEntity> Exceptions = ReadExceptions();
                foreach (var exception in Exceptions)
                {
                    Console.Write(exception.Id + " | ");
                    Console.Write(exception.ExceptionType + " | ");
                    Console.Write(exception.ExceptionMessage + " | ");
                    Console.Write(exception.TimeStamp);
                }
                Console.ReadLine();
                return;
            }

            bool validAnswer = false;
            int  bank        = 0;

            while (!validAnswer)
            {
                Console.WriteLine("And how much money did you bring today?");
                validAnswer = int.TryParse(Console.ReadLine(), out bank);
                if (!validAnswer)
                {
                    Console.WriteLine("Please enter digits only, no decimals");
                }
            }


            Console.WriteLine("Hello, {0}. Would you like to join a game of 21 right now?", playerName);
            string answer = Console.ReadLine().ToLower();

            if (answer == "yes" || answer == "yeah" || answer == "y" || answer == "ok" || answer == "okay" || answer == "sure")
            {
                Player player = new Player(playerName, bank);
                player.ID = Guid.NewGuid();
                using (StreamWriter file = new StreamWriter(@"C:\Users\Michael\Logs\log.txt", true))
                {
                    file.WriteLine(player.ID);
                }
                Game game = new BlackJackGame();
                game += player;
                player.IsActivelyPlaying = true;
                while (player.IsActivelyPlaying && player.Balance > 0)
                {
                    try
                    {
                        game.Play();
                    }
                    catch (FraudException ex)
                    {
                        Console.WriteLine(ex.Message);
                        UpdateDbWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("An Error has occurred. Please contact your System Administrator.");
                        UpdateDbWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                }
                game -= player;
                Console.WriteLine("Thank you for playing");
            }
            Console.WriteLine("Feel free to look around the casino. Bye for now.");
            Console.ReadLine();
        }
示例#11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Grand Hotel and Casino. Let's start by telling me your name.");
            string playerName = Console.ReadLine();

            if (playerName.ToLower() == "admin")
            {
                List <ExceptionEntity> Exceptions = ReadExceptions();
                foreach (var exception in Exceptions)
                {
                    Console.Write(exception.Id + " | ");
                    Console.Write(exception.ExceptionType + " | ");
                    Console.Write(exception.ExceptionMessage + " | ");
                    Console.Write(exception.TimeStamp + " | ");
                    Console.WriteLine();
                }
                Console.Read();
                return;
            }
            bool validAnswer = false;
            int  bank        = 0;

            while (!validAnswer)
            {
                Console.WriteLine("And how much money did you bring today?");
                validAnswer = int.TryParse(Console.ReadLine(), out bank);
                if (!validAnswer)
                {
                    Console.WriteLine("please enter digits only. No decimals");
                }
            }


            Console.WriteLine("Hello, {0}. Would you like to join a game of blackjack right now?", playerName);
            string answer = Console.ReadLine().ToLower();

            if (answer == "yes" || answer == "yeah" || answer == "y" || answer == "ya")
            {
                Player player = new Player(playerName, bank);
                player.Id = Guid.NewGuid();
                using (StreamWriter file = new StreamWriter(@"C:\Users\Matthew Pendleton\myProjects\TA-C-Sharp\BlackJack\BlackJack\Logs\logs.txt", true))
                {
                    file.WriteLine(player.Id);
                }
                Game game = new BlackJackGame();
                game += player;
                player.IsActivelyPlaying = true;
                while (player.IsActivelyPlaying && player.Balance > 0)
                {
                    try
                    {
                        game.Play();
                    }
                    catch (FraudException ex)
                    {
                        Console.WriteLine(ex.Message);
                        UpdateDbWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("an error occurred. Please contact your system administrator");
                        UpdateDbWithException(ex);
                        Console.ReadLine();
                        return;
                    }
                }
                game -= player;
                Console.WriteLine("Thank you for playing!");
            }
            Console.WriteLine("Feel free to look around the casino. Bye for now.");
            Console.Read();
        }