Enum onejoker::poker::hand_scale::Scale

source ·
#[repr(u8)]
pub enum Scale {
Show 14 variants None = 0, HighHand = 1, AceToFive = 2, DeuceToSeven = 3, AceToSix = 4, Badugi = 5, Badeucy = 6, PaiGow = 7, Stripped = 8, ActionRazz = 9, HighHandBug = 10, AceToFiveBug = 11, Mexican = 12, ThreeCard = 13,
}
Expand description

wiki | Poker hand evaluation info

Enum representing hand “scales”, or ways in which poker hands are evaluated in different games.

Variants§

§

None = 0

None / Invalid

§

HighHand = 1

Traditional “high” poker hands

§

AceToFive = 2

Low hands, aces low, no straights or flushes

§

DeuceToSeven = 3

Low hands, aces low (“Kansas City” low)

§

AceToSix = 4

Low hands, aces high (“London” low)

§

Badugi = 5

Four cards, aces low, no matching suits

§

Badeucy = 6

Badugi, aces high

§

PaiGow = 7

High hands, except wheel beats K-high straight

§

Stripped = 8

Stripped deck: flush beats full house

§

ActionRazz = 9

Ace-to-five low, face card needed to qualify

§

HighHandBug = 10

High hands with single bug

§

AceToFiveBug = 11

Ace-to-five low with single bug

§

Mexican = 12

Spanish deck with single bug

§

ThreeCard = 13

Three-card high hands

Implementations§

source§

impl Scale

source

pub const fn from_u8(index: u8) -> Scale

Get a hand scale by index

source

pub fn by_name(sname: &str) -> Scale

Get hand scale by name

use onejoker::prelude::*;

let scale = Scale::by_name("ace-to-five");
assert_eq!(scale, Scale::AceToFive);
source

pub fn new_deck(&self) -> Deck

Create a new deck for this game

source

pub fn name(&self) -> &'static str

Canonical name of the game or hand type

use onejoker::prelude::*;

assert_eq!(Scale::AceToFive.name(), "ace-to-five");
source

pub const fn deck_type(&self) -> DeckType

Preferred deck for this game

use onejoker::prelude::*;

assert_eq!(DeckType::Low, Scale::AceToFive.deck_type());
source

pub const fn complete_hand(&self) -> usize

Number of cards in a complete hand

use onejoker::prelude::*;

assert_eq!(5, Scale::AceToFive.complete_hand());
source

pub const fn low_aces(&self) -> bool

Calculations and comparisons expect low aces

use onejoker::prelude::*;

assert!(Scale::AceToFive.low_aces());
assert!(! Scale::DeuceToSeven.low_aces());
source

pub const fn low_hands(&self) -> bool

Hand values are calculated for low hands

use onejoker::prelude::*;

assert!(Scale::AceToFive.low_hands());
assert!(Scale::DeuceToSeven.low_hands());
assert!(! Scale::HighHand.low_hands());
source

pub const fn straights_and_flushes(&self) -> bool

Does the game include straights and flushes?

use onejoker::prelude::*;

assert!(Scale::HighHand.straights_and_flushes());
assert!(! Scale::AceToFive.straights_and_flushes());
source

pub const fn high_wheel(&self) -> bool

Is wheel a straight for high-ace games?

use onejoker::prelude::*;

assert!(Scale::HighHand.high_wheel());
assert!(! Scale::DeuceToSeven.high_wheel());
source

pub const fn pai_gow_wheel(&self) -> bool

Does wheel beat K-high straight?

use onejoker::prelude::*;

assert!(! Scale::HighHand.pai_gow_wheel());
assert!(Scale::PaiGow.pai_gow_wheel());
source

pub const fn low_broadway(&self) -> bool

Is Broadway a straight for low-ace games?

use onejoker::prelude::*;

// The only game that might: but I prefer this rule
assert!(! Scale::AceToSix.low_broadway());
source

pub const fn spanish_gap(&self) -> bool

Does deck have 8s, 9s, and 10s removed?

use onejoker::prelude::*;

assert!(Scale::Mexican.spanish_gap());
source

pub fn value_from_level(&self, hl: HandLevel) -> u32

Mapping from generic hand level to numeric value

use onejoker::prelude::*;

assert_eq!(4, Scale::AceToFive.value_from_level(HandLevel::Trips));
source

pub fn level_from_value(&self, v: u32) -> HandLevel

Mapping from numeric value to generic hand level

use onejoker::prelude::*;

assert_eq!(HandLevel::Trips, Scale::AceToFive.level_from_value(4));
source

pub fn valid_card(&self, c: Card) -> bool

Is the given card valid for this game?

source

pub fn valid_hand(&self, h: &Hand) -> bool

Is this hand valid for this game?

source

pub fn to_string(&self, d: &HandDescription) -> String

Print hand

source

pub fn full_text(&self, d: &HandDescription) -> String

Game-specific function to get full English name of hand

use onejoker::prelude::*;
use onejoker::poker::{ojp_hh_value,ojp_hh_description};

let hand = Hand::new(DeckType::English).init(hand!("9s","As","9d","Ks","Ah"));
let v = ojp_hh_value(&hand);
let d = ojp_hh_description(&hand, v);
println!("{}", d.full_text());
println!("{}", Scale::HighHand.full_text(&d));
source

pub fn value(&self, hand: &Hand) -> HandValue

Game-specific quick value-only hand evaluation function

use onejoker::prelude::*;

let hand = Hand::new(DeckType::English).init(hand!("9s","As","9d","Ks","Ah"));
let v = Scale::HighHand.value(&hand);
println!("{}", v);
source

pub fn description(&self, h: &Hand, v: HandValue) -> HandDescription

Get description of hand

use onejoker::prelude::*;

let hand = Hand::new(DeckType::English).init(hand!("9s","As","9d","Ks","Ah"));
let v = Scale::HighHand.value(&hand);
let d = Scale::HighHand.description(&hand, v);
println!("{}", v);

Trait Implementations§

source§

impl Clone for Scale

source§

fn clone(&self) -> Scale

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 Scale

source§

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

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

impl Default for Scale

source§

fn default() -> Scale

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

impl From<u8> for Scale

source§

fn from(n: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for Scale

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 PartialEq for Scale

source§

fn eq(&self, other: &Scale) -> 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 Copy for Scale

source§

impl Eq for Scale

source§

impl StructuralPartialEq for Scale

Auto Trait Implementations§

§

impl Freeze for Scale

§

impl RefUnwindSafe for Scale

§

impl Send for Scale

§

impl Sync for Scale

§

impl Unpin for Scale

§

impl UnwindSafe for Scale

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