feat: determine winner
This commit is contained in:
parent
18bd87e68f
commit
5741a6894b
2 changed files with 22 additions and 5 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue