initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub enum Suit {
|
||||
Spades,
|
||||
Hearts,
|
||||
Diamonds,
|
||||
Clubs,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Rank(pub u8); // 2-14 (11=J, 12=Q, 13=K, 14=A)
|
||||
|
||||
impl Rank {
|
||||
pub fn new(value: u8) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Card {
|
||||
pub suit: Suit,
|
||||
pub rank: Rank,
|
||||
}
|
||||
|
||||
impl Card {
|
||||
pub fn new(suit: Suit, rank_val: u8) -> Self {
|
||||
Self {
|
||||
suit,
|
||||
rank: Rank::new(rank_val),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user