Ejemplo n.º 1
0
        private void StraightCheck(GameCard firstCard, GameCard secondCard, GameCard[] cardsOnTable, IPlayer player)
        {
            int firstCardPairs = cardsOnTable.Count(card => firstCard.Rank == card.Rank);
            int secondCardPairs = cardsOnTable.Count(card => secondCard.Rank == card.Rank);
            List<int> allCards = new List<int>();

            if (firstCardPairs == 0)
            {
                if (firstCard.Rank == 14)
                {
                    allCards.Add(firstCard.Rank);
                    allCards.Add(1);
                }
                else
                {
                    allCards.Add(firstCard.Rank);
                }
            }

            if (secondCardPairs == 0)
            {
                if (secondCard.Rank == 14)
                {
                    allCards.Add(secondCard.Rank);
                    allCards.Add(1);
                }
                else
                {
                    allCards.Add(firstCard.Rank);
                }
            }

            if (cardsOnTable.Any(card => card.Rank == 14))
            {
                allCards.Add(1);
            }

            allCards.AddRange(cardsOnTable.Select(card => card.Rank));

            allCards.Sort();

            int countConsecutives = 0;
            int highestCardRankInStreight = 0;

            for (int startCard = 0; startCard < allCards.Count - 1; startCard++)
            {
                if (allCards[startCard] + 1 == allCards[startCard + 1])
                {
                    countConsecutives++;
                    if (countConsecutives >= 5)
                    {
                        highestCardRankInStreight = allCards[startCard + 1];
                    }
                }
            }

            if (countConsecutives < 5)
            {
                return;
            }

            player.PokerHandMultiplier = 4;
            player.CardPower = highestCardRankInStreight * 4 + player.PokerHandMultiplier * 100;
        }