예제 #1
0
        public virtual List <PokerDetailInformation> GetWinner(PokerDetailInformation detail1, PokerDetailInformation detail2)
        {
            var list1         = detail1.CardDetail.ToOrderByDescendingList();
            var list2         = detail2.CardDetail.ToOrderByDescendingList();
            var compareResult = list1.CompareTo(list2);

            if (compareResult > 0)
            {
                return new List <PokerDetailInformation> {
                           detail1
                }
            }
            ;
            else if (compareResult < 0)
            {
                return new List <PokerDetailInformation> {
                           detail2
                }
            }
            ;
            else
            {
                return new List <PokerDetailInformation> {
                           detail1, detail2
                }
            };
        }
    }
예제 #2
0
 private int GetTheValueOfThreeKind(PokerDetailInformation detail)
 {
     foreach (var info in detail.CardDetail)
     {
         if (info.Value == 3)
         {
             return(info.Key);
         }
     }
     throw new InvalidOperationException("Does not exist three a kind, check the rule first");
 }
예제 #3
0
        private int GetValueOfPair(PokerDetailInformation detail)
        {
            var currentValue = -1;

            foreach (var item in detail.CardDetail)
            {
                // find the biggest value of pair, because it maybe exist two pairs
                if (item.Value == 2 && item.Key > currentValue)
                {
                    currentValue = item.Key;
                }
            }
            if (currentValue < 0)
            {
                throw new InvalidOperationException("Does not exist one pair, check the rule first");
            }

            return(currentValue);
        }
예제 #4
0
        public override List <PokerDetailInformation> GetWinner(PokerDetailInformation detail1, PokerDetailInformation detail2)
        {
            var value1 = GetTheValueOfThreeKind(detail1);
            var value2 = GetTheValueOfThreeKind(detail2);

            if (value1 == value2)
            {
                return(base.GetWinner(detail1, detail2));
            }
            else if (value1 > value2)
            {
                return new List <PokerDetailInformation> {
                           detail1
                }
            }
            ;
            else
            {
                return new List <PokerDetailInformation> {
                           detail2
                }
            };
        }
예제 #5
0
 public override List <PokerDetailInformation> GetWinner(PokerDetailInformation detail1, PokerDetailInformation detail2)
 {
     return(base.GetWinner(detail1, detail2));
 }