コード例 #1
0
  @Test
  public void three_players_2SplitPots() throws Exception {
    gotoStep(BETS_4);
    int previousPot = 30;
    assertEquals(90, player1.getChips());
    assertEquals(70, player2.getChips());
    assertEquals(50, player3.getChips());
    assertEquals(3, tableFacade.getRaisesRemaining());
    assertCurrentBets(0, 0, 0, 0, previousPot);

    // BET4 --> first bets
    bet(player1, game, 20);
    assertEquals(70, player1.getChips());
    assertCurrentBets(20, 0, 0, 20, 20 + previousPot);

    call(player2, game);
    assertEquals(50, player2.getChips());
    assertCurrentBets(20, 20, 0, 20, 40 + previousPot);

    raise(player3, game, 20);
    assertEquals(10, player3.getChips());
    assertEquals(2, tableFacade.getRaisesRemaining());
    assertCurrentBets(20, 20, 40, 40, 80 + previousPot);

    // BET4 --> second bets (cause of a raise)
    raise(player1, game, 20);
    assertEquals(1, tableFacade.getRaisesRemaining());
    assertEquals(30, player1.getChips());
    assertCurrentBets(60, 20, 40, 60, 120 + previousPot);

    call(player2, game);
    assertEquals(10, player2.getChips());
    assertCurrentBets(60, 60, 40, 60, 160 + previousPot);

    allIn(player3, game);
    assertEquals(0, player3.getChips());
    assertCurrentBets(60, 60, 50, 60, 170 + previousPot);

    List<SplitPot> splitPots = game.getPot().buildSplitPots();
    assertEquals(2, splitPots.size());
    SplitPot firstPot = splitPots.get(0);
    SplitPot secondPot = splitPots.get(1);
    assertEquals(180, firstPot.getTotal());
    assertEquals(3, firstPot.getPlayers().size());
    assertEquals(20, secondPot.getTotal());
    assertEquals(2, secondPot.getPlayers().size());

    //        game.nextStep();
    assertEquals(SHOWDOWN, game.getStep());

    show(player1, game);
    show(player2, game);
    show(player3, game);
    assertEquals(0, game.getTableFacade().getCurrentStepBet(player1));
    assertEquals(0, game.getTableFacade().getCurrentStepBet(player2));
    assertEquals(0, game.getTableFacade().getCurrentStepBet(player3));
  }
コード例 #2
0
ファイル: PotTest.java プロジェクト: visma/isma-project-poker
  @Test
  public void split_pots() throws Exception {
    Pot pot = new Pot();
    assertEquals(0, pot.getTotal());
    pot.add(toto, 50);
    pot.add(tata, 20);
    pot.add(titi, 50);
    assertEquals(120, pot.getTotal());

    List<SplitPot> splitPots = pot.buildSplitPots();
    assertEquals(2, splitPots.size());

    SplitPot firstPot = splitPots.get(0);
    SplitPot secondPot = splitPots.get(1);
    assertEquals(3, firstPot.getPlayers().size());
    assertTrue(firstPot.getPlayers().contains(toto));
    assertTrue(firstPot.getPlayers().contains(tata));
    assertTrue(firstPot.getPlayers().contains(titi));

    assertEquals(2, secondPot.getPlayers().size());
    assertTrue(secondPot.getPlayers().contains(toto));
    assertFalse(secondPot.getPlayers().contains(tata));
    assertTrue(secondPot.getPlayers().contains(titi));
  }