Beispiel #1
0
        public bool IsHandAStraight()
        {
            var orderedHand = DealtHand.OrderBy(x => x.Rank).ToList();

            bool result = false;

            if (DealtHand != null && DealtHand.Count != 0)
            {
                if (orderedHand[0].Rank != Enums.Rank.Ten)
                {
                    if ((int)orderedHand[1].Rank == (int)orderedHand[0].Rank + 1 &&
                        (int)orderedHand[2].Rank == (int)orderedHand[1].Rank + 1 &&
                        (int)orderedHand[3].Rank == (int)orderedHand[2].Rank + 1 &&
                        (int)orderedHand[4].Rank == (int)orderedHand[3].Rank + 1
                        )
                    {
                        result = true;
                    }
                }
                else
                {
                    if ((int)orderedHand[1].Rank == (int)orderedHand[0].Rank + 1 &&
                        (int)orderedHand[2].Rank == (int)orderedHand[1].Rank + 1 &&
                        (int)orderedHand[3].Rank == (int)orderedHand[2].Rank + 1 &&
                        (int)orderedHand[4].Rank == (int)Enums.Rank.Ace
                        )
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        public PlayingCard PlayCard(int cardNr)
        {
            var cardToPlay = DealtHand.FirstOrDefault(x => x.Id == cardNr);

            DealtHand.Remove(cardToPlay);
            return(cardToPlay);
        }
Beispiel #3
0
 public void ChangeCard(List <int> idOfCardsToChange, PlayingCardGame game)
 {
     foreach (var cards in idOfCardsToChange)
     {
         var cardToChange = DealtHand.First(x => x.Id == cards);
         var newCard      = game.PickCardFromDeck();
         newCard.Id = cardToChange.Id;
         DealtHand.Remove(cardToChange);
         DealtHand.Add(newCard);
     }
 }
Beispiel #4
0
 public bool IsHandARoyalFlush() => IsHandAFlush() ? IsHandAStraight() : DealtHand.Max(x => (int)x.Rank) == (int)Enums.Rank.Ace;
Beispiel #5
0
 public bool IsHandAFlush() => DealtHand == null || DealtHand.Count == 0 ? false : DealtHand.All(x => x.Suit == Enums.Suits.Clubs || x.Suit == Enums.Suits.Diamonds || x.Suit == Enums.Suits.Hearts || x.Suit == Enums.Suits.Spades) ? true : false;