Package com.poker.test

Source Code of com.poker.test.TestOdds

package com.poker.test;

import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import com.poker.analyst.element.Board;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.PlayingCards;
import com.poker.analyst.strategy.BoardGenerator;

public class TestOdds {
  public static PlayingCards getPlayingCards(int dim){
    List<Card> cardsList = BoardGenerator.generateCardsList();
    final Set<Card> allCards = new TreeSet<Card>(new CardComparator());
   
    Card[] heroCard = new Card[2];
    Card[] tableCard = new Card[6];
    for (int i = 0; i<2; i++)
      heroCard[i] = BoardGenerator.getCard(cardsList);
   
    for (int i = 0; i<dim; i++)
      tableCard[i] = BoardGenerator.getCard(cardsList);
   
       
    return new PlayingCards(heroCard, tableCard);
  }
 
  public static void main(String[] args) throws Exception {
           
    PlayingCards plCards = getPlayingCards(3);
   
    System.out.println("==================Player:================== ");
    for (Card card: plCards.getPlayerCards())
      System.out.println(card);
    System.out.println("==================TABLE:================== ");
    for (Card card: plCards.getTableCards())
      if (card != null) System.out.println(card);
    System.out.println("========================================== ");
   
   
   
   
   
  }
}

class CardComparator implements Comparator<Card> {

    @Override
    public int compare(final Card arg0, final Card arg1) {

        if (arg0.getFace() == arg1.getFace()) {
            if (arg0.getSuit().ordinal() > arg1.getSuit().ordinal()) {
                return 1;
            } else {
                return -1;
            }
        }
        if (arg0.getFace().ordinal() > arg1.getFace().ordinal()) {
            return -1;
        } else {
            return 1;
        }
    }

}
TOP

Related Classes of com.poker.test.TestOdds

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.