Enum PokerHand

Source
pub enum PokerHand {
    HighCard = 0,
    Pair = 1,
    TwoPair = 2,
    ThreeOfAKind = 3,
    Straight = 4,
    Flush = 5,
    FullHouse = 6,
    FourOfAKind = 7,
    StraightFlush = 8,
    FiveOfAKind = 9,
    FlushHouse = 10,
    FlushFive = 11,
}
Expand description

Poker Hands are sets of between one and five cards that can be played in Ortalab to obtain Chips and Mult for scoring.

This includes all of the standard poker hands, along with three “illegal” poker hands. These hands are possible in Ortalab because players can have duplicate cards, enabling hands that aren’t typically possible in poker.

Higher tier hands take precedence over lower tier hands regardless of their level or scoring. e.g., if your hand is K♦ K♦ K♦ K♦ 2♦, the hand will always be a Four of a Kind and never a Flush.

PokerHand is declared in ascending tier order. You can read the tier numerically as follows:


assert_eq!(PokerHand::HighCard as u8,   0);
assert_eq!(PokerHand::Pair as u8,       1);
// ...
assert_eq!(PokerHand::Flush as u8,      5);
// ...
assert_eq!(PokerHand::FlushHouse as u8, 10);
assert_eq!(PokerHand::FlushFive as u8,  11);

Poker hands also include a base score, which provides initial values for the round’s Chips and Mult. These base scores can be accessed with PokerHand::hand_value as follows:


let (chips, mult) = PokerHand::Flush.hand_value();
assert_eq!(chips, 35.0);
assert_eq!(mult, 4.0);

Only the card relevant to the hand are scored. All others are unscored.

Example 1: You play an ace high with 4 other cards. Only the High card base amount and the aces values are used for this hands score. The other cards are ignored.

Example 2: You play a pair of 3s and A K Q. Only the pair cards are scored. The other cards ignored.

Variants§

§

HighCard = 0

When no other hand is possible, the one highest card in your hand. Aces are considered the highest card.

e.g. Q♦ 9♥ A♠ 3♥ 4♠ (Q♦ 9♥ 3♥ 4♠ not counted)

§

Pair = 1

Two cards with a matching rank. Suits may differ.

e.g. K♠ 9♠ 9♦ 6♥ 3♥ (K♠ 6♥ 3♥ not counted)

§

TwoPair = 2

Two cards with a matching rank, and two cards with any other matching rank. Suits may differ.

e.g. Q♣ Q♦ A♠ 4♦ 4♠ (A♠ not counted)

§

ThreeOfAKind = 3

Three cards with a matching rank. Suits may differ.

e.g. 9♣ 9♦ 9♠ A♠ 3♦ (A♠ 3♦ not counted)

§

Straight = 4

Five cards in consecutive order which are not all from the same suit. Aces can be counted high or low, but not both at once.

e.g. A♠ 2♦ 3♣ 4♠ 5♥ and 10♦ J♠ Q♦ K♣ A♠ are straights, but Q♦ K♣ A♠ 2♣ 3♠ is not.

§

Flush = 5

Five cards of any rank, all from a single suit.

e.g. A♥ K♥ 9♥ 5♥ 4♥

§

FullHouse = 6

Three cards with a matching rank, and two cards with any other matching rank, with cards from two or more suits.

e.g. K♥ K♦ K♣ 2♥ 2♣

§

FourOfAKind = 7

Four cards with a matching rank. Suits may differ.

e.g. J♠ J♣ J♥ J♦ 3♣ (3♣ not counted)

§

StraightFlush = 8

Five cards in consecutive order, all from a single suit.

e.g. Q♠ J♠ 10♠ 9♠ 8♠

§

FiveOfAKind = 9

An “illegal” hand.

Five cards with the same rank which are not all the same suit.

e.g. A♠ A♥ A♥ A♣ A♠

§

FlushHouse = 10

An “illegal” hand.

Three cards with the same rank, and two cards with the same rank, all from a single suit.

e.g. 7♦ 7♦ 7♦ 4♦ 4♦

§

FlushFive = 11

An “illegal” hand.

Five cards with the same rank and same suit.

e.g. A♠ A♠ A♠ A♠ A♠

Implementations§

Trait Implementations§

Source§

impl Clone for PokerHand

Source§

fn clone(&self) -> PokerHand

Returns a duplicate 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 PokerHand

Source§

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

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

impl Display for PokerHand

Source§

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

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

impl Hash for PokerHand

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 PokerHand

Source§

fn cmp(&self, other: &PokerHand) -> 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,

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

impl PartialEq for PokerHand

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for PokerHand

Source§

fn partial_cmp(&self, other: &PokerHand) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sequence for PokerHand

Source§

const CARDINALITY: usize = 12usize

Number of values of type Self. Read more
Source§

fn next(&self) -> Option<Self>

Returns value following *self or None if this was the end. Read more
Source§

fn previous(&self) -> Option<Self>

Returns value preceding *self or None if this was the beginning. Read more
Source§

fn first() -> Option<Self>

Returns the first value of type Self. Read more
Source§

fn last() -> Option<Self>

Returns the last value of type Self. Read more
Source§

impl Copy for PokerHand

Source§

impl Eq for PokerHand

Source§

impl StructuralPartialEq for PokerHand

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: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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§

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>,

Source§

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>,

Source§

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.