示例#1
0
        private void CheckForStraight(IPlayer player, ICard[] allSevenCards)
        {
            if (player.HandFactor >= TypeOfTheHand.HighCard)
            {

                ICard[] distinctCards = allSevenCards.GroupBy(card => card.Value).Select(c => c.First()).ToArray();

                for (int j = 0; j < distinctCards.Length - 4; j++)
                {
                    if (distinctCards[j].Value + 4 == distinctCards[j + 4].Value)
                    {
                        player.HandFactor = TypeOfTheHand.Straight;
                        player.Power = (int)distinctCards.Max(card => card.Value) + (int)player.HandFactor * GlobalConstants.FactorForCalculatingThePower;
                        this.AddHand(player);

                    }

                    if (distinctCards[j].Value == ValueOfCard.Ten &&
                        distinctCards[j + 1].Value == ValueOfCard.Jack &&
                        distinctCards[j + 2].Value == ValueOfCard.Queen &&
                        distinctCards[j + 3].Value == ValueOfCard.King &&
                        distinctCards[j + 4].Value == ValueOfCard.Ace)
                    {
                        player.HandFactor = TypeOfTheHand.Straight;
                        player.Power = (int)ValueOfCard.Ace + (int)player.HandFactor * GlobalConstants.FactorForCalculatingThePower;
                        this.AddHand(player);
                    }
                    
                    if (distinctCards[j].Value == ValueOfCard.Two &&
                        distinctCards[j + 1].Value == ValueOfCard.Three &&
                        distinctCards[j + 2].Value == ValueOfCard.Four &&
                        distinctCards[j + 3].Value == ValueOfCard.Five &&
                        distinctCards[j + 4].Value == ValueOfCard.Ace)
                    {
                        player.HandFactor = TypeOfTheHand.Straight;
                        player.Power = (int)ValueOfCard.Five + (int)player.HandFactor * GlobalConstants.FactorForCalculatingThePower;
                        this.AddHand(player);
                    }
                }
            }
        }