Quote the real price when a call exceeds the stack

Facing more than you have left is a call for your whole stack — commit() clamps
the commitment — so labelling it "Call 35" when only 20 can be paid promised a
price the player could neither make nor owed. It now reads "All in 20".

The ViewModel also submits the clamped amount rather than relying on the engine
to fix it up, so the action sent never disagrees with the label shown.

Verified by reverting: both new label tests fail.

Tests: 141 -> 144 (64 engine JVM, 64 Android host, 16 app).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jay
2026-07-25 21:53:25 -04:00
parent f0c8a7c430
commit 4f1ef45dd7
3 changed files with 62 additions and 2 deletions
@@ -97,3 +97,48 @@ class ActionButtonsTest {
assertEquals("All in", raiseLabel(b, 500))
}
}
class CallCostTest {
private fun offer(toCall: Int, stack: Int) = DecisionOffer(
token = 1L,
handNumber = 1,
street = Street.RIVER,
seat = 0,
hole = listOf(0, 1),
board = emptyList(),
pot = 100,
toCall = toCall,
minRaiseTo = 999,
maxRaiseTo = stack,
stack = stack,
canCheck = false,
canRaise = false,
)
/**
* Facing more than you have left is a call for your whole stack; the engine
* clamps the commitment. Quoting the full price promised a payment the player
* could not make and did not owe.
*/
@Test
fun `facing more than the stack is labelled as an all in for the stack`() {
val b = buttonsFor(offer(toCall = 35, stack = 20))
assertEquals("All in 20", b.checkOrCallLabel)
assertEquals(20, b.effectiveCall)
}
@Test
fun `calling exactly the stack is also an all in`() {
val b = buttonsFor(offer(toCall = 20, stack = 20))
assertEquals("All in 20", b.checkOrCallLabel)
assertEquals(20, b.effectiveCall)
}
@Test
fun `an affordable call quotes the real price`() {
val b = buttonsFor(offer(toCall = 35, stack = 500))
assertEquals("Call 35", b.checkOrCallLabel)
assertEquals(35, b.effectiveCall)
}
}