From 42f6ef6d44e893b47e5e2a49496b5dd2122df232 Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Thu, 22 Dec 2022 08:31:35 -0500 Subject: Add a simple bot that plays random (legal) cards - Leads random cards - Follows suit if possible --- protocol/src/card.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'protocol/src/card.rs') 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; -- cgit v1.2.3