Commit Graph

27 Commits

Author SHA1 Message Date
GarandPLG 00eeb97ed8 Add progress tracking to tasks and turn advancement
- Extend the `Task` trait with methods for progress handling and
  completion.
- Update `DiggingTask` to store `progress` and `tick_increase`, and
  implement the new trait methods.
- Implement the new methods in the `Tasks` enum, adding a mutable
  accessor.
- Introduce `BoardState::get_active_tasks` and
  `BoardState::advance_turn` to iterate over active tasks and update
  their progress each turn.
- Un-comment the call to `board.advance_turn()` in
  `SkirmishState::tick_update`.
2026-05-20 12:49: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 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 7541db79d8 Refactor App to use unified AppChannels for events
App now receives an AppChannels struct; AppEvent enum removed.

Event handling, tick generation, and audio communication are now
performed through dedicated channels.
2026-05-03 22:27:08 +02:00
GarandPLG 7fb001faab Add tick thread and Skirmish state update
Introduce `AppEvent::Tick` and a background thread that emits timed
events. `App` now handles `Tick` by calling a new `update` method,
which advances the board and increments a `turn_counter` in
`SkirmishState`. Add required imports, fields, and the
`spawn_tick_thread` call in `main`.
2026-05-03 18:14:46 +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 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 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 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 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
GarandPLG 07e941eba1 Add bounded focus and padding to skirmish UI
- Initialize FocusedCell with map dimensions and start near the map
  centre.
- Store max rows/cols in FocusedCell and clamp moves to these bounds.
- Scroll actions now adjust the corresponding offset and also move the
  focused cell, keeping navigation consistent.
- Zoom actions modify the vertical offset to keep the view centered
  after
  changing zoom levels.
- Cell widget now uses a Padding widget with dynamic top padding based
  on
  the area height.
2026-03-30 16:32:28 +02:00
GarandPLG 363baa1c1a Add navigation and selection for skirmish cells
Reclassify Escape key as Quit and add directional actions to move the
focused cell.
2026-03-29 22:03:22 +02:00
GarandPLG 1d1dc0f2f7 Add zoom support and dynamic keybinding layout
Introduce ZoomIn/ZoomOut actions and a Zoom group with corresponding
keybindings.
Add a CLI option to set the initial zoom level and a ZoomLevel enum.
Expose a utility to compute the largest keybinding group size for layout
sizing.
Refactor board widget to adjust cell dimensions based on zoom level and
simplify offset calculations.
Update views to use the new layout sizing helper and integrate zoom
handling in skirmish logic.
2026-03-29 14:12:03 +02:00
GarandPLG edf491457e Add init flags to Offset and set vertical offset
Add `value_initiated` and `max_initiated` flags to prevent
repeated assignments. Provide `set_initial_value` for one‑time
initialisation and use it to centre the vertical offset when
creating the board widget. Remove stale comments on cell size constants.
2026-03-28 14:35:05 +01:00
GarandPLG 9300eef906 Initialize skirmish board and refactor states
- Create `GameStates` from a `&Cli` and initialize the skirmish board in
  `App::new`.
- Move map dimensions to `SkirmishState` and add a `board_cells` vector
  populated by `CellWidget`s.
- Refactor `SettingsState` to store only user‑specific settings (fields
  are cloned).
- Update `BoardWidget` to hold a reference to the cell vector and use
  the new dimensions.
- Adjust CLI defaults: map width to 50 and map height to 25.
2026-03-27 19:25:20 +01:00
GarandPLG 5a40760151 Replace scrollbar state with simple offset struct
Introduce Offset type to track scroll positions and replace
ScrollbarState fields in SkirmishState
Update keybindings, App::draw, Widget impl, and BoardWidget::new
to use mutable references and the new Offset struct.
Adjust imports accordingly.
2026-03-26 21:50:39 +01:00
GarandPLG cc179cee03 Add scrolling actions and board widget
Introduce directional and scroll actions, update keybindings, add
scrollbar
state to SkirmishState, and render the board with a new BoardWidget.
Adjust CLI
defaults and layout heights accordingly.
2026-03-26 11:05:43 +01:00
GarandPLG 0577697059 Replace settings module with skirmish mode
Removed the settings UI and its keybinding logic, added a skirmish view
and corresponding keybindings, simplified the SettingsState to hold
skirmish configuration, updated module exports, and changed the CLI
default map height from 25 to 21. Also fixed the main menu selection
limit.
2026-03-17 14:28:46 +01:00
GarandPLG aaa2c90426 Refactor gaamestates 2026-03-16 21:58:43 +01:00