From db96dc5c8a12b0fd21bd8a7b0b8732ddf2af08d7 Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Thu, 21 Dec 2023 23:13:13 +0100 Subject: [PATCH] Add gold to the result message --- src/main.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1c74556..4e98854 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,17 +120,19 @@ fn main() -> Result<()> { .border_style(Style::default().fg(Color::White)) .border_type(BorderType::Rounded) .style(Style::default().bg(Color::Black)); - let paragraph = match game.get_game_state() { + let mut text = match game.get_game_state() { GameState::RUNNING => { - Paragraph::new("Quitting is for cowards! You'll better try again!") + "Quitting is for cowards! You'll better try again!".to_string() } GameState::LOST => { - Paragraph::new("Sorry, you died in the dungeon. Better luck next time!") + "Sorry, you died in the dungeon. Better luck next time!".to_string() } GameState::WON => { - Paragraph::new("Congratulation! You mastered your way through the dungeon and won the game.") + "Congratulation! You mastered your way through the dungeon and won the game.".to_string() } - }.block(block).wrap(Wrap { trim: true }); + }; + text += format!("\nYou collected {} gold.", game.get_player().get_gold()).as_str(); + let paragraph = Paragraph::new(text).block(block).wrap(Wrap { trim: true }); frame.render_widget(paragraph, area); }); if event::poll(std::time::Duration::from_millis(16))? {