generated from GarandPLG/rust-flake-template
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:
@@ -4,6 +4,7 @@ use ratatui::style::Color;
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct BaseBuilding {
|
||||
durability: u16,
|
||||
max_durability: u16,
|
||||
stress: u8,
|
||||
owner: Players,
|
||||
level: u8,
|
||||
@@ -13,6 +14,7 @@ impl BaseBuilding {
|
||||
pub fn new(owner: Players) -> Self {
|
||||
Self {
|
||||
durability: 1500,
|
||||
max_durability: 1500,
|
||||
stress: 0,
|
||||
owner,
|
||||
level: b'1',
|
||||
@@ -44,6 +46,10 @@ impl Structure for BaseBuilding {
|
||||
self.durability
|
||||
}
|
||||
|
||||
fn get_max_durability(&self) -> u16 {
|
||||
self.max_durability
|
||||
}
|
||||
|
||||
fn get_stress(&self) -> u8 {
|
||||
self.stress
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user