55 lines
1.0 KiB
Rust
55 lines
1.0 KiB
Rust
use super::{card::Card, hand::Hand, card_index::CardIndex as CI, card_suit::CardSuit as CS};
|
|
|
|
pub fn new_full_deck() -> Hand {
|
|
let mut hand = Hand::new();
|
|
|
|
for suit in [CS::Clubs, CS::Diamonds, CS::Hearts, CS::Spades] {
|
|
for index in [
|
|
CI::A,
|
|
CI::J,
|
|
CI::K,
|
|
CI::Q,
|
|
CI::N10,
|
|
CI::N9,
|
|
CI::N8,
|
|
CI::N7,
|
|
CI::N6,
|
|
CI::N5,
|
|
CI::N4,
|
|
CI::N3,
|
|
CI::N2,
|
|
] {
|
|
hand.add_card(Card { suit, index });
|
|
}
|
|
}
|
|
|
|
hand
|
|
}
|
|
|
|
pub fn new_blackjack_shoe(decks: u32) -> Hand {
|
|
let mut hand = Hand::new();
|
|
|
|
for _ in 0..decks {
|
|
hand.merge(&mut new_full_deck());
|
|
}
|
|
|
|
hand.shuffle();
|
|
|
|
hand
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn full_deck_count() {
|
|
assert_eq!(new_full_deck().count(), 52);
|
|
}
|
|
|
|
#[test]
|
|
fn shoe_count() {
|
|
assert_eq!(new_blackjack_shoe(6).count(), 6 * 52);
|
|
}
|
|
}
|