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