Enum onejoker::cards::deck_type::DeckType

source ·
#[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

source

pub const fn from_u8(idx: u8) -> Self

Get deck type by index. Primarily for internal use

source

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);
source

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);
source

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");
source

pub const fn size(&self) -> usize

Number of cards in full deck

use onejoker::prelude::*;

assert_eq!(DeckType::Bezique.size(), 64);
source

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());
source

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());
source

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));
source

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);
source

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));
source

pub const fn fix_ace(&self, cin: Card) -> Card

Fix incoming aces for this deck

Trait Implementations§

source§

impl Clone for DeckType

source§

fn clone(&self) -> DeckType

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DeckType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DeckType

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for DeckType

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for DeckType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<u8> for DeckType

source§

fn from(n: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for DeckType

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for DeckType

source§

fn cmp(&self, other: &DeckType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for DeckType

source§

fn eq(&self, other: &DeckType) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for DeckType

source§

fn partial_cmp(&self, other: &DeckType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for DeckType

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for DeckType

source§

impl Eq for DeckType

source§

impl StructuralPartialEq for DeckType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> RuleType for T
where T: Copy + Debug + Eq + Hash + Ord,