Add Building and Unit structs, extend CellWidget

Introduce empty Building and Unit types and expose them
through new modules. Extend CellWidget to store optional
Unit and Building, update its constructor, and adjust board
rendering to create cells with these new fields (currently always None).
This commit is contained in:
2026-04-13 21:27:44 +02:00
parent 1393f282e8
commit 44d29bd3ad
7 changed files with 26 additions and 4 deletions
+2
View File
@@ -0,0 +1,2 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Building {}
+3
View File
@@ -0,0 +1,3 @@
pub mod building;
pub use building::Building;
+2
View File
@@ -1,10 +1,12 @@
pub mod app;
pub mod buildings;
pub mod helpers;
pub mod keybind;
pub mod keybindings;
pub mod state;
pub mod states;
pub mod threads;
pub mod units;
pub mod view;
pub mod views;
pub mod widgets;
+7 -3
View File
@@ -57,16 +57,20 @@ 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 enemy_base: bool = row == enemy_base_coords.0 && col == enemy_base_coords.1;
let tag: CellTag = if row == player_base_coords.0 && col == player_base_coords.1 {
let tag: CellTag = if player_base {
CellTag::Base(Players::Player)
} else if row == enemy_base_coords.0 && col == enemy_base_coords.1 {
} else if enemy_base {
CellTag::Base(Players::Enemy)
} else {
CellTag::Stone
};
rows.push(CellWidget::new(row, col, zoom_level, selected, tag));
rows.push(CellWidget::new(
row, col, zoom_level, selected, tag, None, None,
));
}
cells.push(rows);
+3
View File
@@ -0,0 +1,3 @@
pub mod unit;
pub use unit::Unit;
+2
View File
@@ -0,0 +1,2 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Unit {}
+7 -1
View File
@@ -1,4 +1,4 @@
use crate::app::states::ZoomLevel;
use crate::app::{buildings::Building, states::ZoomLevel, units::Unit};
use ratatui::{
buffer::Buffer,
layout::{Alignment, Rect},
@@ -28,6 +28,8 @@ pub struct CellWidget {
zoom_level: ZoomLevel,
tag: CellTag,
marked: bool,
unit: Option<Unit>,
building: Option<Building>,
}
impl CellWidget {
@@ -37,6 +39,8 @@ impl CellWidget {
zoom_level: ZoomLevel,
selected: bool,
tag: CellTag,
unit: Option<Unit>,
building: Option<Building>,
) -> Self {
Self {
row,
@@ -45,6 +49,8 @@ impl CellWidget {
zoom_level,
tag,
marked: false,
unit,
building,
}
}