Package com.poker.analyst.combination

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

package com.poker.analyst.combination;

import java.util.List;


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 abstract class Combination {

 
  // for flush and straight
 
 
  List<Card> combinationList;
 
  public abstract CardFace getMinValue();
  public abstract CardFace getMaxValue();
  public abstract List<CardValue> getCardValues(Hand hand);
 
 
   
  //*************************** getters && setters *******************************
 
  public List<Card> getCombinationList() {
    return combinationList;
  }

  public void setCombinationList(List<Card> combinationList) {
    this.combinationList = combinationList;
  }
     
    public Integer getCombinationValue() {
        return -1;
    }
   
    protected List<CardValue> updateCardsRang(List<CardValue> listCardValues){   
    List<Card> listCardComb = getCombinationList();
   
    int first = -1;
    int second = -1;
    CardRangeInComb firstCR = null;
    CardRangeInComb secondCR = null;
    if (listCardValues != null){
      for (int i = 0; i<listCardValues.size();i++){
        if (i == 0) first = listCardValues.get(i).getCardPosition();
        if (i == 1) second = listCardValues.get(i).getCardPosition();
      }     
      if (first != -1){
        if (first == 0
          firstCR = CardRangeInComb.TOP;
        else
          if (first == listCardComb.size())  firstCR = CardRangeInComb.LOW;
        else
          firstCR = CardRangeInComb.MIDDLE;
       
        listCardValues.get(0).setCardRange(firstCR);
      }
     
      if (second != -1){
        if (second == 0
          secondCR = CardRangeInComb.TOP;
        else
          if (first == listCardComb.size())  firstCR = CardRangeInComb.LOW;
        else
          secondCR = CardRangeInComb.MIDDLE;
       
        listCardValues.get(1).setCardRange(secondCR);
      }
     
      if (CardRangeInComb.MIDDLE.equals(firstCR) && CardRangeInComb.LOW.equals(secondCR) ||
          CardRangeInComb.LOW.equals(firstCR) && CardRangeInComb.MIDDLE.equals(secondCR)){
        if (Math.abs(listCardValues.get(0).getCardPosition() -
               listCardValues.get(1).getCardPosition()) == 1){
          listCardValues.get(0).setCardRange(CardRangeInComb.LOW);
          listCardValues.get(1).setCardRange(CardRangeInComb.LOW);
        }
      }               
    }     
    return listCardValues;
  }   

}
TOP

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

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.