예제 #1
0
        public int CompareTo(IHand other)
        {
            var otherOnePair = other as OnePair;

            if (otherOnePair == null)
            {
                throw new InvalidOperationException();
            }

            if (PairRank != otherOnePair.PairRank)
            {
                return(PairRank.CompareTo(otherOnePair.PairRank));
            }

            for (int i = 0; i < 3; i++)
            {
                if (SingleRanks[i] != otherOnePair.SingleRanks[i])
                {
                    return(SingleRanks[i].CompareTo(otherOnePair.SingleRanks[i]));
                }
            }

            return(0);
        }
예제 #2
0
        public override int CompareToOffsuitHand(OffsuitHandBase other)
        {
            var otherOnePair = other as OnePair;

            if (otherOnePair == null)
            {
                return(HandRank.CompareTo(other.HandRank));
            }

            if (PairRank != otherOnePair.PairRank)
            {
                return(PairRank.CompareTo(otherOnePair.PairRank));
            }
            if (Kicker1 == otherOnePair.Kicker1)
            {
                return(Kicker1.CompareTo(otherOnePair.Kicker1));
            }
            if (Kicker2 == otherOnePair.Kicker2)
            {
                return(Kicker2.CompareTo(otherOnePair.Kicker2));
            }

            return(Kicker3.CompareTo(otherOnePair.Kicker3));
        }