Add Miner stats and conditional audio flag

- Extend MinerUnit with hp, digging ability, and power, and provide
  getters for these fields.
- Update the Unit trait and Units enum to expose hp, max hp,
  can_dig, and digging_power, and enhance base_text to display them.
- Remove unnecessary `Eq` derives from several structs and enums.
- Introduce a `--disable-audio` CLI flag and conditionally spawn the
  audio thread based on its value.
This commit is contained in:
2026-05-05 16:58:29 +02:00
parent 35209dd064
commit a1d0a84885
9 changed files with 113 additions and 14 deletions
@@ -3,7 +3,7 @@ use crate::app::states::skirmish_states::{
units::{MinerUnit, Unit},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Units {
Miner(MinerUnit),
}
@@ -28,9 +28,29 @@ impl Unit for Units {
fn get_owner(&self) -> Players {
self.unit().get_owner()
}
fn get_hp(&self) -> u16 {
self.unit().get_hp()
}
fn get_max_hp(&self) -> u16 {
self.unit().get_max_hp()
}
fn get_can_dig(&self) -> bool {
self.unit().get_can_dig()
}
fn get_digging_power(&self) -> f32 {
self.unit().get_digging_power()
}
}
impl Unit for Option<Units> {
fn is_unit(&self) -> bool {
self.map_or(false, |u| u.is_unit())
}
fn get_tag(&self) -> char {
self.map_or(' ', |u| u.get_tag())
}
@@ -43,7 +63,19 @@ impl Unit for Option<Units> {
self.map_or(Players::Unclaimed, |u| u.get_owner())
}
fn is_unit(&self) -> bool {
self.map_or(false, |u| u.is_unit())
fn get_hp(&self) -> u16 {
self.map_or(0, |u| u.get_hp())
}
fn get_max_hp(&self) -> u16 {
self.map_or(0, |u| u.get_max_hp())
}
fn get_can_dig(&self) -> bool {
self.map_or(false, |u| u.get_can_dig())
}
fn get_digging_power(&self) -> f32 {
self.map_or(0.0, |u| u.get_digging_power())
}
}