private static void PlayersDrawsOne(SuperCard[] playersHand, CardSet myDeck, SuperCard[] computerHand) { Console.WriteLine("If you want to replace a card type 1-5, The top card is one and the bottom is 5."); Console.WriteLine("Or 0 to keep your hand."); int ui = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); if (ui == 1) { playersHand[0] = myDeck.GetOneCard(); } if (ui == 2) { playersHand[1] = myDeck.GetOneCard(); } if (ui == 3) { playersHand[2] = myDeck.GetOneCard(); } if (ui == 4) { playersHand[3] = myDeck.GetOneCard(); } if (ui == 5) { playersHand[4] = myDeck.GetOneCard(); } else if (ui == 0) { playersHand[0] = playersHand[0]; } }
private static void ComputerDrawsOne(SuperCard[] computerHand, CardSet myDeck) { bool compFlush; compFlush = Flush(computerHand); SuperCard LowestValue = computerHand[0]; int sindex = 0; if (compFlush == false) { for (int index = 0; index < computerHand.Length; ++index) { if (computerHand[index].CardRank < LowestValue.CardRank) { LowestValue = computerHand[index]; sindex = index; } } if (Convert.ToInt32(LowestValue.CardRank) < 8) { computerHand[sindex] = myDeck.GetOneCard(); } } }
private static void ComputerDrawsOne(SuperCard[] computerHand, CardSet myDeck) { SuperCard lowestCard = computerHand[0]; if (Flush(computerHand)) { } else { int a = 0; for (int i = 1; i < computerHand.Length; i++) { if ((int)(computerHand[i].CardRank) < (int)(lowestCard.CardRank)) { lowestCard = computerHand[i]; a = i; } } if ((int)lowestCard.CardRank < 7) { computerHand[a] = myDeck.GetOneCard(); } } }
private static void PlayerDrawsOne(int pHowManyCards, CardSet pMyDeck, SuperCard[] pPlayerHand) { WriteLine("\nWhich card would you like to replace?"); WriteLine($"Enter 1-{pHowManyCards}, or 0 if no cards: "); int a; int.TryParse(ReadLine(), out a); if (a > 0) { pPlayerHand[a - 1] = pMyDeck.GetOneCard(); } }
private static void PlayerDrawsOne(SuperCard[] playersHand, CardSet myDeck) { Console.WriteLine("Which card would you like to replace? Please specify by typing 1, 2, 3, 4, or 5. \nType 0 if you would not like to change any cards."); try { int replace = Convert.ToInt32(Console.ReadLine()); switch (replace) { case 0: Console.WriteLine("You have chosen not to replace any cards"); break; case 1: playersHand[0] = myDeck.GetOneCard(); break; case 2: playersHand[1] = myDeck.GetOneCard(); break; case 3: playersHand[2] = myDeck.GetOneCard(); break; case 4: playersHand[3] = myDeck.GetOneCard(); break; case 5: playersHand[4] = myDeck.GetOneCard(); break; } } catch { Console.WriteLine("Invalid entry, please try again!"); } }
private static void PlayerMulliganCard(SuperCard[] playerHand, CardSet myDeck) { WriteLine($"\nWhich card out of {playerHand.Length} cards would you like to mulligan?"); Write("Press 'Enter' or 0 if none: "); string input = ReadLine(); Int32.TryParse(input, out int cardNumber); if (cardNumber != 0) { playerHand[cardNumber - 1] = myDeck.GetOneCard(cardNumber); } }
private static void PlayerDrawsOne(SuperCard[] hand, CardSet deck) { const int INVALID_CARD = -1; const int STAND_PAT = 0; const int MIN_CARD = 1; int maxCard = hand.Length; int card = INVALID_CARD; do { Console.Write( "Enter {0} to stand pat or {1}-{2} to replace a card: ", STAND_PAT, MIN_CARD, maxCard); // Accept input and convert to integer if (!int.TryParse(Console.ReadLine(), out card)) { // User type in a non-integer, which is caught in next if card = INVALID_CARD; } if (card < STAND_PAT || card > maxCard) { Console.WriteLine("Invalid selection, please try again"); card = INVALID_CARD; // Set to re-prompt } //else if (card == STAND_PAT) //{ // if (!confirmChoice("You are standing pat")) // { // card = INVALID_CARD; // } //} else if (card != STAND_PAT) { --card; // Change to zero-based for array hand[card].Display(); SetScreenColors(); if (confirmChoice("Replace")) { hand[card] = deck.GetOneCard(); } else { card = INVALID_CARD; // Set to re-prompt } } } while (card == INVALID_CARD); }
private static void ComputerDrawsOne(SuperCard[] computerHand, CardSet myDeck) { // loops thru indexes of computerHand array from 0 - (max - 1) to find lowest ranking card int lowRankIndex = 0; int lowestRank = (int)computerHand[0].CardsRank; for (int i = 0; i < computerHand.Length - 1; i++) { if (lowestRank > (int)computerHand[i].CardsRank) { lowRankIndex = i; lowestRank = (int)computerHand[i].CardsRank; } } // does not run GetOneCard method if lowestRank value is greater than 7 if (lowestRank <= 7 && Flush(computerHand) == false) { computerHand[computerHand.Length - 1] = myDeck.GetOneCard(); } }
private static void ComputerMulliganCard(SuperCard[] computerHand, CardSet myDeck) { if (!Flush(computerHand)) { int index = 0; int count = 0; SuperCard currentLowestCard = new CardClub(Rank.Ace); foreach (SuperCard card in computerHand) { if ((int)card.CardRank < 8 && (int)card.CardRank < (int)currentLowestCard.CardRank) { index = count; } count++; } computerHand[index] = myDeck.GetOneCard(index); } }
private static void ComputerDrawsOne(SuperCard[] hand, CardSet deck) { const Rank THESHOLD = Rank.Seven; int lowest = 0; if (!Flush(hand)) { // Find the lowest scoring card for (int card = 1; card < hand.Length; ++card) { if (hand[card].cardsRank < hand[lowest].cardsRank) { lowest = card; } } // Does it meet a threshold of 7 points? if (hand[lowest].cardsRank < THESHOLD) { hand[lowest] = deck.GetOneCard(); } } }