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(); }
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(); }
static void Main(string[] args) { const int HAND_SIZE = 5; const int DISCARD_CARDS = 1; const int PLAYERS = 2; const int START_BALANCE = 10; const int BET = 1; int howManyCards = HAND_SIZE; int totalCardsDrawn = (HAND_SIZE + DISCARD_CARDS) * PLAYERS; int balance = START_BALANCE; // Just 'cause I'm curious //int handsPlayed = 0; //int handsWon = 0; bool won = false; // Instantiate a deck of cards. CardSet myDeck = new CardSet(); // Declare the 2 hands. Instantiated in myDeck.GetCards() SuperCard[] computerHand; SuperCard[] playersHand; // Set screen colors SetScreenColors(); Console.Clear(); // To actually change the background color // Introduction Console.Write( "Welcome to Quark's game of Poker!\n\n" + "You play against the dealer who follows the same rules as " + "you do.\n\n" + "You will start with ${0}. " + "The bet is ${1} for each hand played.\n\n" + "When you are out of money, you are out of the game.\n\n" + "You will be given {2} cards each hand.\n\n" + "You may replace {3} card.\n\n" + "Flushes, all cards in the same suit, automatically win,\n" + "else whoever has the higher scoring hand wins.\n\n" + "Dealer wins on ties. Them's the rules.\n\n" + "Press Enter to play your first hand.", balance, BET, howManyCards, DISCARD_CARDS); Console.ReadLine(); // Pause for reading. // Loop until player's out of money while (balance > 0) { // Clear the screen Console.Clear(); // Shuffle the cards myDeck.ShuffleCards(totalCardsDrawn); // Generate new hands for each player computerHand = myDeck.GetCards(howManyCards); playersHand = myDeck.GetCards(howManyCards); // Sort the hands by suit and rank Array.Sort(computerHand); Array.Sort(playersHand); // Display the hands DisplayHands(computerHand, playersHand); // Allow players to change a card ComputerDrawsOne(computerHand, myDeck); PlayerDrawsOne(playersHand, myDeck); // Re-sort the hands & re-display to show any new cards Array.Sort(computerHand); Array.Sort(playersHand); Console.Clear(); DisplayHands(computerHand, playersHand); // Compare the hands won = CompareHands(computerHand, playersHand); // Display the winner and adjust the player's balance if (won) { balance += BET; // Player won the pot Console.WriteLine("You win!"); //++handsWon; // Track wins for grins } else { balance -= BET; // Computer won the pot Console.WriteLine("Dealer wins."); } // Just 'cause I'm curious //Console.WriteLine( // "\nYou've won {0} out of {1} hands played", // handsWon, ++handsPlayed); // If the player can still play, display balance and // wait for User to press Enter if (balance > 0) { Console.Write( "\nYour balance is now ${0,-3} " + "Press Enter for another hand" , balance); Console.ReadLine(); // Let User decide to continue } } Console.WriteLine( "Sorry, you are out of funds. Please come again soon!"); Console.ReadLine(); // Pause for reading. }
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(); } }
static void Main(string[] args) { // a. Create an instance of your CardSet class, and call it myDeck. CardSet myDeck = new CardSet(); // b. Build a loop that does a Console.WriteLine 52 times. //creating howmanyCard int howManyCards = 3; //players balance int balance = 10; //setting the screen color Console.ForegroundColor = ConsoleColor.Yellow; Console.BackgroundColor = ConsoleColor.DarkBlue; Console.WriteLine("Welcome to the Poker Game."); Console.WriteLine("you have $10 and each bet will be $1."); Console.WriteLine("Press any key when you are ready to start."); Console.ReadLine(); while (balance > 0) { //calling the mehods SuperCard[] computerHand = myDeck.GetCards(howManyCards); SuperCard[] playersHand = myDeck.GetCards(howManyCards); //sorting the card Array.Sort(computerHand); Array.Sort(playersHand); //displaying the cards DisplayHands(computerHand, playersHand); //setting the colors again Console.ForegroundColor = ConsoleColor.Yellow; Console.BackgroundColor = ConsoleColor.DarkBlue; //comparing the cards Console.WriteLine(); bool won = CompareHands(computerHand, playersHand); if (won) { Console.WriteLine("Congrats! You won the game"); balance += 1; } else { Console.WriteLine("Sorry! You lost the game"); balance -= 1; } //decreasing the balance Console.WriteLine("your new balance is {0}", balance); Console.WriteLine("please press Enter to play another round"); Console.ReadLine(); } Console.WriteLine("your balance is now zero."); // end of program Console.ReadLine(); }
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(); }