Expand description
§wiki | A library for handling playing cards and card games.
Last updated October 17, 2024
This crate is part of the OneJoker project
to create free software for handling playing cards and card games
in general, and many poker variants in particular.
Lee Daniel Crocker lee@onejoker.org
Licensed https://creativecommons.org/publicdomain/zero/1.0/
§Example
use onejoker::*;
fn main() -> Result<(),Error> {
let mut d = Deck::new("default");
d.shuffle();
let h1 = d.new_hand_with(5);
let h2 = d.new_hand_with(5);
println!("Player 1: [{}], Player 2: [{}]", h1, h2);
let high = HandEvaluatorHigh::new();
let v1 = high.value_of(&h1)?;
let v2 = high.value_of(&h2)?;
if v1 < v2 {
println!("Player 1 wins with [{}]", v1.full_name());
} else if v1 > v2 {
println!("Player 2 wins with [{}]", v2.full_name());
} else {
println!("Players tie with [{}]", v1.full_name());
}
Ok(())
}
This should produce output similar to:
Player 1: 4cJc7s4h6s, Player 2: Kd6sJdAsKh
Player 2 wins with pair of kings, ace, jack, six
Re-exports§
pub use errors::OjError;
pub use utils::oj_rand_next32;
pub use utils::oj_rand_range;
pub use utils::oj_shuffle;
pub use utils::oj_sort;
pub use utils::oj_next_combination;
pub use utils::oj_binomial;
pub use cards::suit::Suit;
pub use cards::rank::Rank;
pub use cards::card::Ordinal;
pub use cards::card::Card;
pub use cards::card::WHITE_JOKER;
pub use cards::card::BLACK_JOKER;
pub use cards::card::JOKER;
pub use cards::card::LOW_ACE_OF_CLUBS;
pub use cards::card::LOW_ACE_OF_DIAMONDS;
pub use cards::card::LOW_ACE_OF_HEARTS;
pub use cards::card::LOW_ACE_OF_SPADES;
pub use cards::card::DEUCE_OF_CLUBS;
pub use cards::card::DEUCE_OF_DIAMONDS;
pub use cards::card::DEUCE_OF_HEARTS;
pub use cards::card::DEUCE_OF_SPADES;
pub use cards::card::TREY_OF_CLUBS;
pub use cards::card::TREY_OF_DIAMONDS;
pub use cards::card::TREY_OF_HEARTS;
pub use cards::card::TREY_OF_SPADES;
pub use cards::card::FOUR_OF_CLUBS;
pub use cards::card::FOUR_OF_DIAMONDS;
pub use cards::card::FOUR_OF_HEARTS;
pub use cards::card::FOUR_OF_SPADES;
pub use cards::card::FIVE_OF_CLUBS;
pub use cards::card::FIVE_OF_DIAMONDS;
pub use cards::card::FIVE_OF_HEARTS;
pub use cards::card::FIVE_OF_SPADES;
pub use cards::card::SIX_OF_CLUBS;
pub use cards::card::SIX_OF_DIAMONDS;
pub use cards::card::SIX_OF_HEARTS;
pub use cards::card::SIX_OF_SPADES;
pub use cards::card::SEVEN_OF_CLUBS;
pub use cards::card::SEVEN_OF_DIAMONDS;
pub use cards::card::SEVEN_OF_HEARTS;
pub use cards::card::SEVEN_OF_SPADES;
pub use cards::card::EIGHT_OF_CLUBS;
pub use cards::card::EIGHT_OF_DIAMONDS;
pub use cards::card::EIGHT_OF_HEARTS;
pub use cards::card::EIGHT_OF_SPADES;
pub use cards::card::NINE_OF_CLUBS;
pub use cards::card::NINE_OF_DIAMONDS;
pub use cards::card::NINE_OF_HEARTS;
pub use cards::card::NINE_OF_SPADES;
pub use cards::card::TEN_OF_CLUBS;
pub use cards::card::TEN_OF_DIAMONDS;
pub use cards::card::TEN_OF_HEARTS;
pub use cards::card::TEN_OF_SPADES;
pub use cards::card::JACK_OF_CLUBS;
pub use cards::card::JACK_OF_DIAMONDS;
pub use cards::card::JACK_OF_HEARTS;
pub use cards::card::JACK_OF_SPADES;
pub use cards::card::KNIGHT_OF_CLUBS;
pub use cards::card::KNIGHT_OF_DIAMONDS;
pub use cards::card::KNIGHT_OF_HEARTS;
pub use cards::card::KNIGHT_OF_SPADES;
pub use cards::card::QUEEN_OF_CLUBS;
pub use cards::card::QUEEN_OF_DIAMONDS;
pub use cards::card::QUEEN_OF_HEARTS;
pub use cards::card::QUEEN_OF_SPADES;
pub use cards::card::KING_OF_CLUBS;
pub use cards::card::KING_OF_DIAMONDS;
pub use cards::card::KING_OF_HEARTS;
pub use cards::card::KING_OF_SPADES;
pub use cards::card::ACE_OF_CLUBS;
pub use cards::card::ACE_OF_DIAMONDS;
pub use cards::card::ACE_OF_HEARTS;
pub use cards::card::ACE_OF_SPADES;
pub use cards::hashes::ojh_fnv_u32;
pub use cards::hashes::ojh_fnv_u64;
pub use cards::hashes::ojh_positional_u32c;
pub use cards::hashes::ojh_positional_u32csr;
pub use cards::hashes::ojh_positional_u64c;
pub use cards::hashes::ojh_positional_u64csr;
pub use cards::hashes::ojh_bitfield_u64co;
pub use cards::hashes::ojh_mp5_english;
pub use cards::hand::Hand;
pub use cards::deck::Deck;
pub use poker::hand_value::HandLevelTrait;
pub use poker::hand_value::HandLevelHigh;
pub use poker::hand_value::HandLevelPaiGow;
pub use poker::hand_value::HandLevelStripped;
pub use poker::hand_value::HandLevelManilla;
pub use poker::hand_value::HandLevelMexican;
pub use poker::hand_value::HandLevelAceToFive;
pub use poker::hand_value::HandLevelDeuceToSeven;
pub use poker::hand_value::HandLevelAceToSix;
pub use poker::hand_value::HandLevelBadugi;
pub use poker::hand_value::HandLevelActionRazz;
pub use poker::hand_value::HandValueTrait;
pub use poker::hand_value::HandValue;
pub use poker::hand_value::HandEvaluatorTrait;
pub use poker::high_hand::HandValueHigh;
pub use poker::high_hand::HandEvaluatorHigh;
Modules§
- wiki | Non-game-specific card handling
- wiki | Library-related error types.
- wiki | Poker hands and game play
- wiki | General utility functions
Macros§
- Construct an ad-hoc error from a string or existing non-
anyhow
error value. - Return early with an error.
Structs§
- Iterator of a chain of source errors.
- The
Error
type, a wrapper around a dynamic error type.
Traits§
- Provides the
context
method forResult
.
Functions§
- Equivalent to Ok::<_, anyhow::Error>(value).
Type Aliases§
Result<T, Error>