Refactor buildings/units, move CellTag & Players

Introduce BaseBuilding struct. Rename Building and Unit to enum types
(Buildings, Units). Move CellTag and Players enums to the skirmish state
module and update imports and re‑exports accordingly. Add placeholder
miner module.
This commit is contained in:
2026-04-15 13:21:39 +02:00
parent 44d29bd3ad
commit be41936f14
11 changed files with 38 additions and 26 deletions
+6
View File
@@ -0,0 +1,6 @@
use crate::app::states::Players;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BaseBuilding {
owner: Players,
}
+1 -1
View File
@@ -1,2 +1,2 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Building {}
pub enum Buildings {}
+2 -1
View File
@@ -1,3 +1,4 @@
pub mod base;
pub mod building;
pub use building::Building;
pub use building::Buildings;
+1 -1
View File
@@ -9,5 +9,5 @@ pub use main_menu::MainMenuState;
pub use perk_decks::{PerkDecks, PerkDecksState};
pub use settings::SettingsState;
pub use skills_config::SkillsConfigState;
pub use skirmish::{GameMode, SkirmishState, ZoomLevel};
pub use skirmish::{CellTag, GameMode, Players, SkirmishState, ZoomLevel};
pub use skirmish_states::{FocusedCell, Offset};
+13
View File
@@ -20,3 +20,16 @@ pub enum ZoomLevel {
Default,
ZoomedOut,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CellTag {
Base(Players),
Tunel,
Stone,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Players {
Player,
Enemy,
}
+2 -2
View File
@@ -1,7 +1,7 @@
use crate::app::{
helpers::{CellSizes, cell_size_helper, cells_area_helper},
states::{FocusedCell, Offset, ZoomLevel, skirmish_states::MoveFocusedCell},
widgets::{CellTag, CellWidget, Players},
states::{CellTag, FocusedCell, Offset, Players, ZoomLevel, skirmish_states::MoveFocusedCell},
widgets::CellWidget,
};
use ratatui::layout::Rect;
View File
+2 -1
View File
@@ -1,3 +1,4 @@
pub mod miner;
pub mod unit;
pub use unit::Unit;
pub use unit::Units;
+1 -1
View File
@@ -1,2 +1,2 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Unit {}
pub enum Units {}
+9 -18
View File
@@ -1,4 +1,8 @@
use crate::app::{buildings::Building, states::ZoomLevel, units::Unit};
use crate::app::{
buildings::Buildings,
states::{CellTag, Players, ZoomLevel},
units::Units,
};
use ratatui::{
buffer::Buffer,
layout::{Alignment, Rect},
@@ -7,19 +11,6 @@ use ratatui::{
widgets::{Block, Borders, Paragraph, Widget},
};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CellTag {
Base(Players),
Tunel,
Stone,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Players {
Player,
Enemy,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CellWidget {
row: usize,
@@ -28,8 +19,8 @@ pub struct CellWidget {
zoom_level: ZoomLevel,
tag: CellTag,
marked: bool,
unit: Option<Unit>,
building: Option<Building>,
unit: Option<Units>,
building: Option<Buildings>,
}
impl CellWidget {
@@ -39,8 +30,8 @@ impl CellWidget {
zoom_level: ZoomLevel,
selected: bool,
tag: CellTag,
unit: Option<Unit>,
building: Option<Building>,
unit: Option<Units>,
building: Option<Buildings>,
) -> Self {
Self {
row,
+1 -1
View File
@@ -3,5 +3,5 @@ pub mod cell;
pub mod keybindings;
pub use board::BoardWidget;
pub use cell::{CellTag, CellWidget, Players};
pub use cell::CellWidget;
pub use keybindings::KeybindingsWidget;