roguelike-game/src/gui/game_over_menu.rs

66 lines
1.7 KiB
Rust
Raw Normal View History

use ::rltk::prelude::*;
2022-02-02 09:45:19 -05:00
use crate::{colors, gamelog};
#[derive(PartialEq, Copy, Clone)]
pub enum GameOverResult {
NoSelection,
QuitToMenu,
}
pub fn game_over(ctx: &mut Rltk) -> GameOverResult {
let mut draw_batch = DrawBatch::new();
draw_batch.print_color_centered(
15,
"Your journey has ended!",
ColorPair::new(colors::YELLOW, colors::BLACK),
);
draw_batch.print_color_centered(
2022-02-02 09:45:19 -05:00
17,
"One day, we'll tell you all about how you did.",
ColorPair::new(colors::WHITE, colors::BLACK),
2022-02-02 09:45:19 -05:00
);
draw_batch.print_color_centered(
2022-02-02 09:45:19 -05:00
18,
"That day, sadly, is not in this chapter...",
ColorPair::new(colors::WHITE, colors::BLACK),
2022-02-02 09:45:19 -05:00
);
draw_batch.print_color_centered(
2022-02-02 09:45:19 -05:00
19,
format!("You lived for {} turns.", gamelog::get_event_count("Turn")),
ColorPair::new(colors::WHITE, colors::BLACK),
2022-02-02 09:45:19 -05:00
);
draw_batch.print_color_centered(
2022-02-02 09:45:19 -05:00
20,
&format!(
"You suffered {} points of damage.",
gamelog::get_event_count("Damage Taken")
),
ColorPair::new(colors::RED, colors::BLACK),
2022-02-02 09:45:19 -05:00
);
draw_batch.print_color_centered(
2022-02-02 09:45:19 -05:00
21,
&format!(
"You inflicted {} points of damage.",
gamelog::get_event_count("Damage Inflicted")
),
ColorPair::new(colors::RED, colors::BLACK),
2022-02-02 09:45:19 -05:00
);
draw_batch.print_color_centered(
2022-02-02 09:45:19 -05:00
23,
"Press any key to return to the menu.",
ColorPair::new(colors::MAGENTA, colors::BLACK),
2022-02-02 09:45:19 -05:00
);
draw_batch
.submit(6000)
.expect("Failed to batch draw Game Over menu");
2022-02-02 09:45:19 -05:00
match ctx.key {
None => GameOverResult::NoSelection,
Some(_) => GameOverResult::QuitToMenu,
}
}