Polish table and clarify showdown results
This commit is contained in:
@@ -78,6 +78,47 @@ class ActionButtonsTest {
|
||||
assertFalse(buttonsFor(offer(canRaise = false)).showRaise)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `raise presets use the pot after calling and legal raise-to amounts`() {
|
||||
val decision = offer(
|
||||
toCall = 10,
|
||||
minRaiseTo = 20,
|
||||
maxRaiseTo = 500,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
listOf(
|
||||
RaisePreset("Min", 20),
|
||||
RaisePreset("½ pot", 35),
|
||||
RaisePreset("Pot", 60),
|
||||
RaisePreset("All in", 500),
|
||||
),
|
||||
raisePresets(decision),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `raise presets drop clamped duplicates instead of mislabelling them`() {
|
||||
val decision = offer(
|
||||
toCall = 10,
|
||||
minRaiseTo = 45,
|
||||
maxRaiseTo = 50,
|
||||
stack = 50,
|
||||
)
|
||||
|
||||
assertEquals(
|
||||
listOf(RaisePreset("Min", 45), RaisePreset("All in", 50)),
|
||||
raisePresets(decision),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a single legal shove has one all-in preset`() {
|
||||
val decision = offer(minRaiseTo = 200, maxRaiseTo = 120, stack = 120)
|
||||
|
||||
assertEquals(listOf(RaisePreset("All in", 120)), raisePresets(decision))
|
||||
}
|
||||
|
||||
// ---------- fold and call ----------
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package com.jsjdesigns.poker
|
||||
|
||||
import com.jsjdesigns.poker.core.HandEvaluator
|
||||
import com.jsjdesigns.poker.core.cardsOf
|
||||
import com.jsjdesigns.poker.game.HandResult
|
||||
import com.jsjdesigns.poker.game.PotAward
|
||||
import com.jsjdesigns.poker.game.PotPayout
|
||||
import com.jsjdesigns.poker.game.ShowdownHand
|
||||
import com.jsjdesigns.poker.game.Street
|
||||
import com.jsjdesigns.poker.game.TableSnapshot
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -20,14 +25,41 @@ class HandSummaryTest {
|
||||
winners: List<Int> = listOf(1),
|
||||
showdown: Boolean = true,
|
||||
pot: Int = 16,
|
||||
) = HandResult(
|
||||
board = intArrayOf(0, 1, 2, 3, 4),
|
||||
net = net,
|
||||
winners = winners,
|
||||
wentToShowdown = showdown,
|
||||
potSize = pot,
|
||||
events = emptyList(),
|
||||
)
|
||||
awards: List<PotAward>? = null,
|
||||
): HandResult {
|
||||
val board = cardsOf("2c 7d 9s Jc 3h")
|
||||
val holes = listOf(cardsOf("Ah Ad"), cardsOf("Kh Kd"), cardsOf("Qh Qd"))
|
||||
return HandResult(
|
||||
board = board,
|
||||
net = net,
|
||||
wentToShowdown = showdown,
|
||||
potSize = pot,
|
||||
events = emptyList(),
|
||||
showdownHands = if (showdown) {
|
||||
winners.map { winner ->
|
||||
val hole = holes[winner]
|
||||
ShowdownHand(
|
||||
seat = winner,
|
||||
hole = hole.toList(),
|
||||
score = HandEvaluator.evaluate(hole + board),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
emptyList()
|
||||
},
|
||||
potAwards = awards ?: listOf(
|
||||
PotAward(
|
||||
amount = pot,
|
||||
payouts = winners.mapIndexed { index, winner ->
|
||||
PotPayout(
|
||||
winner,
|
||||
pot / winners.size + if (index < pot % winners.size) 1 else 0,
|
||||
)
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `summary names the winner and reports the hero's actual net`() {
|
||||
@@ -76,6 +108,43 @@ class HandSummaryTest {
|
||||
assertTrue(summary.heroWon)
|
||||
assertTrue(summary.detail.endsWith("You broke even"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `side pots name each award and the winning made hand`() {
|
||||
val board = cardsOf("2c 7d 9s Jc 3h")
|
||||
val aces = cardsOf("Ah Ad")
|
||||
val kings = cardsOf("Kh Kd")
|
||||
val result = HandResult(
|
||||
board = board,
|
||||
net = intArrayOf(100, 100, -200),
|
||||
wentToShowdown = true,
|
||||
potSize = 450,
|
||||
events = emptyList(),
|
||||
showdownHands = listOf(
|
||||
ShowdownHand(0, aces.toList(), HandEvaluator.evaluate(aces + board)),
|
||||
ShowdownHand(1, kings.toList(), HandEvaluator.evaluate(kings + board)),
|
||||
),
|
||||
potAwards = listOf(
|
||||
PotAward(150, listOf(PotPayout(0, 150))),
|
||||
PotAward(300, listOf(PotPayout(1, 300))),
|
||||
),
|
||||
)
|
||||
|
||||
val summary = handSummaryFor(
|
||||
handNumber = 11,
|
||||
result = result,
|
||||
seatNames = listOf("Jay", "Ada", "Bruno"),
|
||||
)
|
||||
|
||||
assertEquals("Main pot", summary.awards[0].label)
|
||||
assertEquals(150, summary.awards[0].amount)
|
||||
assertEquals("You", summary.awards[0].winners.single().label)
|
||||
assertEquals(150, summary.awards[0].winners.single().amountWon)
|
||||
assertEquals("Pair", summary.awards[0].winners.single().handDescription)
|
||||
assertEquals("Side pot 1", summary.awards[1].label)
|
||||
assertEquals("Ada", summary.awards[1].winners.single().label)
|
||||
assertEquals(kings.toList(), summary.awards[1].winners.single().hole)
|
||||
}
|
||||
}
|
||||
|
||||
class VisibleHandSummaryTest {
|
||||
@@ -87,6 +156,7 @@ class VisibleHandSummaryTest {
|
||||
potSize = 20,
|
||||
heroNet = -4,
|
||||
wentToShowdown = true,
|
||||
awards = emptyList(),
|
||||
)
|
||||
|
||||
private fun snapshot(
|
||||
|
||||
Reference in New Issue
Block a user