Files
pokerfreak/src/read/draw_class.rs
T

36 lines
1.2 KiB
Rust

//! Strongest draw of hero's hand.
//!
//! No draw on the river and none once hero already has a straight or better. `Combo` is a flush draw
//! together with a straight draw or with a pair of hero's own (underpair up to trips). `Backdoor` exists on the flop only.
use super::census::Census;
use super::draw::Draw;
use super::flush_draw::{backdoor_flush, flush_draw_suits};
use super::made::Made;
use super::straight_draw::{backdoor_straight, completing_ranks};
use crate::variant::Rules;
pub fn draw_of(rules: &Rules, census: &Census, made: Made) -> Draw {
if census.board_len >= 5 || made >= Made::Straight {
return Draw::None;
}
let flush = flush_draw_suits(rules.hole_usage, census) != 0;
let ends = completing_ranks(rules, census);
let paired = (Made::Underpair..=Made::Trips).contains(&made);
match (flush, ends) {
(true, 0) if !paired => Draw::Flush,
(true, _) => Draw::Combo,
(false, 0) => backdoor(rules, census),
(false, 1) => Draw::Gutshot,
(false, _) => Draw::OpenEnded,
}
}
fn backdoor(rules: &Rules, census: &Census) -> Draw {
if backdoor_flush(rules.hole_usage, census) || backdoor_straight(rules, census) {
Draw::Backdoor
} else {
Draw::None
}
}