Files
pokerfreak/src/game/action_kind.rs
T

22 lines
532 B
Rust

/// The vocabulary of `legalActions`.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum ActionKind {
Fold,
Check,
Call,
Raise,
}
impl ActionKind {
pub const ALL: [ActionKind; 4] =
[ActionKind::Fold, ActionKind::Check, ActionKind::Call, ActionKind::Raise];
pub fn parse(text: &str) -> Option<ActionKind> {
ActionKind::ALL.into_iter().find(|a| a.name() == text.trim())
}
pub fn name(self) -> &'static str {
["FOLD", "CHECK", "CALL", "RAISE"][self as usize]
}
}