Skip to content

Commit 076e36d

Browse files
committed
- table_no_cell.rs:1714 — self.bet = self.forced.big_blind → self.bet = actual
- table.rs:516 — self.bet.set(self.forced.big_blind) → self.bet.set(actual) - Updated 4 existing tests that encoded the old incorrect semantics (assertions changed from 100 to 30) - Added 1 new regression test table_no_cell_to_call_capped_at_short_stack_bb
1 parent c8c5c72 commit 076e36d

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pkcore"
33
description = "Prototype core poker library."
4-
version = "0.0.47"
4+
version = "0.0.48"
55
rust-version = "1.94.1"
66
edition = "2024"
77
authors = ["electronicpanopticon <gaoler@electronicpanopticon.com>"]

src/casino/table.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ impl TableCelled {
513513
pub fn act_forced_bet_big_blind(&self) -> Result<(), PKError> {
514514
let bb_seat_num = self.determine_big_blind();
515515
let actual = self.act_forced_bet(bb_seat_num, self.forced.big_blind)?;
516-
self.bet.set(self.forced.big_blind);
516+
self.bet.set(actual);
517517
self.log_info(TableAction::ForcedBetBigBlind(bb_seat_num, actual));
518518
self.action_to_next();
519519

@@ -2472,7 +2472,8 @@ mod casino__table_tests {
24722472

24732473
#[test]
24742474
fn forced_bets_short_bb_to_call_full_amount() {
2475-
// BB (seat 2) has only 30 chips; UTG (seat 0) must still call the full 100 BB.
2475+
// BB (seat 2) has only 30 chips; UTG (seat 0) calls only what BB posted (30),
2476+
// not the configured blind (100).
24762477
let table = three_player_table_with_short_bb(30);
24772478
table.act_forced_bets().unwrap();
24782479

@@ -2481,16 +2482,16 @@ mod casino__table_tests {
24812482
assert_eq!(30, bb_seat.player.bet.count());
24822483
drop(bb_seat);
24832484

2484-
assert_eq!(100, table.to_call(0));
2485+
assert_eq!(30, table.to_call(0));
24852486
}
24862487

24872488
#[test]
24882489
fn act_call_after_short_blind() {
24892490
let table = three_player_table_with_short_bb(30);
24902491
table.act_forced_bets().unwrap();
2491-
// UTG (seat 0) calls — should commit 100 chips.
2492+
// UTG (seat 0) calls — commits only what BB actually posted (30).
24922493
table.act_call(0).unwrap();
24932494
let utg = table.seats.get_seat(0).unwrap();
2494-
assert_eq!(100, utg.player.bet.count());
2495+
assert_eq!(30, utg.player.bet.count());
24952496
}
24962497
}

src/casino/table_no_cell.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ impl TableNoCell {
17111711
pub fn act_forced_bet_big_blind(&mut self) -> Result<(), PKError> {
17121712
let bb = self.determine_big_blind();
17131713
let actual = self.seats.act_forced_bet(bb, self.forced.big_blind)?;
1714-
self.bet = self.forced.big_blind;
1714+
self.bet = actual;
17151715
self.log(TableAction::ForcedBetBigBlind(bb, actual));
17161716
self.log(TableAction::ActionTo(self.next_to_act()));
17171717
Ok(())
@@ -3258,6 +3258,23 @@ mod tests {
32583258
);
32593259
}
32603260

3261+
// Regression: when BB is short-stacked, other players should only need to call
3262+
// what the BB actually posted, not the configured blind amount.
3263+
#[test]
3264+
fn table_no_cell_to_call_capped_at_short_stack_bb() {
3265+
// button=0: seat 0 = UTG/button, seat 1 = SB, seat 2 = BB (short-stacked)
3266+
let seats = SeatsNoCell::new(vec![
3267+
SeatNoCell::new(PlayerNoCell::new_with_chips("UTG".to_string(), 5_000)),
3268+
SeatNoCell::new(PlayerNoCell::new_with_chips("SB".to_string(), 5_000)),
3269+
SeatNoCell::new(PlayerNoCell::new_with_chips("BB".to_string(), 60)), // short-stacked
3270+
]);
3271+
let mut table = TableNoCell::nlh_from_seats(seats, ForcedBets::new(50, 100));
3272+
table.act_forced_bets().unwrap();
3273+
let utg = table.determine_utg();
3274+
// UTG should call 60 (what BB actually posted), not 100 (the configured blind).
3275+
assert_eq!(60, table.to_call(utg));
3276+
}
3277+
32613278
#[test]
32623279
fn table_no_cell_bet_is_zero_before_blinds() {
32633280
let table = make_two_player_table();
@@ -3287,7 +3304,8 @@ mod tests {
32873304

32883305
#[test]
32893306
fn table_no_cell_forced_bets_short_bb_to_call_full_amount() {
3290-
// BB (seat 2) has only 30 chips — posts all-in; UTG (seat 0) must still call 100.
3307+
// BB (seat 2) has only 30 chips — posts all-in; UTG (seat 0) needs to call
3308+
// only what BB actually posted (30), not the configured blind (100).
32913309
let seats = SeatsNoCell::new(vec![
32923310
SeatNoCell::new(PlayerNoCell::new_with_chips("UTG".to_string(), 5_000)),
32933311
SeatNoCell::new(PlayerNoCell::new_with_chips("SB".to_string(), 5_000)),
@@ -3303,12 +3321,12 @@ mod tests {
33033321
let _ = bb;
33043322

33053323
let utg = table.determine_utg();
3306-
assert_eq!(100, table.to_call(utg));
3324+
assert_eq!(30, table.to_call(utg));
33073325
}
33083326

33093327
#[test]
33103328
fn table_no_cell_act_call_after_short_blind() {
3311-
// BB (seat 2) short-stack; UTG (seat 0) calls — commits 100.
3329+
// BB (seat 2) short-stack; UTG (seat 0) calls — commits only what BB posted (30).
33123330
let seats = SeatsNoCell::new(vec![
33133331
SeatNoCell::new(PlayerNoCell::new_with_chips("UTG".to_string(), 5_000)),
33143332
SeatNoCell::new(PlayerNoCell::new_with_chips("SB".to_string(), 5_000)),
@@ -3322,7 +3340,7 @@ mod tests {
33223340
table.act_call(utg).unwrap();
33233341

33243342
let utg_seat = table.seats.get_seat(utg).unwrap();
3325-
assert_eq!(100, utg_seat.player.bet);
3343+
assert_eq!(30, utg_seat.player.bet);
33263344
}
33273345

33283346
// ── Chip audit ────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)