turn_state logic
This commit is contained in:
parent
f6361b9fa1
commit
1e6a3ca84b
10 changed files with 61 additions and 16 deletions
|
|
@ -11,7 +11,7 @@ use derive_aliases::derive;
|
|||
|
||||
use bevy::prelude::*;
|
||||
use spacetimedb::SpacetimeType;
|
||||
use strum::FromRepr;
|
||||
use strum::{EnumCount, FromRepr};
|
||||
|
||||
#[derive(..Base, Hash, Default)]
|
||||
#[derive(States, SpacetimeType)]
|
||||
|
|
@ -112,3 +112,24 @@ pub fn tiles() -> Vec<Tile> {
|
|||
}
|
||||
tiles
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Default,
|
||||
..Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Hash,
|
||||
Debug,
|
||||
)]
|
||||
#[derive(SubStates, FromRepr, EnumCount, SpacetimeType)]
|
||||
#[source(GameState = GameState::Play)]
|
||||
pub enum TurnState {
|
||||
#[default]
|
||||
None,
|
||||
Tsumo,
|
||||
Menzen,
|
||||
RiichiKan,
|
||||
Discard,
|
||||
RonChiiPonKan,
|
||||
End,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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`.
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
28
jong/src/stdb/turn_state_type.rs
Normal file
28
jong/src/stdb/turn_state_type.rs
Normal 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;
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ pub fn join_or_create_lobby(ctx: &ReducerContext, mut lobby_id: u32) -> Result<(
|
|||
host_player_id: player.id,
|
||||
players: vec![PlayerOrBot::Player { id: player.id }],
|
||||
game_state: GameState::Setup,
|
||||
turn_state: TurnState::None,
|
||||
});
|
||||
info!("created lobby: {:?}", lobby);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) {
|
|||
lobby.game_state = GameState::Deal;
|
||||
let mut lobby = ctx.db.lobby().id().update(lobby);
|
||||
|
||||
|
||||
let tiles = new_shuffled_wall(ctx);
|
||||
ctx.db.wall().insert(Wall {
|
||||
// id: 0,
|
||||
|
|
@ -24,6 +23,7 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) {
|
|||
deal_hands(ctx, lobby_id);
|
||||
|
||||
lobby.game_state = GameState::Play;
|
||||
lobby.turn_state = TurnState::Tsumo;
|
||||
ctx.db.lobby().id().update(lobby);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ pub struct Lobby {
|
|||
pub players: Vec<PlayerOrBot>,
|
||||
|
||||
pub game_state: GameState,
|
||||
pub turn_state: TurnState,
|
||||
}
|
||||
|
||||
#[table(name = wall)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue