spinners and gems
This commit is contained in:
+10
-3
@@ -5,6 +5,9 @@
|
||||
//! presentational: it reads `health`/`gems` values handed in at construction and
|
||||
//! never mutates game state.
|
||||
|
||||
use crate::utils::rgba8_to_color;
|
||||
use kiln_core::Archetype;
|
||||
use kiln_core::cp437::tile_to_char;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::{Color, Style};
|
||||
@@ -18,8 +21,6 @@ const MAX_HEARTS: u32 = 5;
|
||||
const HEART_FULL: Color = Color::Rgb(255, 0, 0);
|
||||
/// A depleted heart: dark red.
|
||||
const HEART_EMPTY: Color = Color::Rgb(90, 0, 0);
|
||||
/// The gem glyph color: blue.
|
||||
const GEM: Color = Color::Rgb(80, 80, 255);
|
||||
|
||||
/// A ratatui widget that renders the play-mode status sidebar.
|
||||
///
|
||||
@@ -51,13 +52,19 @@ impl Widget for StatusSidebarWidget {
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Draw the gem indicator from the gem archetype's default glyph, so the
|
||||
// sidebar matches what gems look like on the board (no hardcoded ♦/color).
|
||||
let gem_glyph = Archetype::Gem.default_glyph();
|
||||
let gem_char = tile_to_char(gem_glyph.tile).to_string();
|
||||
let gem_style = Style::default().fg(rgba8_to_color(gem_glyph.fg));
|
||||
|
||||
let lines = vec![
|
||||
Line::from("Health:"),
|
||||
Line::from(hearts),
|
||||
Line::from(""),
|
||||
Line::from(vec![
|
||||
Span::raw("Gems: "),
|
||||
Span::styled("♦", Style::default().fg(GEM)),
|
||||
Span::styled(gem_char, gem_style),
|
||||
Span::raw(format!(" {}", self.gems)),
|
||||
]),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user