Move skirmish Offset and FocusedCell to own module

Extract Offset and FocusedCell structs from skirmish.rs into a new
skirmish_states module. Re-export the structs from the top-level states
module and adjust imports in skirmish.rs.
This commit is contained in:
2026-04-01 22:10:25 +02:00
parent f405c3cde1
commit c4e28255b6
5 changed files with 94 additions and 86 deletions
@@ -0,0 +1,34 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct FocusedCell {
pub row: usize,
pub col: usize,
pub max_row: usize,
pub max_col: usize,
}
impl FocusedCell {
pub fn new(row: usize, col: usize, max_row: usize, max_col: usize) -> Self {
Self {
row,
col,
max_row,
max_col,
}
}
pub fn move_up(&mut self) {
self.row = self.row.saturating_sub(1).max(0);
}
pub fn move_down(&mut self) {
self.row = self.row.saturating_add(1).min(self.max_row - 1);
}
pub fn move_left(&mut self) {
self.col = self.col.saturating_sub(1).max(0);
}
pub fn move_right(&mut self) {
self.col = self.col.saturating_add(1).min(self.max_col - 1);
}
}