private PlayedCards GetStartingCards() { var cardsToPlay = new PlayedCards(this); // try to play hands with the most number of cards first. if (Hand.HasMatchingCards(PokerHands.Quadruple)) { IEnumerable <Card> lowestMatchingCards = GetLowestMatchingCards(PokerHands.Quadruple); cardsToPlay.Type = PokerHands.Quadruple; cardsToPlay.AddCards(lowestMatchingCards); } else if (Hand.HasMatchingCards(PokerHands.Triple)) { IEnumerable <Card> lowestMatchingCards = GetLowestMatchingCards(PokerHands.Triple); cardsToPlay.Type = PokerHands.Triple; cardsToPlay.AddCards(lowestMatchingCards); } else if (Hand.HasMatchingCards(PokerHands.Double)) { IEnumerable <Card> lowestMatchingCards = GetLowestMatchingCards(PokerHands.Double); cardsToPlay.Type = PokerHands.Double; cardsToPlay.AddCards(lowestMatchingCards); } else { // we get to start off the hand Card lowestCard = GetLowestCard(); cardsToPlay.Type = PokerHands.Single; cardsToPlay.AddCard(lowestCard); } return(cardsToPlay); }
public override PlayedCards PlayTurn(PlayedCards currentMove) { var cardsToPlay = new PlayedCards(this); // display the cards to the player DisplayCardList(); bool valid = false; do { var stillBuildingHand = true; do { int selectedCardIndex = GetUserSelectedCardIndex(); if (selectedCardIndex >= 0) { Card selectedCard = Hand[selectedCardIndex]; cardsToPlay.AddCard(selectedCard); valid = true; } if (!ContinueBuildingHandPrompt()) { stillBuildingHand = false; } } while (stillBuildingHand); try { // validate the move cardsToPlay.Validate(currentMove); } catch (Exception ex) { cardsToPlay.Clear(); Console.WriteLine("Invalid move: " + ex.Message); valid = false; } } while (valid == false); // play the cards); return(cardsToPlay); }