19 lines
752 B
Rust
19 lines
752 B
Rust
//! Where each category sits in the ladder of a given hand ranking (higher = stronger).
|
|
|
|
use super::category::Category;
|
|
use crate::variant::HandRanking;
|
|
|
|
/// Indexed by `Category as usize`: high card … straight flush.
|
|
const STANDARD: [u8; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
/// Flush and full house swap places; the straight stays above three of a kind
|
|
/// (some short deck rule sets put trips above the straight, this crate does not).
|
|
const FLUSH_OVER_FULL_HOUSE: [u8; 9] = [0, 1, 2, 3, 4, 6, 5, 7, 8];
|
|
|
|
pub fn place(ranking: HandRanking, category: Category) -> u8 {
|
|
let ladder = match ranking {
|
|
HandRanking::Standard => &STANDARD,
|
|
HandRanking::FlushOverFullHouse => &FLUSH_OVER_FULL_HOUSE,
|
|
};
|
|
ladder[category as usize]
|
|
}
|