예제 #1
0
  public static int getHandValue(long cards) {

    List<Card> cardList = BinaryConverter.longToCards(cards);
    PokerHandUtil phu = new PokerHandUtil(cardList);
    Hand bestHand = phu.getBestHand();

    int rankSum = 0;
    int factor = 10;
    for (Card c : bestHand.getCards()) {
      rankSum += c.getRank().getOrderValue() * factor;
      factor--;
      factor--;
    }

    return bestHand.getPokerHand().getOrderValue() * HAND_FACTOR + rankSum;
  }
예제 #2
0
        @Override
        public int compare(final Card first, final Card second) {

          final String firstVal = first.getSuit().getShortName();
          final String secondVal = second.getSuit().getShortName();

          final int comparison = firstVal.compareTo(secondVal);
          if (comparison == 0) {
            final Integer firstIntVal = Integer.valueOf(first.getRank().getOrderValue());
            final Integer secondIntVal = Integer.valueOf(second.getRank().getOrderValue());

            return firstIntVal.compareTo(secondIntVal);
          }

          return comparison;
        }