display game
This commit is contained in:
15
src/game.rs
15
src/game.rs
@@ -4,3 +4,18 @@ pub struct Game {
|
||||
players: [Box<dyn Agent>; 2],
|
||||
board: Board,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Game {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
writeln!(
|
||||
f,
|
||||
"Players: {} ({}) and {} ({})",
|
||||
self.players[0].name(),
|
||||
self.players[0].color().text(),
|
||||
self.players[1].name(),
|
||||
self.players[1].color().text()
|
||||
)?;
|
||||
write!(f, "{}", self.board)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user