Beispiel #1
0
 /// <summary>
 /// Compares this to the "other" card.
 /// </summary>
 /// <param name="other"></param>
 /// <returns>+ if greater, 0 if equal, - if less than.</returns>
 public int CompareTo(IStandardCard other)
 {
     if (this.Face == other.Face)
     {
         /**
          * This is a gamble card! Suit should be meaningless!
          *
          * return this.Suit.CompareTo(other.Suit);
          */
         return(0);
     }
     else
     {
         if (this.Face == GambleCardFace.Ace || other.Face == GambleCardFace.Joker)
         {
             //CompareTo always manages to confuse me,
             //but I do know that I want the opposite value if we get an ace, or they have a joker
             //so we swap this and other for this comparison
             return(other.Face.CompareTo(this.Face));
         }
         else if (other.Face == GambleCardFace.Ace || this.Face == GambleCardFace.Joker)
         {
             //CompareTo always manages to confuse me,
             //but I do know that I want our value if they get an ace, or we have a joker
             //So it stays normal, but we isolate it for clarity's sake
             return(this.Face.CompareTo(other.Face));
         }
         else
         {
             //If neither are aces or of any other-same value,
             return(this.Face.CompareTo(other.Face));
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Compares this to the "other" card for equality.
 /// </summary>
 /// <param name="other">Other GambleCard</param>
 /// <returns>Whether other is equal to this.</returns>
 public bool Equals(IStandardCard other)
 {
     return(this.CompareTo(other) == 0);
 }