Exemple #1
0
 public PokerHand(string hand)
 {
     cards = new Card[5];
     string[] StrCards = hand.Split(new char[] { ' ' });
     for (int i = 0; i < cards.Length; ++i)
     {
         cards[i] = new Card(StrCards[i]);
     }
     Value = new ShowDown(cards);
 }
Exemple #2
0
        public Result CompareWith(PokerHand hand)
        {
            Result result = Result.Win;

            if (Value.value < hand.Value.value)
            {
                result = Result.Win;
            }
            else if (Value.value > hand.Value.value)
            {
                result = Result.Loss;
            }
            else if (Value.value == hand.Value.value)
            {
                if (Value.top > hand.Value.top)
                {
                    result = Result.Win;
                }
                else if (Value.top < hand.Value.top)
                {
                    result = Result.Loss;
                }
                else if (Value.top == hand.Value.top)
                {
                    int i = ShowDown.Compare(cards, hand.cards);
                    if (i > 0)
                    {
                        result = Result.Win;
                    }
                    else if (i < 0)
                    {
                        result = Result.Loss;
                    }
                    else if (i == 0)
                    {
                        result = Result.Tie;
                    }
                }
            }
            return(result);
        }