Package com.poker.analyst.combination

Source Code of com.poker.analyst.combination.Straight

package com.poker.analyst.combination;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import com.poker.analyst.combination.Combination;
import com.poker.analyst.combinations.auxil.CardRangeInComb;
import com.poker.analyst.combinations.auxil.CardValue;
import com.poker.analyst.element.Card;
import com.poker.analyst.element.CardFace;
import com.poker.analyst.element.Hand;

public class Straight extends Combination {     

 
  List<CardFace> outFaces;
  @Override
  public CardFace getMaxValue() {
    if (this.getCombinationList() != null && this.getCombinationList().size() != 0){
      if (getCombinationList().get(0).getFace().equals(CardFace.ACE) &&
        getCombinationList().get(this.getCombinationList().size() - 1).getFace().equals(CardFace.TWO))
           
        return getCombinationList().get(1).getFace();
      else
        return getCombinationList().get(0).getFace();
    }
    else
      return null;
  }

  @Override
  public CardFace getMinValue() {
    if (this.getCombinationList() != null && this.getCombinationList().size() != 0){
      if (getCombinationList().get(0).getFace().equals(CardFace.ACE) &&
        getCombinationList().get(this.getCombinationList().size() - 1).getFace().equals(CardFace.TWO))
           
        return getCombinationList().get(0).getFace();
      else
        return getCombinationList().get(this.getCombinationList().size() - 1).getFace();
    }
    else
      return null;
  }
 
  public String toString() {
    String str = "Straight of :  [ ";
       
    for (Card card : this.getCombinationList())
      str += card + " ";
   
    str += "] ";
    if (outFaces != null){
      str += ", outs [ ";
      for (CardFace cardFace : this.getOutFaces())
        str += cardFace + " ";
      str += "]";
    }
   
        return str;
    }
 
  @Override
    public Integer getCombinationValue() {
        return 4;
    }

  public List<CardFace> getOutFaces() {
    return outFaces;
  }

  public void setOutFaces(List<CardFace> outFaces) {
    this.outFaces = outFaces;
  }
  @Override
  public List<CardValue> getCardValues(Hand hand) {
    List<CardValue> listCardValues = null;
    CardValue cardValue;
    Card plCard;
    Card cardFromList;
     
    List<Card> listCardComb = getCombinationList();
    CardFace cface = getMinValue();
    for (int i = 0; i< listCardComb.size(); i++){
      cardFromList = listCardComb.get(i);
      for (int q = 0; q<2 ; q++){
        plCard = hand.getHandCards()[q];
        if (cardFromList.getFace().equals(plCard.getFace())){
          if (listCardValues == null) listCardValues = new ArrayList<CardValue>();
          cardValue = new CardValue();
          cardValue.setCard(plCard);
          cardValue.setCardPosition(i);
          cardValue.setCardRange(CardRangeInComb.TOP);
          listCardValues.add(cardValue);
        }
      } 
    }
    return updateCardsRang(listCardValues);
  }
   

}
TOP

Related Classes of com.poker.analyst.combination.Straight

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.