16 lines
667 B
Rust
16 lines
667 B
Rust
use super::ledger::Ledger;
|
|
use crate::game::{Choice, Spot};
|
|
|
|
/// Applies a choice to hero's stack and the pot. Chips are conserved
|
|
/// (`stack + pot` is unchanged) and the stack never goes negative.
|
|
/// Nothing is committed beforehand, so a raise to X moves X chips, a call moves
|
|
/// `to_call`; both are capped by the stack (an all-in at most).
|
|
pub fn settle(spot: &Spot, choice: Choice) -> Ledger {
|
|
let before = Ledger { stack: spot.hero_stack.max(0.0), pot: spot.pot };
|
|
match choice {
|
|
Choice::Call => before.pay(spot.to_call),
|
|
Choice::Raise { to } => before.pay(to),
|
|
Choice::Fold | Choice::Check | Choice::Abstain => before,
|
|
}
|
|
}
|