turn_state logic

This commit is contained in:
Tao Tien 2026-02-10 01:40:13 -08:00
parent f6361b9fa1
commit 1e6a3ca84b
10 changed files with 61 additions and 16 deletions

View file

@ -21,7 +21,7 @@ use crate::{
game::{
hand::{Hand, Pond},
player::{CurrentPlayer, MainPlayer},
round::{TurnState, Wind},
round::Wind,
wall::Wall,
},
tile::{self},
@ -65,7 +65,7 @@ impl Plugin for Riichi {
app.add_plugins(plugins)
.init_state::<GameState>()
// .add_sub_state::<TurnState>()
.add_sub_state::<TurnState>()
// .init_resource::<round::MatchSettings>()
// .init_resource::<round::Compass>()
.add_message::<GameMessage>()

View file

@ -12,6 +12,7 @@ use crate::{
wall::Wall,
},
};
use jong_types::TurnState;
// #[derive(Resource)]
// pub struct CurrentPlayer(pub Entity);
@ -48,18 +49,6 @@ pub enum WindRelation {
Kamicha,
}
#[derive(SubStates, Default, Clone, Copy, PartialEq, Eq, Hash, Debug, FromRepr, EnumCount)]
#[source(GameState = GameState::Play)]
pub(crate) enum TurnState {
#[default]
Tsumo,
Menzen,
RiichiKan,
Discard,
RonChiiPonKan,
End,
}
#[derive(Component, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub(crate) enum CallType {
Skip,

View file

@ -5,6 +5,7 @@
use super::game_state_type::GameState;
use super::lobby_type::Lobby;
use super::player_or_bot_type::PlayerOrBot;
use super::turn_state_type::TurnState;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `lobby`.

View file

@ -6,6 +6,7 @@ use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::game_state_type::GameState;
use super::player_or_bot_type::PlayerOrBot;
use super::turn_state_type::TurnState;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -14,6 +15,7 @@ pub struct Lobby {
pub host_player_id: u32,
pub players: Vec<PlayerOrBot>,
pub game_state: GameState,
pub turn_state: TurnState,
}
impl __sdk::InModule for Lobby {

View file

@ -26,6 +26,7 @@ pub mod rank_type;
pub mod shuffle_deal_reducer;
pub mod suit_type;
pub mod tile_type;
pub mod turn_state_type;
pub mod view_player_hand_table;
pub mod wall_table;
pub mod wall_type;
@ -55,6 +56,7 @@ pub use rank_type::Rank;
pub use shuffle_deal_reducer::{set_flags_for_shuffle_deal, shuffle_deal, ShuffleDealCallbackId};
pub use suit_type::Suit;
pub use tile_type::Tile;
pub use turn_state_type::TurnState;
pub use view_player_hand_table::*;
pub use wall_table::*;
pub use wall_type::Wall;

View file

@ -0,0 +1,28 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
#[derive(Copy, Eq, Hash)]
pub enum TurnState {
None,
Tsumo,
Menzen,
RiichiKan,
Discard,
RonChiiPonKan,
End,
}
impl __sdk::InModule for TurnState {
type Module = super::RemoteModule;
}