Package org.cspoker.common.elements.hand

Examples of org.cspoker.common.elements.hand.Hand$UniqueHandHash


        HandType.STRAIGHT.getDescription()));
    assertTrue(hand1.compareTo(hand2) == 0);
  }

  public void testStraightFlushHands() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));

    assertTrue(hand1.getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));

    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SEVEN, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.DIAMONDS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.DIAMONDS));

    assertFalse(hand2.getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));

    // hand1 >hand 2
    hand2 = new Hand();
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FIVE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.TWO, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.THREE, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.HEARTS));
    assertTrue(hand2.getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));
    assertTrue(hand1.compareTo(hand2) == 1);

    // hand1 <hand 2
    hand2 = new Hand();
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.QUEEN, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.JACK, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.TEN, Suit.CLUBS));
    assertTrue(hand2.getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));
    assertTrue(hand1.compareTo(hand2) == -1);

    hand2 = hand1;
    assertTrue(hand2.getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));
    assertTrue(hand1.compareTo(hand2) == 0);
  }
View Full Code Here


    // the player with the single highest card gets the odd chips that can't
    // be divided over the winners
    if (pot.getChips().getValue() != 0) {
      MutableSeatedPlayer playerWithHighestSingleCard = winners.get(0);
      Card highestCard = new Hand(playerWithHighestSingleCard
          .getPocketCards()).getHighestRankCard();
      for (MutableSeatedPlayer player : winners) {
        Card otherHighestCard = new Hand(player.getPocketCards())
        .getHighestRankCard();
        int compareSingleBestCard = highestCard
        .compareTo(otherHighestCard);
        if ((compareSingleBestCard > 0)
            || ((compareSingleBestCard == 0) && (otherHighestCard
View Full Code Here

   */
  private Hand getBestFiveCardHand(MutableSeatedPlayer player) {
    List<Card> cards = new ArrayList<Card>(7);
    cards.addAll(getGame().getCommunityCards());
    cards.addAll(player.getPocketCards());
    return new Hand(cards).getBestFive();
  }
View Full Code Here

        HandType.STRAIGHT_FLUSH.getDescription()));
    assertTrue(hand1.compareTo(hand2) == 0);
  }

  public void testSixCardHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));

    assertTrue(hand1.getBestFive().getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));

    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));

    assertTrue(hand2.getBestFive().getShortDescription().equals(
        HandType.THREE_OF_A_KIND.getDescription()));

    // test hand1>hand 2
    assertTrue(hand1.compareTo(hand2) == 1);

    // test hand1<hand 2

    hand1 = new Hand();
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));

    assertTrue(hand1.compareTo(hand2) == -1);

    // test hand1==hand2
    hand1 = new Hand();
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
View Full Code Here

    assertTrue(hand1.compareTo(hand2) == 0);
  }

  public void testSevenCardHand() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FIVE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.NINE, Suit.SPADES));

    assertTrue(hand1.getBestFive().getShortDescription().equals(
        HandType.STRAIGHT_FLUSH.getDescription()));

    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.FOUR, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.SIX, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.CLUBS));

    assertTrue(hand2.getBestFive().getShortDescription().equals(
        HandType.THREE_OF_A_KIND.getDescription()));

    // test hand1>hand 2
    assertTrue(hand1.compareTo(hand2) == 1);

    // test hand1<hand 2

    hand1 = new Hand();
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.DIAMONDS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.ACE, Suit.HEARTS));

    assertTrue(hand1.compareTo(hand2) == -1);

    // test hand1==hand2
    hand1 = new Hand();
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.FOUR, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.SEVEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.EIGHT, Suit.SPADES));
View Full Code Here

    assertTrue(hand1.compareTo(hand2) == 0);
  }

  public void testAceHighStraightVSKingHighStraight() {
    Hand hand1 = new Hand();
    Hand hand2 = new Hand();

    hand1 = hand1.add(testExactCard.getExactCard(Rank.KING, Suit.HEARTS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.QUEEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.JACK, Suit.CLUBS));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TEN, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.NINE, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.TWO, Suit.SPADES));
    hand1 = hand1.add(testExactCard.getExactCard(Rank.THREE, Suit.DIAMONDS));

    hand2 = hand2.add(testExactCard.getExactCard(Rank.KING, Suit.HEARTS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.QUEEN, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.JACK, Suit.CLUBS));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.TEN, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.NINE, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.ACE, Suit.SPADES));
    hand2 = hand2.add(testExactCard.getExactCard(Rank.THREE, Suit.DIAMONDS));

    assertTrue(hand1.compareTo(hand2) == -1);
  }
View Full Code Here

TOP

Related Classes of org.cspoker.common.elements.hand.Hand$UniqueHandHash

Copyright © 2018 www.massapicom. 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.