Commit Graph

49 Commits

Author SHA1 Message Date
GarandPLG e3c3ad96e3 Add delete flag to end_marking_cells
Pass true when handling the Delete action and false for normal cleanup,
updating all call sites to use the new boolean parameter.
2026-05-19 13:24:33 +02:00
GarandPLG ec4c68364d Add two spaces after miner task icon 2026-05-19 01:01:29 +02:00
GarandPLG 5b960c65ff Rename marking methods and use get_coords
Introduce push_marked_cell, pop_marked_cell and end_marking_cells to
replace the
previous set_marked_cell, undo_marked_cell and clear_marked_cells.
Collapse
get_row/get_col into get_coords and update all callers accordingly.
2026-05-19 00:59:48 +02:00
GarandPLG 34c5e448ce . 2026-05-18 17:37:31 +02:00
GarandPLG 291670fad3 Return task queue as styled Line vectors
Change `get_tasks_formatted` to return a `Vec<Line<'_>>` instead of a
plain
`String`. Update `MinerUnit` to construct colored task lines, modify the
`Unit` trait and `Units` implementations to use the new return type, and
add the required `ratatui` imports. Adjust `base_text` handling to
render
each task line separately.
2026-05-18 16:02:12 +02:00
GarandPLG d2f5968861 Add Task trait and improve miner task display
Define a full `Task` trait with icon and path accessors. Implement the
trait for
`DiggingTask` and delegate it through the `Tasks` enum. Introduce helper
functions in `MinerUnit` to convert coordinates to spreadsheet‑style
strings
and use them in a revamped `get_tasks_formatted`. Update the unit
rendering
logic to show the tasks queue only when tasks are present.
2026-05-18 15:48:40 +02:00
GarandPLG 7c9e3d28f0 Refactor task handling to use VecDeque references
- Change `get_tasks` to return `&VecDeque<Tasks>` instead of a formatted
  `String`.
- Introduce `get_tasks_formatted` for display purposes.
- Update `MinerUnit`, `Unit` trait, `Units` enum, and its `Option`
  implementation accordingly.
- Add `EMPTY_TASKS` lazy static for handling empty task lists.
- Adjust `BoardState` to use the new task API (commented out
  conditional).
2026-05-18 14:48:07 +02:00
GarandPLG e4728aab5d Show unit task queue and mark in side panel
Add `get_tasks` to the `Unit` trait and implement it for `MinerUnit`,
`Units` enum and `Option<Units>`.  Use the new method in `base_text` to
display a “Tasks Queue” line.

Refactor task assignment in `BoardState` to a chained call.

Update the skirmish view and `SidePanelWidget` to pass a flag indicating
whether the displayed unit is the currently marked one, and highlight
the
unit name accordingly.
2026-05-17 11:00:06 +02:00
GarandPLG f554fa2efc Add digging tasks and unit coordinate support
Introduce Tasks handling for units, store coordinates in MinerUnit,
expose getters/setters for unit tasks, add logging of marked cells,
and provide cell accessors for mutable unit options.
2026-05-12 13:42:13 +02:00
GarandPLG a3bb9dc6f1 Remove unused base coordinates from BoardState 2026-05-12 10:51:18 +02:00
GarandPLG d87316e4fe Remove unused lifetimes from app structs 2026-05-12 10:48:48 +02:00
GarandPLG cd1822d05e Add lifetime parameter and MarkedCells struct
Refactor App, GameStates, SkirmishState and BoardState to carry a
generic
lifetime `'a`. Introduce a new `MarkedCells` type that holds marking
state
and selected unit, replacing the previous `marking_cells` flag and raw
deque. Update related methods, keybindings, view implementations and
module exports to use the new structures.
2026-05-06 21:39:53 +02:00
GarandPLG b66c1d8e25 Use VecDeque for tasks and marked cells
Replace `Vec` with `VecDeque` in `BoardState` marked cells,
`DiggingTask` path,
and `MinerUnit` tasks to enable efficient push/pop operations. Remove
the
`Copy` trait from several structs and enums, adjust derives accordingly,
and
use `as_ref` in `Option<Units>` implementations to avoid consuming the
option.
Update cell rendering to clone widgets and adjust
`CellWidget::get_option_unit`
to return a cloned `Option<Units>`. Add necessary `VecDeque` imports.
2026-05-06 20:01:49 +02:00
GarandPLG 41020708e4 Rename internal helpers and adjust related calls
Rename `structure` to `s` in Structures and `unit` to `u` in Units,
updating all
call sites. Refactor `Structures::text` to match on the owner directly
and
push the owner line only for claimed owners. Change the “% )” token
color
in unit display from green to gray.
2026-05-06 18:51:45 +02:00
GarandPLG 644d8648b2 Refactor DiggingTask and embed it in Tasks enum
- Remove lifetime and path storage from DiggingTask, make it Copy.
- Add a placeholder `new` constructor that accepts a path.
- Update the Tasks enum to hold a DiggingTask value.
- Reorder module declarations and re‑export order for tasks.
- Add a commented‑out tasks field to MinerUnit as a preparation step.
2026-05-05 17:43:50 +02:00
GarandPLG 1c0f27f115 Add tasks module and rename trait files 2026-05-05 17:14:33 +02:00
GarandPLG a1d0a84885 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.
2026-05-05 16:58:29 +02:00
GarandPLG b1183175be Display structure owner and adjust UI layouts
Add owner line to structure text, using gray label and owner span.
Switch side panel layout to Fill/Length and remove left border from side
panel widget.
Import Stylize for colored text rendering.
2026-05-05 13:34:07 +02:00
GarandPLG 55a260755c Add ore level support and unify text rendering
Introduce a numeric `level` field for `BaseBuilding` and `Ore`, update
their
constructors and `get_level` implementations, and increase the default
ore
amount to the new maximum. Extend the `Structure` and `Unit` traits with
`base_text` and `text` methods, add `is_unit` to `Units`, and adjust the
`Structures` enum to delegate text rendering. Refactor `SidePanelWidget`
to
use the unified trait methods, removing duplicated rendering code.
Update
`BoardState` to create ore structures with an initial level of 1.
2026-05-05 00:18:49 +02:00
GarandPLG 766b65b2fc 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`.
2026-05-04 16:14:54 +02:00
GarandPLG b639531841 Refactor GameMode and Players into skirmish_states
Move the GameMode and Players enums from the top‑level states module
into the
skirmish_states submodule, add an Unclaimed variant to Players, and
update all
imports, trait implementations, and related logic accordingly. Adjust
the
durability percentage calculation to use u32 for safety.
2026-05-01 19:05:03 +02:00
GarandPLG f7c1795f29 Add max durability and enhance side panel UI
- Introduce `max_durability` fields to BaseBuilding, Stone, and Tunnel
  structures.
- Extend `Structure` trait with `get_max_durability` and implement it in
  all structures.
- Update `Structures` enum to forward `get_max_durability`.
- Add color utilities and `get_span` method to `Players` enum for styled
  text.
- Refactor `CellWidget` method names (`get_option_unit`,
  `set_structure`).
- Revise side panel widget to accept references to `Structures` and
  `Option<Units>`, render colored blocks and detailed stats.
- Simplify skirmish view to use `BoardState` directly and adapt side
  panel rendering.
2026-04-26 21:04:19 +02:00
GarandPLG c24862dd48 Extract helper methods for enum trait implementations 2026-04-24 11:53:07 +02:00
GarandPLG cf843057c3 Add side panel and refactor title helpers
Introduce a `side_panel` flag throughout the skirmish state, board
creation,
and cell area calculation to enable a detachable side panel. Refactor
the
title helper to own its strings and use a static separator, updating the
single‑title helper accordingly. Add a new `SidePanelWidget` and expose
the
`skirmish_main_area_layout` helper. Extend keybindings with `Tab` and
`ShiftTab` actions under a new `Opener` group. Update structures and
units
to implement a `get_name` method and adjust related traits and imports.
2026-04-24 11:41:09 +02:00
GarandPLG 06a439ff88 Move ZoomLevel into skirmish_states
Introduce Structure and Unit traits with enum wrappers.
Replace old zoom helper with ZoomLevel methods.
Update imports, BoardState, CellWidget, and CLI to use new locations.
2026-04-20 12:17:56 +02:00
GarandPLG 0a8b3562f6 Rename buildings module to structures 2026-04-19 20:02:21 +02:00
GarandPLG 33088dc29d Add Stone and Tunnel, refactor CellStructure
Introduce new building types Stone and Tunnel with their own tag, color,
and
properties. CellStructure now holds these structs (Tunnel, Stone)
instead of
simple variants. BaseBuilding is simplified to return a char tag and a
color
based on owner. BoardState creation and CellWidget rendering are updated
to
use the new building structs and their methods.
2026-04-19 20:00:59 +02:00
GarandPLG 54e86b2688 Move buildings and units under skirmish_states
Reorganize the codebase by moving the buildings and units modules
into the skirmish_states namespace, updating imports accordingly.
2026-04-19 18:02:36 +02:00
GarandPLG f5ef4b4931 Privatize internal modules and adjust re‑exports 2026-04-16 22:22:32 +02:00
GarandPLG e6d87dd064 Refactor Units enum location and chain CellWidget setters
Move Units enum from the units module into the skirmish state module,
add a dedicated Players enum, and remove the now‑unused unit module.
Update all imports accordingly.
Adjust CellWidget's set_zoom_level and set_structure to return &mut
Self,
enabling method chaining.
2026-04-16 22:02:15 +02:00
GarandPLG 6dc5f8605c Replace CellTag with CellStructure and embed BaseBuilding
The refactor removes the `Buildings` enum and the `building` module,
replacing
`CellTag` with a new `CellStructure` enum that directly holds a
`BaseBuilding`.
A `get_owner` method is added to `BaseBuilding` to support the new
structure.
All related imports, constructors, and rendering logic are updated to
use
`CellStructure` instead of the old tag and building fields.
2026-04-16 21:56:06 +02:00
GarandPLG 0f60249309 Add BaseBuilding and MinerUnit with UI rendering 2026-04-16 10:59:02 +02:00
GarandPLG be41936f14 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.
2026-04-15 13:21:39 +02:00
GarandPLG 44d29bd3ad 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).
2026-04-13 21:27:44 +02:00
GarandPLG 1393f282e8 Refactor cell marking, add undo, update keybindings
CellWidget::set_selected and set_marked now return &mut Self for method
chaining. Added BoardState::undo_marked_cell to remove the last marked
cell and restore focus. Backspace triggers undo, Delete clears marking.
2026-04-13 16:57:44 +02:00
GarandPLG d5f4d03264 Add toggle_marking and simplify marking logic
Introduce a public `BoardState::toggle_marking` that flips the
marking mode and starts or clears marking accordingly. Refactor
`set_marked_cell` to accept tuple coordinates and clean up its
logic. Update `change_focused_cell` to work with the new signature
and use the toggle helper. Adjust cell display to show coordinates
when a cell is marked.
2026-04-10 21:30:48 +02:00
GarandPLG 869ba0bb7f Add marking mode; rename resize and zoom methods
Introduce a marking mode that lets users toggle cells with Space and
clear
them with Backspace. BoardState now stores `marking_cells` and a list of
`marked_cells` and provides methods to start, clear, and update marks.
CellWidget tracks a `marked` flag and renders marked cells in
LightMagenta.

Keybindings are updated: Space now reads “Marking cells”, Backspace
reads
“Cancel marking”, and the original Enter binding is commented out.

The former `resize_change` and `zoom_change` functions are renamed to
`change_resize` and `change_zoom`; all call sites are updated
accordingly.
2026-04-10 19:06:47 +02:00
GarandPLG b45c300bc3 Add base tags, adjust margins, update CLI defaults
Introduce `CellTag` and `Players` enums and extend `CellWidget` to carry
a tag.
Store player and enemy base coordinates in `BoardState` and tag those
cells.
Reduce horizontal margin from 3 to 1 in board layout helpers.
Change CLI defaults: map width default 42, map height min 11 and default
11.
Adjust offset calculation and render constraints to match the new
layout.
2026-04-09 18:16:26 +02:00
GarandPLG 56bef7c98e Refactor CellWidget constructor to accept selected
Update `CellWidget::new` to take a `selected` flag and remove the
chaining return values from `set_selected` and `set_zoom_level`. The
board code now passes the selection state directly during construction.
2026-04-08 23:43:16 +02:00
GarandPLG 247f5c143b Adjust board vertical offset and focus 2026-04-08 14:51:04 +02:00
GarandPLG e4682f1c52 Refactor board cells to 2D vector and auto‑scroll
Store cells as a nested vector instead of a flat list, simplifying
indexing and
rendering. Add `is_focused_cell_visible` to detect when the focused cell
is
outside the viewport and adjust vertical/horizontal offsets accordingly
in
the skirmish keybindings. Update related methods and widget rendering to
use
the new 2‑D structure.
2026-04-08 14:25:14 +02:00
GarandPLG 4917068fb1 Fix board after resize 2026-04-08 13:24:44 +02:00
GarandPLG 04db2f1daf Make BoardState fields private 2026-04-08 00:08:09 +02:00
GarandPLG 48483da1a4 Refactor skirmish focus handling and CellWidget API
Introduce a MoveFocusedCell enum and a BoardState.change_focused_cell
method to
centralize focus movement logic. Update skirmish keybindings to use this
new
method and simplify board rendering by directly using stored CellWidget
state.
Make CellWidget setters chainable and expose the new enum in the module
re‑exports. Remove duplicated max_offset logic and old move_* methods.
2026-04-07 23:20:11 +02:00
GarandPLG e3fea75983 Add zoom support and emoji keybinding icons
- CellWidget now stores a ZoomLevel, renders size‑dependent text, and
  provides
  methods to set the zoom level and build its block.
- BoardState creates cells with the current zoom level, adds a helper to
  get a
  mutable cell, and updates each cell’s zoom level in `zoom_change`.
- KeybindingsWidget constructor now takes the widget height, calculates
  vertical padding to centre groups, and adds left borders between
  groups.
- Views (default, main_menu, skirmish) pass the area height to the new
  constructor.
- Keybinding descriptions are replaced with emoji symbols (🔈, 🔊, 🔉).
- BoardWidget clones the cell template instead of dereferencing it.
2026-04-07 19:21:43 +02:00
GarandPLG 3f646de3bb Encapsulate cell selection and simplify board rendering 2026-04-07 17:48:05 +02:00
GarandPLG 2b96ec129f Encapsulate FocusedCell fields and add getters 2026-04-07 01:14:36 +02:00
GarandPLG 923af91aeb Lazy init game states and extract board module
App now stores CLI arguments and an optional GameStates, initializing
the
states lazily on the first window resize. Skirmish board logic is moved
to
a new BoardState module with dedicated helpers (cells_area_helper and
updated cell size handling). Views and keybindings are updated to use
the
optional state accessors.
2026-04-02 00:45:57 +02:00
GarandPLG c4e28255b6 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.
2026-04-01 22:10:25 +02:00