feat: determine winner

This commit is contained in:
Henri Bourcereau 2024-09-27 12:35:14 +02:00
parent 18bd87e68f
commit 5741a6894b
2 changed files with 22 additions and 5 deletions

View file

@ -201,10 +201,23 @@ impl App {
}
pub fn display(&mut self) -> String {
let winner = self
.game
.state
.determine_winner()
.and_then(|id| self.game.state.players.get(&id));
let str_won: String = winner
.map(|p| {
let mut name = " winner: ".to_owned();
name.push_str(&p.name);
name
})
.unwrap_or("".to_owned());
let mut output = "-------------------------------".to_owned();
output += format!(
"\n{:?} > {} > {:?}",
"\n{:?}{} > {} > {:?}",
self.game.state.stage,
str_won,
self.game
.state
.who_plays()