generated from GarandPLG/rust-flake-template
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`.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::app::states::skirmish_states::BoardState;
|
||||
use crate::{app::states::skirmish_states::BoardState, cli::Cli};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SkirmishState {
|
||||
@@ -6,4 +6,15 @@ pub struct SkirmishState {
|
||||
pub name: &'static str,
|
||||
pub board: BoardState,
|
||||
pub side_panel: bool,
|
||||
pub turn_counter: u64,
|
||||
}
|
||||
|
||||
impl SkirmishState {
|
||||
pub fn update(&mut self, cli: &Cli) {
|
||||
self.board.advance_turn();
|
||||
|
||||
// if self.board.is_victory() {}
|
||||
|
||||
self.turn_counter += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user