package com.poker.analyst.analyser.combanalyzer;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import com.poker.analyst.analyser.CardComparator;
import com.poker.analyst.combination.FourOfKind;
import com.poker.analyst.combination.Pair;
import com.poker.analyst.combination.ThreeOfKind;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.CardFace;
import com.poker.analyst.element.CardPositionType;
import com.poker.analyst.element.PlayingCards;
import com.poker.analyst.element.Suit;
public class SmthOfKing {
public static List<ThreeOfKind> analyse3OfKing(PlayingCards plCards){
Set<Card> allCards = new TreeSet<Card>(new CardComparator());
for (Card card: plCards.getPlayerCards())
if (card != null) allCards.add(card);
for (Card card: plCards.getTableCards())
if (card != null) allCards.add(card);
return analyse3OfKing(allCards, plCards);
}
public static List<FourOfKind> analyse4OfKing(PlayingCards plCards){
Set<Card> allCards = new TreeSet<Card>(new CardComparator());
for (Card card: plCards.getPlayerCards())
if (card != null) allCards.add(card);
for (Card card: plCards.getTableCards())
if (card != null) allCards.add(card);
return analyse4OfKing(allCards, plCards);
}
public static List<ThreeOfKind> analyse3OfKing(Set<Card> allCards, PlayingCards plCards){
ThreeOfKind comb = null;
List<ThreeOfKind> combinations= null;
int count = 0;
int i = 0;
CardFace cardFace = null;
for (Card card: allCards){
i++;
if (card.getFace().equals(cardFace))
count++;
else{
if (count == 3){
if (combinations == null) combinations = new ArrayList<ThreeOfKind>();
comb = new ThreeOfKind();
comb.setCombinationList(PairAnalyzer.getListOfCardsByFace(allCards,cardFace));
combinations.add(comb);
}
cardFace = card.getFace();
count = 1;
}
}
if (count == 3){
if (combinations == null) combinations = new ArrayList<ThreeOfKind>();
comb = new ThreeOfKind();
comb.setCombinationList(PairAnalyzer.getListOfCardsByFace(allCards,cardFace));
combinations.add(comb);
}
return combinations;
}
public static List<FourOfKind> analyse4OfKing(Set<Card> allCards, PlayingCards plCards){
FourOfKind comb = null;
List<FourOfKind> combinations= null;
int count = 0;
int i = 0;
CardFace cardFace = null;
for (Card card: allCards){
i++;
if (card.getFace().equals(cardFace))
count++;
else{
if (count == 4){
if (combinations == null) combinations = new ArrayList<FourOfKind>();
comb = new FourOfKind();
comb.setCombinationList(PairAnalyzer.getListOfCardsByFace(allCards,cardFace));
combinations.add(comb);
}
cardFace = card.getFace();
count = 1;
}
}
if (count == 4){
if (combinations == null) combinations = new ArrayList<FourOfKind>();
comb = new FourOfKind();
comb.setCombinationList(PairAnalyzer.getListOfCardsByFace(allCards,cardFace));
combinations.add(comb);
}
return combinations;
}
}