diff --git a/src/models/board.rs b/src/models/board.rs index 07997e4..353b7ad 100644 --- a/src/models/board.rs +++ b/src/models/board.rs @@ -1,8 +1,11 @@ use std::fmt; use super::piece::Piece; +use super::player::Player; -pub struct Board(Vec>>); +#[derive(Clone)] +pub struct Tile(Option, Option); +pub struct Board(Vec>); impl fmt::Display for Board { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -13,7 +16,7 @@ impl fmt::Display for Board { .map(|row| { row .into_iter() - .map(|op| match op { + .map(|op| match op.0 { Some(p) => p.to_string(), None => ".".to_string(), }) @@ -35,10 +38,15 @@ impl Board { .map(|row| { row .chars() - .map(|l| Piece::from_string(&l).ok()) + .map(|l| Tile(Piece::from_string(&l).ok(), None)) .collect::>() }) .collect::>(); + + for row in board.iter().skip(1) { + assert!(row.len() == board[0].len()); + } + Board(board) }