Reference¶
cardroom.table module¶
cardroom.table implements classes related to poker tables.
This module simply encodes table logic that is time-agnostic. This
entails joining, leaving, and so on WITHOUT timeouts such as auto
check, fold, et cetera. Timings are implemented in
cardroom.controller.
- class cardroom.table.Button(table: Table)¶
Bases:
objectThe class for table buttons.
Unlike its name, this class not only keeps track of button position but also determines who is eligible to play the next hand.
As such, this instance is also relevant in stud games that do not use the button.
- property seat: Seat | None¶
Return the button’s associated seat.
If no seat is associated,
Noneis returned.- Returns:
The associated seat or
None.
- seat_index: int | None = None¶
The seat index at which the button is placed in.
- step() deque[int]¶
Move or place the button and return the seats that contain the players of the next poker game, in order.
- Returns:
The ordered seat indices that can play the next hand.
- class cardroom.table.Seat(table: Table)¶
Bases:
objectThe class for table seats.
- active_status: bool = False¶
The active status (
Falseif idle).
- property index: int¶
Return the seat index (position).
- Returns:
The seat index.
- player_index: int | None = None¶
The player index of the seated player (if playing).
- property player_status: bool¶
Return whether the user in the seat (if any) is involved in the ongoing game (if any).
- Returns:
The player stauts.
- property ready_or_postable_status: bool¶
Return whether the seat is ready to play or ready after posting a post bet.
A post bet is relevant when the person just joined the table but has to wait for the button to pass before being able to play. If they do not want to wait, they can pay the post bet (equivalent to the big blind) and begin play immediately.
They do not need to pay the post bet in games without button like in stud games.
- Returns:
The ready (maybe after posting) status.
- property ready_status: bool¶
Return whether the seat is ready to play even without posting a post bet.
Since the player does not need to pay the post bet, this means the player joined, waited for the button, and the button passed them, allowing them to begin play in the table. Or, they are playing non-button games like stud games.
- Returns:
The ready status.
- starting_stack: int | None = None¶
The starting stack override. When rebuying, buying in, etc., this attribute is updated to reflect the new desired value. If this is none, this attribute is overridden at the and of each hand to reflect the final stacks of the state (if involved in the hand).
- user: str | None = None¶
The user sitting in the seat (if any).
- property user_status: bool¶
Return whether a user is seated in the seat.
- Returns:
The user status.
- wait_status: bool = False¶
The wait status (
Falseif no need to wait before playing).
- class cardroom.table.Table(game: Poker, seat_count: int, min_starting_stack: int, max_starting_stack: int)¶
Bases:
objectThe class for cardroom tables.
- be_back(user: str) None¶
Perform the being back operation.
Being back is akin to resuming or saying “I’m back”.
- Parameters:
user – The user being back.
- Returns:
None.
- buy_rebuy_top_off_or_rat_hole(user: str, starting_stack: int) None¶
Perform the stack overriding operation.
- Parameters:
user – The user overriding their stack.
starting_stack – The new desired stack amount.
- Returns:
None.
- can_be_back(user: str) bool¶
Query the validity of the sitting out operation.
- Parameters:
user – The user sitting out.
- Returns:
Trueif valid, elseFalse.
- can_buy_rebuy_top_off_or_rat_hole(user: str, starting_stack: int | None = None) bool¶
Query the validity of the stack overriding operation.
- Parameters:
user – The user overriding their stack.
starting_stack – The new desired stack amount.
- Returns:
Trueif valid, elseFalse.
- can_change_game(game: Poker) bool¶
Query the validity of the game changing operation.
- Parameters:
game – The changed game.
- Returns:
Trueif valid, elseFalse.
- can_construct_state() bool¶
Query the validity of the state construction operation.
- Returns:
Trueif valid, elseFalse.
- can_destroy_state() bool¶
Query the validity of the state destruction operation.
- Returns:
Trueif valid, elseFalse.
- can_join(user: str, seat_index: int | None = None) bool¶
Query the validity of the joining operation.
- Parameters:
user – The user joining the table.
seat_index – The seat index at which the user is joining.
- Returns:
Trueif valid, elseFalse.
- can_leave(user: str) bool¶
Query the validity of the leaving operation.
- Parameters:
user – The user leaving the table.
- Returns:
Trueif valid, elseFalse.
- can_sit_out(user: str) bool¶
Query the validity of the sitting out operation.
- Parameters:
user – The user sitting out.
- Returns:
Trueif valid, elseFalse.
- change_game(game: Poker) None¶
Perform the game changing operation.
- Parameters:
game – The changed game.
- Returns:
None.
- construct_state() None¶
Perform the state construction operation.
- Returns:
None.
- destroy_state() None¶
Perform the state destruction operation.
- Returns:
None.
- game: Poker¶
The game being played on the table.
- get_seat(user: str) Seat | None¶
Lookup the seat of the user.
If none is found,
Noneis returned.- Returns:
The seat of the user or
None.
- property hand_history: HandHistory | None¶
Return the hand history of active state, if any.
- Returns:
The hand history or
None.
- join(user: str, seat_index: int) None¶
Perform the joining operation.
- Parameters:
user – The user joining the table.
seat_index – The seat index at which the user is joining.
- Returns:
None.
- leave(user: str) None¶
Perform the leaving operation.
- Parameters:
user – The user leaving the table.
- Returns:
None.
- max_starting_stack: int¶
The maximum starting stack, buy-in amount, etc.
- min_starting_stack: int¶
The minimum starting stack, buy-in amount, etc.
- property player_seats: Iterator[Seat]¶
Iterate through the seats that contain the players, in order.
- Returns:
The player seats.
- property ready_or_postable_seats: Iterator[Seat]¶
Yield the ready or postable seats.
On what being ready/postable means, please refer to
cardroom.table.Seat.ready_or_postable_status.- Returns:
The ready or postable seats.
- property ready_seats: Iterator[Seat]¶
Yield the ready seats.
On what being ready means, please refer to
cardroom.table.Seat.ready_status.- Returns:
The ready seats.
- seat_count: int¶
The number of seats in the table.
- property seat_indices: range¶
Return the table’s seat indices.
- Returns:
The seat indices.
- sit_out(user: str) None¶
Perform the sitting out operation.
Sitting out is akin to becoming idle or away from keyboard (AFK).
- Parameters:
user – The user sitting out.
- Returns:
None.
- state: State | None = None¶
The state of the game being played on the table (if ongoing).
- property turn_seat: Seat | None¶
Return the seat whose player is in turn to act.
If this does not exist or is not applicable,
Noneis returned.- Returns:
The turn seat or
None.
- property users: Iterator[str]¶
Yield the users.
- Returns:
The users.
- verify_being_back(user: str) Seat¶
Verify the being back operation.
- Parameters:
user – The user being back.
- Returns:
The seat the user is in.
- verify_buying_rebuying_topping_off_or_rat_holing(user: str, starting_stack: int | None = None) Seat¶
Verify the stack overriding operation.
- Parameters:
user – The user overriding their stack.
starting_stack – The new desired stack amount.
- Returns:
The seat the user is in.
- verify_game_changing(game: Poker) None¶
Verify the game changing operation.
- Parameters:
game – The changed game.
- Returns:
None.
- verify_joining(user: str, seat_index: int | None = None) None¶
Verify the joining operation.
- Parameters:
user – The user joining the table.
seat_index – The seat index at which the user is joining.
- Returns:
None.
- verify_leaving(user: str) Seat¶
Verify the leaving operation.
- Parameters:
user – The user leaving the table.
- Returns:
The seat the user is in.
- verify_sitting_out(user: str) Seat¶
Verify the sitting out operation.
- Parameters:
user – The user sitting out.
- Returns:
The seat the user is in.
- verify_state_construction() None¶
Verify the state construction operation.
- Returns:
None.
- verify_state_destruction() None¶
Verify the state destruction operation.
- Returns:
None.
cardroom.tournament module¶
cardroom.utilities module¶
- cardroom.utilities.divmod(dividend: int, divisor: int) tuple[int, int]¶
- cardroom.utilities.get_admin() bool¶
- cardroom.utilities.get_auth() bool¶
- cardroom.utilities.get_decimal_places() int¶
- cardroom.utilities.get_divmod() Callable[[int, int], tuple[int, int]]¶
- cardroom.utilities.get_felt() bool¶
- cardroom.utilities.get_parse_value() Callable[[str], int]¶
- cardroom.utilities.get_rat_holing_status() bool¶
- cardroom.utilities.get_root_routingconf() str¶
- cardroom.utilities.get_style() Style¶
- cardroom.utilities.get_tzinfo() ZoneInfo¶
- cardroom.utilities.parse_value(raw_value: str) int¶
- cardroom.utilities.serialize(obj: Any) Any¶