@@ -70,6 +70,8 @@ impl Display for Player {
70
70
}
71
71
72
72
impl Player {
73
+ /// Used by the caller / game logic to take a Player's cards (ostensibly after the Player has
74
+ /// played them legally).
73
75
pub fn remove_hand_from_cards ( & mut self , hand : & Hand ) {
74
76
assert ! ( self . has_cards( hand) ) ;
75
77
match hand {
@@ -80,6 +82,9 @@ impl Player {
80
82
}
81
83
}
82
84
85
+ /// Used internally to remove any slice of cards from a Player's cards.
86
+ /// # Panics
87
+ /// - Will panic if any of cards_to_remove are not in Player's cards.
83
88
fn remove_cards_from_cards ( & mut self , cards_to_remove : & [ Card ] ) {
84
89
for to_remove in cards_to_remove {
85
90
let index = self
@@ -91,11 +96,14 @@ impl Player {
91
96
}
92
97
}
93
98
99
+ /// Used to make sure the Player actually has the cards they tried to play.
94
100
pub fn has_cards ( & self , hand : & Hand ) -> bool {
95
101
Player :: hand_in_cards ( hand, & self . cards )
96
102
}
97
103
98
- pub fn hand_in_cards ( hand : & Hand , cards : & [ Card ] ) -> bool {
104
+ /// Used internally, converts players cards into BTreeSet to check if cards from hand are
105
+ /// present.
106
+ fn hand_in_cards ( hand : & Hand , cards : & [ Card ] ) -> bool {
99
107
let cards: BTreeSet < & Card > = BTreeSet :: from_iter ( cards) ;
100
108
match hand {
101
109
Hand :: Lone ( a) => cards. contains ( a) ,
0 commit comments