if (card != null) allCards.add(card);
return analyseFlushDraw(allCards, plCards);
}
public static List<Flush> analyseFlush(Set<Card> allCards, PlayingCards plCards){
Flush comb = null;
List<Flush> combinations = null;
List<Card> combinationList;
Set<Card> allFlushCards = null;
int diamonds = 0;
int clubs = 0;
int spades = 0;
int hearts = 0;
int count = 0;
Suit flushSuit = null;
for (Card card: allCards){
switch (card.getSuit()) {
case clubs: clubs++; break;
case diamonds: diamonds++; break;
case spades: spades++; break;
case hearts: hearts++; break;
default: break;
}
}
count = Math.max(Math.max(clubs, diamonds),Math.max(spades, hearts));
if (clubs >= 5) flushSuit = Suit.clubs;
else
if (diamonds >= 5) flushSuit = Suit.diamonds;
else
if (spades >= 5) flushSuit = Suit.spades;
else
if (hearts >= 5) flushSuit = Suit.hearts;
int i = 0;
Card firstCard = null;
if (count >= 5){
combinations = new ArrayList<Flush>();
allFlushCards = new TreeSet<Card>(new CardComparator());
for (Card card: allCards){
if (card.getSuit().equals(flushSuit))
allFlushCards.add(card);
}
do{
comb = new Flush();
combinationList = new ArrayList<Card>();
i = 0;
firstCard = null;
for (Card card: allFlushCards){
if (i++ >4) break;
if (firstCard == null)
firstCard = card;
combinationList.add(card);
}
comb.setCombinationList(combinationList);
combinations.add(comb);
allFlushCards.remove(firstCard);
}while(allFlushCards.size() >=5 );