/** * Test for issue #19. When one player is all-in and the other decides to raise, getNumToAct * should be 0 for this round. */ @Test public void testNumToActAllInRaise() { PublicGameInfo gameInfo = new PublicGameInfo(); gameInfo.setBlinds(0.01, 0.02); gameInfo.setNumSeats(3); gameInfo.setPlayer(0, PublicPlayerInfo.create("player1", 100, null)); gameInfo.setPlayer(1, PublicPlayerInfo.create("player2", 100, null)); gameInfo.setPlayer(2, PublicPlayerInfo.create("player3", 200, null)); gameInfo.newHand(0, 1, 2); gameInfo.update(Action.smallBlindAction(0.01), 1); gameInfo.update(Action.bigBlindAction(0.02), 2); gameInfo.update(Action.foldAction(0.02), 0); gameInfo.update(Action.callAction(0.01), 1); // flop // ------- gameInfo.nextStage(new Hand("8s 8c 8h")); assertEquals(2, gameInfo.getNumToAct()); gameInfo.update(Action.betAction(99.98), 1); // all-in assertEquals(1, gameInfo.getNumToAct()); gameInfo.update(Action.raiseAction(99.98, 50), 2); // strange raise, but the other one is all-in so noone to act anymore assertEquals(0, gameInfo.getNumToAct()); }
/** * tests correct working of the {@link GameInfo#getNumToAct()} method. We play a game to the turn * and check for correct results<br> * - preflop: is complicated, because SB+BB count double (posting the blinds and calling/checking) * - flop: all check - turn: a bet and a reraise - getNumToAct alternates */ @Test public void testNumToAct() { PublicGameInfo gameInfo = new PublicGameInfo(); gameInfo.setBlinds(0.01, 0.02); gameInfo.setNumSeats(4); gameInfo.setPlayer(0, PublicPlayerInfo.create("player1", 100, null)); gameInfo.setPlayer(1, PublicPlayerInfo.create("player2", 100, null)); gameInfo.setPlayer(2, PublicPlayerInfo.create("player3", 100, null)); gameInfo.setPlayer(3, PublicPlayerInfo.create("player4", 100, null)); gameInfo.newHand(0, 1, 2); // preflop // ------- // as long as noone calls, we wait for everyone to the SB: // (player1: post SB, player2: post BB, player3: ??, player0: ??, player(SB): ??) assertEquals(5, gameInfo.getNumToAct()); gameInfo.update(Action.smallBlindAction(0.01), 1); assertEquals(4, gameInfo.getNumToAct()); gameInfo.update(Action.bigBlindAction(0.02), 2); // pl-3: ??, pl-0: ??, pl-1 (SB): ??, assertEquals(3, gameInfo.getNumToAct()); // now someone calls - this make the bigblind need to check gameInfo.update(Action.callAction(0.02), 3); // pl-0: ??, pl-1 (SB): ??, pl-2(BB) (check/raise??) assertEquals(3, gameInfo.getNumToAct()); gameInfo.update(Action.callAction(0.02), 0); assertEquals(2, gameInfo.getNumToAct()); gameInfo.update(Action.callAction(0.01), 1); gameInfo.update(Action.checkAction(), 2); assertEquals(0, gameInfo.getNumToAct()); // flop // ------- gameInfo.nextStage(new Hand("8s 8c 8h")); // 4 players, all check assertEquals(4, gameInfo.getNumToAct()); gameInfo.update(Action.checkAction(), 1); gameInfo.update(Action.checkAction(), 2); assertEquals(2, gameInfo.getNumToAct()); gameInfo.update(Action.checkAction(), 3); gameInfo.update(Action.checkAction(), 0); assertEquals(0, gameInfo.getNumToAct()); // turn // ------- gameInfo.nextStage(new Hand("8d")); // 4 players, 2 check, 1 raise, all other have to call assertEquals(4, gameInfo.getNumToAct()); gameInfo.update(Action.checkAction(), 1); gameInfo.update(Action.checkAction(), 2); assertEquals(2, gameInfo.getNumToAct()); // one bet, so remaining 3 have to call (or fold) gameInfo.update(Action.betAction(0.2), 3); assertEquals(3, gameInfo.getNumToAct()); gameInfo.update(Action.callAction(0.02), 0); gameInfo.update(Action.foldAction(0.02), 1); assertEquals(1, gameInfo.getNumToAct()); // reraise - one folded so two are left to call gameInfo.update(Action.raiseAction(0.02, 0.02), 2); assertEquals(2, gameInfo.getNumToAct()); gameInfo.update(Action.callAction(0.02), 3); gameInfo.update(Action.callAction(0.02), 0); assertEquals(0, gameInfo.getNumToAct()); }