generated from GarandPLG/rust-flake-template
- Document new Rust formatting standards in AGENTS, CODE_MAP, and PROGRESS. - Add rustfmt.toml with style 2024, 2‑space indents, 100‑char width, LF endings. - Apply consistent 2‑space indentation and ordering across source files. - Minor clean‑up of imports and whitespace to match the new style.
60 lines
1016 B
Rust
60 lines
1016 B
Rust
use crate::app::states::skirmish_states::{Players, structures::Structure};
|
|
use ratatui::style::Color;
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub struct BaseBuilding {
|
|
durability: u16,
|
|
stress: u8,
|
|
owner: Players,
|
|
level: u8,
|
|
}
|
|
|
|
impl BaseBuilding {
|
|
pub fn new(owner: Players) -> Self {
|
|
Self {
|
|
durability: 1500,
|
|
stress: 0,
|
|
owner,
|
|
level: 1,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Structure for BaseBuilding {
|
|
fn get_tag(&self) -> char {
|
|
'B'
|
|
}
|
|
|
|
fn get_color(&self) -> Color {
|
|
match self.owner {
|
|
Players::Player => Color::LightBlue,
|
|
Players::Enemy => Color::LightRed,
|
|
Players::Unclaimed => Color::LightGreen,
|
|
}
|
|
}
|
|
|
|
fn get_level(&self) -> char {
|
|
(self.level + b'0') as char
|
|
}
|
|
|
|
fn get_durability(&self) -> u16 {
|
|
self.durability
|
|
}
|
|
|
|
fn get_max_durability(&self) -> u16 {
|
|
1500
|
|
}
|
|
|
|
fn get_stress(&self) -> u8 {
|
|
self.stress
|
|
}
|
|
|
|
fn get_name(&self) -> &'static str {
|
|
"Base"
|
|
}
|
|
|
|
fn get_owner(&self) -> Players {
|
|
self.owner
|
|
}
|
|
}
|