22 lines
612 B
Rust
22 lines
612 B
Rust
use crate::card::Rank;
|
|
|
|
/// Which cards the deck holds: every suit from `lowest` up to the ace.
|
|
/// The ace also plays below `lowest` in the lowest straight (A-2-3-4-5, or A-6-7-8-9).
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub struct DeckRule {
|
|
pub lowest: Rank,
|
|
}
|
|
|
|
impl DeckRule {
|
|
pub const FULL: DeckRule = DeckRule { lowest: Rank::Two };
|
|
pub const SHORT: DeckRule = DeckRule { lowest: Rank::Six };
|
|
|
|
pub fn contains(self, rank: Rank) -> bool {
|
|
rank >= self.lowest
|
|
}
|
|
|
|
pub fn size(self) -> usize {
|
|
Rank::ALL.iter().filter(|r| self.contains(**r)).count() * 4
|
|
}
|
|
}
|