@Test public void testSimpleCase() { // Simple case, player finishes in place 4. // 9.09% of $200 is $18.18 Map<Integer, BigDecimal> balanceAtStart = of(7, bd(70)); List<ConcretePayout> payouts = payoutHandler.calculatePayouts(ImmutableSet.<Integer>of(7), balanceAtStart, 4); assertThat(payouts.get(0).getPayout(), is(bd("18.18"))); }
@Test public void testTwoPlayersOut() { // Two players are out and they had different amounts of chips when the hand started. // 15.15% of $200 is $30.30 Map<Integer, BigDecimal> balanceAtStart = of(7, bd(70), 8, bd(80)); List<ConcretePayout> payouts = payoutHandler.calculatePayouts(ImmutableSet.<Integer>of(7, 8), balanceAtStart, 4); assertThat(payouts.get(0).getPayout(), is(bd("18.18"))); assertThat(payouts.get(1).getPayout(), is(bd("30.30"))); }
@Test public void testThreePlayersOutWithSameStartChips() { // Two players are out and they had different amounts of chips when the hand started. // 7.58% of $200 is $15.16. 15.16 + 18.18 + 30.30 = 63.64 // 63.64 / 3 = 21.21 // 21.21 * 3 = 63.63 => 1 cent remainder Map<Integer, BigDecimal> balanceAtStart = of(7, bd(70), 8, bd(70), 9, bd(70)); List<ConcretePayout> payouts = payoutHandler.calculatePayouts(ImmutableSet.<Integer>of(7, 8, 9), balanceAtStart, 5); assertThat(payouts.get(0).getPayout(), is(bd("21.22"))); assertThat(payouts.get(1).getPayout(), is(bd("21.21"))); assertThat(payouts.get(2).getPayout(), is(bd("21.21"))); }
@Test public void testFourPlayersTwoOfWhichHadTheSameStartingChips() { // Two players are out and they had different amounts of chips when the hand started. // 15.16 + 18.18 = 33.34 // 33.34 / 2 = 16.67 // 6.12% of $200 = 12.24 Map<Integer, BigDecimal> balanceAtStart = of(7, bd(70), 8, bd(70), 9, bd(80), 10, bd(20)); List<ConcretePayout> payouts = payoutHandler.calculatePayouts(ImmutableSet.<Integer>of(7, 8, 10), balanceAtStart, 6); assertThat(payouts.get(0).getPayout(), is(bd("12.24"))); assertThat(payouts.get(1).getPayout(), is(bd("16.67"))); assertThat(payouts.get(2).getPayout(), is(bd("16.67"))); assertThat(payouts.get(3).getPayout(), is(bd("30.30"))); }