private void DetermineHand()
        {
            GameRules ruler  = new GameRules();
            Player    winner = ruler.HandWinner(allPlayers, out HandValue hand);

            scores[winner] = scores[winner] + 1;
            Console.WriteLine($"{winner.Name} wins with {hand.Type}");
            Console.WriteLine();
        }
Esempio n. 2
0
        public override void ReplaceCard(CardDeck deck)
        {
            GameRules  rules   = new GameRules();
            HandValue  myVal   = rules.DetermineHand(Hand.SortedCards);
            List <int> replace = new List <int>();

            switch (myVal.Type)
            {
            case HandType.HighCard:     //replace the three smallest cards
                for (int index = Hand.Count - 1; index > 1; index--)
                {
                    replace.Add(Hand.Cards.IndexOf(Hand.SortedCards[index]));
                }
                break;

            case HandType.Pair:
                for (int index = 0; index < Hand.Count; index++)
                {
                    if (Hand.Cards[index].Rank != myVal.HighestPair)
                    {
                        replace.Add(index);
                    }
                }
                break;

            case HandType.TwoPair:
                for (int index = 0; index < Hand.Count; index++)
                {
                    if (Hand.Cards[index].Rank != myVal.HighestPair && Hand.Cards[index].Rank != myVal.LowestPair)
                    {
                        replace.Add(index);
                    }
                }
                break;

            case HandType.ThreeOfAKind:
                for (int index = 0; index < Hand.Count; index++)
                {
                    if (Hand.Cards[index].Rank != myVal.HighestPair)
                    {
                        replace.Add(index);
                    }
                }
                break;

            default:
                return;
            }
            foreach (int cardIndex in replace)
            {
                Hand.RemoveCard(cardIndex);
                Hand.AddCard(deck.Draw, cardIndex);
            }
        }
        private Player Winner()
        {
            GameRules ruler = new GameRules();

            return(ruler.DetermineWinner(scores));
        }