package com.poker.analyst.test;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.CardFace;
import com.poker.analyst.element.PlayingCards;
import com.poker.analyst.element.Suit;
public class BoardGenerator {
static List<Card> cardsList = new ArrayList<Card>(52);
public BoardGenerator() {
BoardGenerator.cardsList = generateCardsList();
}
public static List<Card> generateCardsList() {
final List<Card> cardsList = new ArrayList<Card>(52);
for (final Suit suit : Suit.values()) {
if (suit.equals(Suit.forAnalyse)) continue;
for (final CardFace cardFace : CardFace.values()) {
cardsList.add(new Card(suit, cardFace));
}
}
return cardsList;
}
private static Card getCard() {
final Random random = new Random(new Date().getTime());
final int number = random.nextInt(cardsList.size());
final Card card = cardsList.get(number);
cardsList.remove(number);
return card;
}
public static Card getCard(List<Card> cardsList) {
final Random random = new Random(new Date().getTime());
final int number = random.nextInt(cardsList.size());
final Card card = cardsList.get(number);
cardsList.remove(number);
return card;
}
public static PlayingCards fillInPlayingCards() {
final Card[] playerCards = new Card[2];
playerCards[0] = getCard();
playerCards[1] = getCard();
final Card[] tableCards = new Card[5];
tableCards[0] = getCard();
tableCards[1] = getCard();
tableCards[2] = getCard();
tableCards[3] = getCard();
tableCards[4] = getCard();
return new PlayingCards(playerCards, tableCards);
}
}