Beispiel #1
0
        public static void Main(string[] args)
        {
            if (!EnvironmentCheck())
            {
                return;
            }

            Console.BackgroundColor = ConsoleColor.DarkMagenta;
            Console.ForegroundColor = ConsoleColor.White;

            Console.Clear();
            Player player   = PlayerSetup();
            var    payTable = GetPayTable();
            var    bet      = GetMachineBetValue();
            var    game     = new Game(player, payTable);

            MachineDisplay.DisplayMachine(game, bet, "Play 1-5 coins or ESC for options.");
            do
            {
                var choice = GetUserInput(true, false);

                switch (choice)
                {
                case Choice.Options:
                    Console.Clear();
                    payTable = GetPayTable();
                    bet      = GetMachineBetValue();
                    game     = new Game(player, payTable);
                    MachineDisplay.DisplayMachine(game, bet, "Play 1-5 coins or ESC for options.");
                    break;

                case Choice.One:
                    PlayGame(game, bet, 1);
                    break;

                case Choice.Two:
                    PlayGame(game, bet, 2);
                    break;

                case Choice.Three:
                    PlayGame(game, bet, 3);
                    break;

                case Choice.Four:
                    PlayGame(game, bet, 4);
                    break;

                case Choice.Five:
                    PlayGame(game, bet, 5);
                    break;
                }
            } while (player.Money > 0);

            Console.WriteLine("Oh no, you're penniless!  Game over.");
            Console.ReadLine();
        }
Beispiel #2
0
        private static void PlayGame(Game game, decimal bet, int coins)
        {
            if (!game.InitialDeal(bet, coins))
            {
                return;
            }

            Choice choice;

            MachineDisplay.AnimateFlippingNoHoldCards(game, bet, string.Empty, coins);

            do
            {
                MachineDisplay.DisplayMachine(game, bet, "Hold cards 1-5 or ENTER to redeal.", coins);

                choice = GetUserInput(false, true);

                switch (choice)
                {
                case Choice.One:
                    game.ToggleCardHold(0);
                    break;

                case Choice.Two:
                    game.ToggleCardHold(1);
                    break;

                case Choice.Three:
                    game.ToggleCardHold(2);
                    break;

                case Choice.Four:
                    game.ToggleCardHold(3);
                    break;

                case Choice.Five:
                    game.ToggleCardHold(4);
                    break;
                }
            } while (choice != Choice.Accept);

            var results = game.ReDeal();

            MachineDisplay.AnimateFlippingNoHoldCards(game, bet, string.Empty, coins);

            var finalMessage = "Game over. Play 1-5 coins.";

            if (results.GameState == GameState.Won)
            {
                finalMessage = $"Won ${results.WinAmount:0.##} with {results.WiningCombination.Description}!";
            }
            MachineDisplay.DisplayMachine(game, bet, finalMessage, coins);
        }