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`.
This commit is contained in:
2026-05-04 16:14:54 +02:00
parent 1daa9802ed
commit 766b65b2fc
10 changed files with 92 additions and 19 deletions
+11 -4
View File
@@ -4,7 +4,7 @@ use crate::app::{
FocusedCell, Offset,
skirmish_states::{
CellSizes, MoveFocusedCell, Players, ZoomLevel,
structures::{BaseBuilding, Stone, Structures},
structures::{BaseBuilding, Ore, Stone, Structures},
units::{MinerUnit, Units},
},
},
@@ -58,12 +58,12 @@ impl BoardState {
let horizontal_offset: Offset = Offset::new(None, Some(h_max_offset));
let focused_cell: FocusedCell =
FocusedCell::new((map_height) / 2, 2, map_height, map_width);
FocusedCell::new((map_height) / 2, 3, map_height, map_width);
let mut cells: Vec<Vec<CellWidget>> = Vec::new();
let player_base_coords: (usize, usize) = ((map_height) / 2, 1);
let enemy_base_coords: (usize, usize) = ((map_height) / 2, map_width - 2);
let player_base_coords: (usize, usize) = ((map_height) / 2, 2);
let enemy_base_coords: (usize, usize) = ((map_height) / 2, map_width - 3);
for row in 0..map_height {
let mut rows: Vec<CellWidget> = Vec::new();
@@ -71,12 +71,19 @@ impl BoardState {
for col in 0..map_width {
let selected: bool = row == focused_cell.get_row() && col == focused_cell.get_col();
let player_base: bool = row == player_base_coords.0 && col == player_base_coords.1;
let player_ore: bool =
row == player_base_coords.0 && col == player_base_coords.1 - 1;
let enemy_base: bool = row == enemy_base_coords.0 && col == enemy_base_coords.1;
let enemy_ore: bool = row == enemy_base_coords.0 && col == enemy_base_coords.1 + 1;
let structure: Structures = if player_base {
Structures::Base(BaseBuilding::new(Players::Player))
} else if enemy_base {
Structures::Base(BaseBuilding::new(Players::Enemy))
} else if player_ore {
Structures::Ore(Ore::new(Players::Player))
} else if enemy_ore {
Structures::Ore(Ore::new(Players::Enemy))
} else {
Structures::Stone(Stone::new())
};