diff --git a/src/game/mod.rs b/src/game/mod.rs index bf41e6c..b099460 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -1,5 +1,4 @@ use bevy::prelude::*; -use tracing::instrument; use crate::tiles::{self, *}; @@ -25,7 +24,7 @@ impl Plugin for Riichi { .add_systems(Startup, tiles::init_tiles) .init_state::() .add_systems(OnEnter(GameState::Setup), (wall::build_wall, hand::deal_hands, setup_done).chain()) - // .add_systems(Update, systems) + .add_systems(Update, (hand::sort_hand).run_if(in_state(GameState::Play))) // semicolon stopper ; } diff --git a/src/game/wall.rs b/src/game/wall.rs index 5202d0e..69e4fd7 100644 --- a/src/game/wall.rs +++ b/src/game/wall.rs @@ -1,4 +1,3 @@ -use bevy::log::tracing::instrument; use bevy::prelude::*; use rand::seq::SliceRandom; diff --git a/src/lib.rs b/src/lib.rs index 1740455..45412c3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![allow(unused)] +pub mod game; pub mod tiles; pub mod yakus; - -pub mod game; diff --git a/src/tiles.rs b/src/tiles.rs index 634e115..5147233 100644 --- a/src/tiles.rs +++ b/src/tiles.rs @@ -1,8 +1,5 @@ use bevy::{ecs::entity::MapEntities, prelude::*}; use strum::FromRepr; -use tracing::instrument; - -use crate::game::{hand::HandTiles, wall::WallTiles}; #[derive(Component, Debug)] pub struct Tile { diff --git a/src/tui/mod.rs b/src/tui/mod.rs index 639b23a..5ccd9bf 100644 --- a/src/tui/mod.rs +++ b/src/tui/mod.rs @@ -18,11 +18,22 @@ enum TuiState { InGame, } -#[derive(Default)] -pub struct RiichiTui { - // player_names: Vec, +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +struct InGame; + +impl ComputedStates for InGame { + type SourceStates = TuiState; + + fn compute(sources: Self::SourceStates) -> Option { + match sources { + TuiState::MainMenu => None, + TuiState::InGame => Some(Self), + } + } } +#[derive(Default)] +pub struct RiichiTui; impl Plugin for RiichiTui { fn build(&self, app: &mut App) { app.add_plugins(( @@ -45,48 +56,17 @@ impl Plugin for RiichiTui { // general setup .init_state::() .add_computed_state::() - .add_systems(Update, curr_state) // main menu .add_systems(Update, (menu::draw_mainmenu, menu::mainmenu_input).run_if(in_state(TuiState::MainMenu))) // gaming .init_resource::() - .add_systems(OnEnter(GameState::Play), render::hand::render_hand) + .add_systems(Update, render::ingame::draw_ingame.run_if(in_state(InGame))) .add_systems(Update, render::hand::render_changed_hand.run_if(in_state(InGame).and(in_state(GameState::Play)))) - .add_systems(Update, render::ingame::draw_ingame.run_if(in_state(TuiState::InGame))) // semicolon stopper ; } } -fn curr_state( - curr_gamestate: Option>>, - curr_tuistate: Res>, - curr_ingame: Option>>, -) { - if let Some(curr_gamestate) = curr_gamestate && curr_gamestate.is_changed(){ - trace!("GameState: {curr_gamestate:?}") - } - if curr_tuistate.is_changed() { - trace!("TuiState: {curr_tuistate:?}") - } - if let Some(curr_ingame) = curr_ingame && curr_ingame.is_changed(){ - trace!("InGame: {curr_ingame:?}") - } -} - -#[derive(Clone, PartialEq, Eq, Hash, Debug)] -struct InGame; - -impl ComputedStates for InGame { - type SourceStates = TuiState; - - fn compute(sources: Self::SourceStates) -> Option { - match sources { - TuiState::MainMenu => None, - TuiState::InGame => Some(Self), - } - } -}