// Flush 5 increasing same suit N^5 + N^4 + 3*N^3 + type1*N^4 + type2*N^3 static int checkFlush() { int i; int HandCards = 5; int[] sol = new int[HandCards]; for (int j = 0; j <= HAND_CARDS - HandCards; j++) { int count = 1; int id = sol[HandCards - count] = deck[j]; for (i = j + 1; count < HandCards && i < HAND_CARDS; i++) { if (Card.idType(id) > Card.idType(deck[i]) && Card.idSuit(id) == Card.idSuit(deck[i])) { id = sol[HandCards - ++count] = deck[i]; } } if (count == HandCards) { int val = N5 + N4 + 3 * N3, exp = 4; for (int t = 0; t < HandCards && exp >= 0; t++) { val += Card.idType(sol[t]) * Utils.pow(N, exp--); } return(val); } } return(-1); }
// StraightFlush 5 sucessive same suit 2*N^5 + N^4 + 5*N^3 + highest cardtype static int checkStrFlush() { int i, id = 0, mcount = 0, suit = 0, HandCards = 5; int ttj = HAND_CARDS - HandCards + 1; for (int j = 0; j <= ttj; j++) { id = Card.idType(deck[j]); suit = Card.idSuit(deck[j]); mcount = HandCards - 1; for (i = j + 1; mcount != 0 && i < HAND_CARDS && mcount <= HAND_CARDS - i + 1; i++) { if (id == Card.idType(deck[i]) + 1 && suit == Card.idSuit(deck[i])) { mcount--; id = Card.idType(deck[i]); } } if (mcount == 0) { return(2 * N5 + N4 + 5 * N3 + Card.idType(deck[j])); } } // check for low-Ace straight flush if (mcount == 1 && id == (int)CardType.Two && Card.idType(deck[0]) == (int)CardType.A && Card.idSuit(deck[0]) == suit) { return(2 * N5 + N4 + 5 * N3 + Card.idType(deck[HAND_CARDS - HandCards])); } return(-1); }