Exemplo n.º 1
0
        static void Main()
        {
            // Create an instance of your CardSet class, and name it myDeck.
            CardSet myDeck = new CardSet();

            // Amount of cards in a hand and starting money
            int howManyCards = 2;
            int balance      = 10;

            while (balance != 0)
            {
                // Set screen output to be some color set
                ForegroundColor = ConsoleColor.Yellow;

                WriteLine("WELCOME TO BASIC POKER!!\nRULES:\n\t- you have $10\n\t- each turn is a $1 bet");
                WriteLine($"BALANCE:\t{balance}");

                // create the two hands for each player
                SuperCard[] computerHand = myDeck.GetCards(howManyCards);
                SuperCard[] playerHand   = myDeck.GetCards(howManyCards);

                // shuffle the cards in the deck
                myDeck.ResetUsage(computerHand);
                myDeck.ResetUsage(playerHand);

                // sort the hands by suit and rank
                Array.Sort(computerHand);
                Array.Sort(playerHand);

                // display the two hands visually
                DisplayHands(computerHand, playerHand);

                // let the player choose to mulligan a card
                PlayerMulliganCard(playerHand, myDeck);

                // let the computer choose to mulligan a card
                ComputerMulliganCard(computerHand, myDeck);

                // sort the hands by suit and rank AGAIN
                Array.Sort(computerHand);
                Array.Sort(playerHand);

                // display the two hands visually AGAIN
                DisplayHands(computerHand, playerHand);

                // compare the two hands and distribute winnings
                bool won = CompareHands(computerHand, playerHand);
                balance = won ? balance + 1 : balance - 1;

                // display the current balance and prompt next game

                WriteLine("Press 'Enter' to continue...");
                ReadLine();
                Clear();
            }
            WriteLine("\nGuess you lost!");

            // end of program
            ReadLine();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int howManyCards = 5;
            int balance      = 10;

            ForegroundColor = ConsoleColor.Yellow;
            BackgroundColor = ConsoleColor.DarkBlue;

            WriteLine("Welcome to simple poker! \nYou have $10 to start (this isn't Vegas) and each turn will be a $1 bet. (High roller aren't we?)");

            CardSet myDeck = new CardSet();

            do
            {
                myDeck.ResetUsage();

                WriteLine("Press the Enter key to bet $1");
                ReadKey();

                SuperCard[] computerHand = myDeck.GetCards(howManyCards);

                SuperCard[] playersHand = myDeck.GetCards(howManyCards);

                Array.Sort(computerHand);

                Array.Sort(playersHand);

                DisplayHands(computerHand, playersHand);
                bool won = CompareHands(computerHand, playersHand);

                PlayerDrawsOne(howManyCards, myDeck, playersHand);
                ComputerDrawsOne(computerHand, myDeck);

                Array.Sort(computerHand);
                Array.Sort(playersHand);
                DisplayHands(computerHand, playersHand);

                if (CompareHands(computerHand, playersHand))
                {
                    balance++;
                    WriteLine("\nYou beat this really simple game by pure luck! Wow, good for you...(okay and maybe a tiny bit of skill)");
                    WriteLine($"You now have {balance:C}!");
                }
                else
                {
                    balance--;
                    WriteLine("\nYou lost. Better get used to it.");
                    WriteLine("You have {0:C} left.", balance);
                }

                if (balance == 0)
                {
                    WriteLine("\nYou lost all of your money. Time to reflect on your life choices.");
                    won = false;
                }
            } while (balance != 0);

            Write("\nPress any key to exit>> ");
            ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int howManyCards = 5;
            int balance      = 10;


            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.BackgroundColor = ConsoleColor.DarkBlue;

            Console.WriteLine("Welcome player, Were going to play poker today");
            Console.WriteLine(" You have $10 to start, and each time you play the game it will be a $1 bet");
            Console.ReadLine();
            CardSet myDeck = new CardSet();

            while (balance > 0)
            {
                Console.Clear();
                myDeck.ResetUsage();

                myDeck.GetCards(howManyCards);
                SuperCard[] computerHand = myDeck.GetCards(howManyCards);
                SuperCard[] playersHand  = myDeck.GetCards(howManyCards);
                Array.Sort(computerHand);
                Array.Sort(playersHand);

                DisplayHands(computerHand, playersHand);


                PlayersDrawsOne(playersHand, myDeck, computerHand);

                ComputerDrawsOne(computerHand, myDeck);

                Array.Sort(computerHand);
                Array.Sort(playersHand);

                Console.WriteLine();

                DisplayHands(computerHand, playersHand);


                bool won = CompareHands(computerHand, playersHand);

                if (won == true)
                {
                    balance++;
                    Console.WriteLine("You have won the game and got 1$");
                    Console.WriteLine("Your balance is {0}$", balance);
                }
                if (won == false)
                {
                    balance--;
                    Console.WriteLine("You have lost 1$. Click enter to try again");
                    Console.WriteLine("Your balance is {0}$", balance);
                    if (balance == 0)
                    {
                        Console.WriteLine("You are out of money the game is over");
                    }
                }
                Console.ReadLine();
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            CardSet myDeck = new CardSet();

            int howManyCards = 5;  // num of cards in a hand
            int balance      = 10; // starting money

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.BackgroundColor = ConsoleColor.DarkBlue;
            Console.Clear();

            Console.WriteLine("Welcome to the Poker Game. \nYou have $10 and each bet will be $1.");
            Console.WriteLine("Press any key when you are ready to start.");
            Console.ReadLine();

            while (balance != 0)
            {
                myDeck.ResetUsage(); //instantiate ResetUsage method so all cards are available after each round

                SuperCard[] computerHand = myDeck.GetCards(howManyCards);
                SuperCard[] playersHand  = myDeck.GetCards(howManyCards);

                Array.Sort(computerHand); // sorts hand from highest to lowest suit and rank
                Array.Sort(playersHand);
                DisplayHands(computerHand, playersHand);

                PlayerDrawsOne(playersHand, myDeck);    // lets player replace one card in their hand
                ComputerDrawsOne(computerHand, myDeck); //  lets computer discard lowest ranking card for a new random card

                Array.Sort(computerHand);
                Array.Sort(playersHand); // re-sorts with new replaced card
                Console.WriteLine();
                Console.WriteLine("Updated Hands");
                DisplayHands(computerHand, playersHand); // re-displays cards with updated hands

                bool won = CompareHands(computerHand, playersHand);
                if (won == true)
                {
                    Console.WriteLine("You won!");
                    balance++;
                }
                else
                {
                    Console.WriteLine("You lost!");
                }

                balance--;

                if (balance == 0)
                {
                    Console.WriteLine("You have $" + balance + " You are out of money.");
                    Console.ReadLine();
                }
                else
                {
                    Console.WriteLine("You have $" + balance);
                    Console.WriteLine("Press 'Enter' for another hand");
                    Console.ReadLine();
                    Console.Clear(); // console will only display 1 round at a time, can compare original hand with replaced hand for both computer and player
                }
            }
            //for (int i = 0; i < 52; i++)
            //{
            //    Console.WriteLine(myDeck.cardArray[i].CardsRank + " of " + myDeck.cardArray[i].CardsSuit);
            //}
            Console.ReadLine();
        }