The problem in the if-statement is that it fails, when the cards are not in order.
e.g. AAAKK but not AAKAK

You could solve this problem by checking three cards with the same number first
and...