public static HandResult.CardType GetCardType(int cardIndex) { HandResult.CardType type = HandResult.CardType.NONE; if (cardIndex >= 0 && cardIndex <= 12) { type = HandResult.CardType.SPADE; //스페이드 } if (cardIndex >= 13 && cardIndex <= 25) { type = HandResult.CardType.DIAMOND; //다이아몬드 } if (cardIndex >= 26 && cardIndex <= 38) { type = HandResult.CardType.HEART; //하트 } if (cardIndex >= 39 && cardIndex <= 51) { type = HandResult.CardType.CLOVER; //클로버 } return(type); }
public HandResult CheckFlush(int[] cards) { HandResult result = new HandResult(); int i = 0; int j = 0; int count = 0; int matchCount = 0; HandResult.CardType matchType = HandResult.CardType.NONE; for (i = 0; i < cards.Length; i++) { matchCount = 0; for (j = 0; j < cards.Length; j++) { if (cards[j] == -1) { continue; } if (GetCardType(cards[i]) == GetCardType(cards[j])) { if (matchCount == 4) { matchType = GetCardType(cards[i]); result.AddMadeCard(cards[i]); result.AddMadeCard(cards[j]); } matchCount++; } } if (matchCount >= 5) { result.handType = HandResult.HandType.FLUSH; result.cardType = matchType; count = 0; for (j = 0; j < cards.Length; j++) { if (GetCardType(cards[j]) == matchType) { result.hands[count] = cards[j] % 13; if (result.hands[count] == 0) { result.hands[count] = 13; } count++; } } Array.Sort <int>(result.hands); Array.Reverse(result.hands); } } return(result); }