Skip to content

Commit 09348db

Browse files
committed
Add all_cards() method to CompactField
1 parent a46c1b4 commit 09348db

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

gomori/src/board/compact_field.rs

+16
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ impl CompactField {
8585
}
8686
}
8787

88+
/// All cards on the field.
89+
///
90+
/// Equal to [`hidden_cards()`] + [`top_card()`], if any.
91+
pub fn all_cards(self) -> CardsSet {
92+
if let Some(c) = self.top_card() {
93+
self.hidden_cards().insert(c)
94+
} else {
95+
self.hidden_cards()
96+
}
97+
}
98+
8899
pub fn into_field(self, i: i8, j: i8) -> Field {
89100
Field {
90101
i,
@@ -164,6 +175,11 @@ mod python {
164175
self.hidden_cards()
165176
}
166177

178+
#[pyo3(name = "all_cards")]
179+
fn py_all_cards(&self) -> CardsSet {
180+
self.all_cards()
181+
}
182+
167183
#[pyo3(name = "into_field")]
168184
fn py_into_field(&self, i: i8, j: i8) -> Field {
169185
self.into_field(i, j)

0 commit comments

Comments
 (0)