package com.poker.analyst.strategy;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
import com.poker.analyst.element.Board;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.CardFace;
import com.poker.analyst.element.Player;
import com.poker.analyst.element.PlayingCards;
import com.poker.analyst.element.Rounds;
import com.poker.analyst.element.Suit;
import com.poker.ui.robot.reaction.UIReaction;
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 Board fillInBoard() {
BoardGenerator.cardsList = generateCardsList();
final Random random = new Random(new Date().getTime());
final PlayingCards cards = fillInPlayingCards();
final Board board = new Board();
final List<Player> players = new ArrayList<Player>();
Player player = null;
final int playerCount = 2 + random.nextInt(8);
for (int i = 0; i < playerCount; i++) {
player = new Player();//(, , 0F, true);
player.setReaction(UIReaction.UIR_ACTION_FOLD);
player.setStack(10F);
player.setBet(0F);
player.setIsInAction(true);
players.add(player);
}
board.setDealer(random.nextInt(playerCount));
board.setHero(random.nextInt(playerCount));
board.setPlayers(players);
board.setPlayingCards(cards);
board.setCurrentRound(Rounds.PREFLOP);
return board;
}
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);
}
}