tidy up user prompts
This commit is contained in:
@@ -43,12 +43,11 @@ impl Board {
|
||||
}
|
||||
|
||||
pub fn apply(&mut self, m: Move) -> Result<(), &str> {
|
||||
let i = m.x * 1 + m.y * 3;
|
||||
|
||||
if !self.is_valid_move(&m) {
|
||||
return Err("invalid move");
|
||||
}
|
||||
|
||||
let i = m.x * 1 + m.y * 3;
|
||||
self.cells[i] = m.piece;
|
||||
|
||||
match self.next {
|
||||
@@ -68,14 +67,13 @@ impl Board {
|
||||
|
||||
pub fn valid_moves_available(&self) -> bool {
|
||||
// check for draw condition
|
||||
let mut empty: usize = 0;
|
||||
for i in 0..self.cells.len() {
|
||||
if self.cells[i] == Cell::Empty {
|
||||
empty += 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
empty > 0
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn has_winner(&self) -> Option<Cell> {
|
||||
|
Reference in New Issue
Block a user