Files
war-in-tunnels/src/app/states/skirmish_states/structures/base.rs
T
GarandPLG 766b65b2fc Introduce Ore structure and simplify durability fields
Add a new Ore structure with ownership, amount, and durability, and
extend the
Structures enum to include it. Update board generation to place ore
cells next
to player and enemy bases and adjust base coordinates accordingly.
Remove the
redundant `max_durability` field from BaseBuilding, Stone, and Tunnel,
fixing
their `get_max_durability` implementations to return constant values.
Rename the
tick handling parameter from `interval_ms` to `tick_ms`. Minor clean‑ups
include
re‑exporting the Ore module, adding TODO comments in the side panel
widget, and
simplifying the audio thread spawn in `main.rs`.
2026-05-04 16:14:54 +02:00

60 lines
1.1 KiB
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: b'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 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
}
}