use serde::{Deserialize, Serialize};
#[derive(
Clone, Copy, Debug, Default, Eq, Hash, PartialEq, Ord, PartialOrd, Serialize, Deserialize,
)]
pub struct Draws {
pub hands_to_play: usize,
pub discards: usize,
pub hand_size: usize,
}
impl std::fmt::Display for Draws {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"Draws {{ hands: {}, discards: {}, hand_size: {} }}",
self.hands_to_play, self.discards, self.hand_size
)
}
}
impl Draws {
pub const DEFAULT_HAND_SIZE: usize = 8;
#[must_use]
pub fn new(hands_to_play: usize, discards: usize) -> Self {
Self {
hands_to_play,
discards,
hand_size: Self::DEFAULT_HAND_SIZE,
}
}
}
#[cfg(test)]
#[allow(non_snake_case)]
mod funky__types__draws_tests {
use super::*;
#[test]
fn display() {
let draws = Draws::new(1, 2);
assert_eq!(
draws.to_string(),
"Draws { hands: 1, discards: 2, hand_size: 8 }"
);
}
#[test]
fn new__defaults_to_the_base_hand_size() {
assert_eq!(Draws::new(4, 3).hand_size, Draws::DEFAULT_HAND_SIZE);
}
}