Add ore level support and unify text rendering

Introduce a numeric `level` field for `BaseBuilding` and `Ore`, update
their
constructors and `get_level` implementations, and increase the default
ore
amount to the new maximum. Extend the `Structure` and `Unit` traits with
`base_text` and `text` methods, add `is_unit` to `Units`, and adjust the
`Structures` enum to delegate text rendering. Refactor `SidePanelWidget`
to
use the unified trait methods, removing duplicated rendering code.
Update
`BoardState` to create ore structures with an initial level of 1.
This commit is contained in:
2026-05-05 00:18:49 +02:00
parent 766b65b2fc
commit 55a260755c
8 changed files with 115 additions and 58 deletions
@@ -42,4 +42,8 @@ impl Unit for Option<Units> {
fn get_owner(&self) -> Players {
self.map_or(Players::Unclaimed, |u| u.get_owner())
}
fn is_unit(&self) -> bool {
self.map_or(false, |u| u.is_unit())
}
}
@@ -1,7 +1,27 @@
use crate::app::states::skirmish_states::Players;
use ratatui::{
style::Stylize,
text::{Line, Span},
};
pub trait Unit {
fn get_owner(&self) -> Players;
fn get_tag(&self) -> char;
fn get_name(&self) -> &'static str;
fn is_unit(&self) -> bool {
true
}
fn base_text(&self) -> Vec<Line<'_>> {
let owner: Span<'_> = self.get_owner().get_span();
vec![Line::from_iter(vec!["Owner: ".gray(), owner])]
}
fn text(&self) -> Vec<Line<'_>> {
self.base_text()
}
}