예제 #1
0
  @Test
  public void testTwoPairHandBeatsOnePairOpponents1() {

    board.add(new Card(TEN, SPADES));
    board.add(new Card(SEVEN, HEARTS));
    board.add(new Card(NINE, HEARTS));
    board.add(new Card(NINE, CLUBS));
    board.add(new Card(FOUR, SPADES));

    deal(0, FOUR, DIAMONDS);
    deal(0, QUEEN, DIAMONDS);

    deal(1, FIVE, DIAMONDS);
    deal(1, TEN, CLUBS);

    deal(2, NINE, SPADES);
    deal(2, QUEEN, SPADES);

    deal(3, SEVEN, SPADES);
    deal(3, TEN, DIAMONDS);

    this.result = getHoldemGame().end();

    assertEquals(4, result.getPlayerResults().length);

    assertEquals(getPlayerByIndex(0), getPlayerWithRankOf(FORTH));
    assertEquals(getPlayerByIndex(1), getPlayerWithRankOf(THIRD));
    assertEquals(getPlayerByIndex(2), getPlayerWithRankOf(WINNER));
    assertEquals(getPlayerByIndex(3), getPlayerWithRankOf(SECOND));
  }
예제 #2
0
  @Test
  public void testStraightBeatsTwoPairHand() {

    board(EIGHT, SPADES);
    board(TWO, HEARTS);
    board(FOUR, CLUBS);
    board(FIVE, SPADES);
    board(QUEEN, SPADES);

    deal(0, JACK, HEARTS);
    deal(0, ACE, DIAMONDS);

    deal(1, TWO, CLUBS);
    deal(1, FIVE, DIAMONDS);

    deal(2, THREE, SPADES);
    deal(2, EIGHT, CLUBS);

    deal(3, SIX, DIAMONDS);
    deal(3, SEVEN, SPADES);

    this.result = getHoldemGame().end();

    assertEquals(4, result.getPlayerResults().length);

    assertEquals(getPlayerByIndex(0), getPlayerWithRankOf(FORTH));
    assertEquals(getPlayerByIndex(1), getPlayerWithRankOf(SECOND));
    assertEquals(getPlayerByIndex(2), getPlayerWithRankOf(THIRD));
    assertEquals(getPlayerByIndex(3), getPlayerWithRankOf(WINNER));
  }
예제 #3
0
  @Test
  public void testStraightHandScoring() {
    board(FOUR, CLUBS);
    board(SEVEN, CLUBS);
    board(THREE, CLUBS);
    board(NINE, CLUBS);
    board(QUEEN, HEARTS);

    deal(0, THREE, HEARTS);
    deal(0, EIGHT, HEARTS);

    deal(1, SEVEN, DIAMONDS);
    deal(1, SEVEN, SPADES);

    deal(2, SIX, CLUBS);
    deal(2, EIGHT, DIAMONDS);

    deal(3, FOUR, HEARTS);
    deal(3, JACK, CLUBS);

    this.result = getHoldemGame().end();

    assertEquals(4, result.getPlayerResults().length);

    assertEquals(getPlayerByIndex(0), getPlayerWithRankOf(FORTH));
    assertEquals(getPlayerByIndex(1), getPlayerWithRankOf(THIRD));
    assertEquals(getPlayerByIndex(2), getPlayerWithRankOf(SECOND));
    assertEquals(getPlayerByIndex(3), getPlayerWithRankOf(WINNER));
  }
예제 #4
0
  @Test
  public void testThreeOfAKindBeatsTwoPairHand() {

    board.add(new Card(FIVE, HEARTS));
    board.add(new Card(QUEEN, SPADES));
    board.add(new Card(THREE, DIAMONDS));
    board.add(new Card(NINE, CLUBS));
    board.add(new Card(QUEEN, CLUBS));

    deal(0, JACK, DIAMONDS);
    deal(0, KING, HEARTS);

    deal(1, FOUR, HEARTS);
    deal(1, FIVE, SPADES);

    deal(2, QUEEN, HEARTS);
    deal(2, EIGHT, SPADES);

    deal(3, SIX, SPADES);
    deal(3, ACE, CLUBS);

    this.result = getHoldemGame().end();

    assertEquals(4, result.getPlayerResults().length);

    assertEquals(getPlayerByIndex(0), getPlayerWithRankOf(FORTH));
    assertEquals(getPlayerByIndex(1), getPlayerWithRankOf(SECOND));
    assertEquals(getPlayerByIndex(2), getPlayerWithRankOf(WINNER));
    assertEquals(getPlayerByIndex(3), getPlayerWithRankOf(THIRD));
  }
예제 #5
0
 private Player getPlayerWithRankOf(ResultRanking rank) {
   return result.getPlayerResults()[result.getPlayerResults().length - 1 - rank.ordinal()][0]
       .getPlayer();
 }