#[repr(u8)]pub enum DeckType {
Show 20 variants
None = 0,
AllCards = 1,
English = 2,
OneJoker = 3,
TwoJokers = 4,
Low = 5,
LowJoker = 6,
Spanish = 7,
Spanish48 = 8,
Mexican = 9,
Panguingue = 10,
Stripped = 11,
Swiss = 12,
Euchre = 13,
Euchre25 = 14,
Euchre28 = 15,
Euchre29 = 16,
Bezique = 17,
Canasta = 18,
Pinochle = 19,
}
Expand description
wiki | Represents a new, full deck
Contains information about the kinds of decks used in various card games.
Variants§
None = 0
None / Invalid
AllCards = 1
63-card deck with 3 jokers, knights, low and high aces for testing
English = 2
English/American 52-card deck with high aces
OneJoker = 3
53-card deck with one joker
TwoJokers = 4
54-card deck with two jokers
Low = 5
52-card deck with low aces
LowJoker = 6
53-card deck with low aces and joker
Spanish = 7
40-card Spanish deck with low aces, knights, no 8/9/10
Spanish48 = 8
48-card Spanish deck with low aces, knights, no 10s
Mexican = 9
41-card Mexican deck with high aces, no 8/9/10, one joker
Panguingue = 10
320-card Panguingue deck with low aces, knights, no 8/9/10, 8 decks
Stripped = 11
32-card German deck with no 8/9/10
Swiss = 12
36-card Swiss/Russian deck with no 2..6
Euchre = 13
24-card Euchre deck with no 2..8
Euchre25 = 14
25-card Euchre deck with no 2..8, one joker
Euchre28 = 15
28-card Euchre deck with no 2..7
Euchre29 = 16
29-card Euchre deck with no 2..7, one joker
Bezique = 17
64-card Bezique deck with no 8/9/10, 2 decks
Canasta = 18
108-card Canasta deck with 2 jokers, 2 decks
Pinochle = 19
48-card Pinochle deck with no 2..8, 2 decks
Implementations§
source§impl DeckType
impl DeckType
sourcepub fn by_name(dname: &str) -> Self
pub fn by_name(dname: &str) -> Self
Get deck type by name or alias
use onejoker::prelude::*;
let dt = DeckType::by_name("bridge");
assert_eq!(dt, DeckType::English);
sourcepub fn set_default(t: Self)
pub fn set_default(t: Self)
Set default deck type
use onejoker::prelude::*;
DeckType::set_default(DeckType::Pinochle);
let h = Hand::default();
assert_eq!(h.deck_type(), DeckType::Pinochle);
sourcepub const fn name(&self) -> &'static str
pub const fn name(&self) -> &'static str
Canonical name of deck type
use onejoker::prelude::*;
let d = Deck::new_by_name("lowball");
assert_eq!(d.deck_type().name(), "lowjoker");
sourcepub const fn size(&self) -> usize
pub const fn size(&self) -> usize
Number of cards in full deck
use onejoker::prelude::*;
assert_eq!(DeckType::Bezique.size(), 64);
sourcepub const fn low_aces(&self) -> bool
pub const fn low_aces(&self) -> bool
Does the deck use low aces?
use onejoker::prelude::*;
let mut d = Deck::new_by_name("razz");
assert!(d.deck_type().low_aces());
d = Deck::new_by_name("swiss");
assert!(! d.deck_type().low_aces());
sourcepub const fn dups_allowed(&self) -> bool
pub const fn dups_allowed(&self) -> bool
Does the deck allow duplicate cards?
use onejoker::prelude::*;
let mut d = Deck::new_by_name("german");
assert!(! d.deck_type().dups_allowed());
d = Deck::new_by_name("canasta");
assert!(d.deck_type().dups_allowed());
sourcepub const fn has(&self, c: Card) -> bool
pub const fn has(&self, c: Card) -> bool
Does the deck allow this specific card?
use onejoker::prelude::*;
assert!(DeckType::Spanish.has(KNIGHT_OF_CLUBS));
assert!(! DeckType::Stripped.has(DEUCE_OF_CLUBS));
sourcepub const fn card_list(&self) -> &'static [Card]
pub const fn card_list(&self) -> &'static [Card]
Get a slice of the full deck
use onejoker::prelude::*;
let v: Vec<Card> = DeckType::Spanish.card_list().to_vec();
assert_eq!(v.len(), 40);
sourcepub const fn valid_card(&self, cin: Card) -> Card
pub const fn valid_card(&self, cin: Card) -> Card
Validate a card for this deck
Note that unlike has
, which just gives a yes/no, this function
returns card with aces fixed if necessary, and maybe other fixes
in the future.
use onejoker::prelude::*;
let dt = DeckType::by_name("lowball");
assert_eq!(LOW_ACE_OF_CLUBS, dt.valid_card(ACE_OF_CLUBS));
assert_eq!(DEUCE_OF_CLUBS, dt.valid_card(DEUCE_OF_CLUBS));
Trait Implementations§
source§impl<'de> Deserialize<'de> for DeckType
impl<'de> Deserialize<'de> for DeckType
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Ord for DeckType
impl Ord for DeckType
source§impl PartialEq for DeckType
impl PartialEq for DeckType
source§impl PartialOrd for DeckType
impl PartialOrd for DeckType
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for DeckType
impl Eq for DeckType
impl StructuralPartialEq for DeckType
Auto Trait Implementations§
impl Freeze for DeckType
impl RefUnwindSafe for DeckType
impl Send for DeckType
impl Sync for DeckType
impl Unpin for DeckType
impl UnwindSafe for DeckType
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)