diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-12-22 08:31:35 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-12-22 08:31:35 -0500 |
commit | 42f6ef6d44e893b47e5e2a49496b5dd2122df232 (patch) | |
tree | dff2f84bbc41295b27deb2397071cb16bb742058 /protocol/src/card.rs | |
parent | 10ecb9e30568bf20287b053a620252d7a80dbd6b (diff) |
Add a simple bot that plays random (legal) cards
- Leads random cards
- Follows suit if possible
Diffstat (limited to 'protocol/src/card.rs')
-rw-r--r-- | protocol/src/card.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/protocol/src/card.rs b/protocol/src/card.rs index 3d6081d..b6b57e7 100644 --- a/protocol/src/card.rs +++ b/protocol/src/card.rs @@ -124,6 +124,11 @@ impl std::str::FromStr for Rank { #[derive(PartialEq, Eq, Clone, Copy, Serialize, Deserialize)] pub struct Card(pub Suit, pub Rank); +impl Card { + pub fn suit(&self) -> Suit { self.0 } + pub fn rank(&self) -> Rank { self.1 } +} + impl fmt::Display for Card { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { let Card(suit, rank) = self; |