Belot.SequentialCombination.CompareTo C# (CSharp) Метод

CompareTo() публичный Метод

Compares current combination to another one
public CompareTo ( object combination ) : int
combination object combination to compare to
Результат int
        public override int CompareTo( object combination )
        {
            if( !(combination is SequentialCombination) )
            {
                throw new InvalidOperationException( "Cannot compare SequentialCombination to an object of different type" );
            }

            int result = 0;

            SequentialCombination comb = combination as SequentialCombination;
            if( this.Points > comb.Points )
            {
                result = 1;
            }
            else if( this.Points < comb.Points )
            {
                result = -1;
            }
            else
            {
                // both combinations are sequential. See biggest card
                CardComparer comparer = new CardComparer( );
                this.Cards.Sort( comparer );
                comb.Cards.Sort( comparer );

                result = comparer.Compare( this.Cards[0], comb.Cards[0] );
            }
            return result;
        }