Add max durability and enhance side panel UI

- Introduce `max_durability` fields to BaseBuilding, Stone, and Tunnel
  structures.
- Extend `Structure` trait with `get_max_durability` and implement it in
  all structures.
- Update `Structures` enum to forward `get_max_durability`.
- Add color utilities and `get_span` method to `Players` enum for styled
  text.
- Refactor `CellWidget` method names (`get_option_unit`,
  `set_structure`).
- Revise side panel widget to accept references to `Structures` and
  `Option<Units>`, render colored blocks and detailed stats.
- Simplify skirmish view to use `BoardState` directly and adapt side
  panel rendering.
This commit is contained in:
2026-04-26 21:04:19 +02:00
parent c24862dd48
commit f7c1795f29
9 changed files with 165 additions and 62 deletions
+27
View File
@@ -1,5 +1,9 @@
use crate::app::states::skirmish_states::BoardState;
use clap::ValueEnum;
use ratatui::{
style::{Color, Stylize},
text::Span,
};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SkirmishState {
@@ -20,3 +24,26 @@ pub enum Players {
Player,
Enemy,
}
impl Players {
pub fn get_text(&self) -> &'static str {
match self {
Self::Player => "Player",
Self::Enemy => "Enemy",
}
}
pub fn get_color(&self) -> Color {
match self {
Self::Player => Color::LightBlue,
Self::Enemy => Color::LightRed,
}
}
pub fn get_span(&self) -> Span<'static> {
match self {
Self::Player => self.get_text().fg(self.get_color()),
Self::Enemy => self.get_text().fg(self.get_color()),
}
}
}