extract player tables
This commit is contained in:
parent
7cef787f38
commit
71ad4cada6
5 changed files with 49 additions and 44 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use log::{info, trace};
|
||||
use spacetimedb::{ReducerContext, Table, reducer};
|
||||
|
||||
use crate::tables::*;
|
||||
use crate::tables::{player::player, *};
|
||||
use jong_types::*;
|
||||
|
||||
mod hand;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use spacetimedb::{ReducerContext, Table, ViewContext, reducer, view};
|
||||
|
||||
use crate::tables::*;
|
||||
use crate::tables::{player::player, *};
|
||||
use jong_types::*;
|
||||
|
||||
pub fn deal_hands(ctx: &ReducerContext, lobby_id: u32) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use log::info;
|
||||
use spacetimedb::{ReducerContext, Table, reducer};
|
||||
|
||||
use crate::tables::*;
|
||||
use crate::tables::{player::player, *};
|
||||
|
||||
mod game;
|
||||
mod tables;
|
||||
|
|
|
|||
|
|
@ -1,44 +1,9 @@
|
|||
use spacetimedb::{Filter, Identity, SpacetimeType, client_visibility_filter, table};
|
||||
use spacetimedb::{Filter, SpacetimeType, client_visibility_filter, table};
|
||||
|
||||
use jong_types::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[table(name = player, public)]
|
||||
pub struct Player {
|
||||
#[primary_key]
|
||||
pub identity: Identity,
|
||||
|
||||
#[unique]
|
||||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
pub name: Option<String>,
|
||||
|
||||
#[index(btree)]
|
||||
pub lobby_id: u32,
|
||||
pub hand_id: u32,
|
||||
pub pond_id: u32,
|
||||
|
||||
pub ready: bool,
|
||||
}
|
||||
|
||||
#[table(name = bot)]
|
||||
pub struct Bot {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
#[index(btree)]
|
||||
pub lobby_id: u32,
|
||||
pub hand_id: u32,
|
||||
pub pond_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, SpacetimeType)]
|
||||
pub enum PlayerOrBot {
|
||||
Player { id: u32 },
|
||||
Bot { id: u32 },
|
||||
}
|
||||
pub mod player;
|
||||
pub use player::*;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[table(name = lobby, public)]
|
||||
|
|
@ -49,7 +14,7 @@ pub struct Lobby {
|
|||
|
||||
#[unique]
|
||||
pub host_player_id: u32,
|
||||
pub players: Vec<PlayerOrBot>,
|
||||
pub players: Vec<player::PlayerOrBot>,
|
||||
|
||||
pub game_state: GameState,
|
||||
pub turn_state: TurnState,
|
||||
|
|
@ -77,7 +42,7 @@ pub struct Hand {
|
|||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
pub owner: PlayerOrBot,
|
||||
pub owner: player::PlayerOrBot,
|
||||
|
||||
pub sort: bool,
|
||||
pub tiles: Vec<Tile>,
|
||||
|
|
@ -89,7 +54,7 @@ pub struct Pond {
|
|||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
pub owner: PlayerOrBot,
|
||||
pub owner: player::PlayerOrBot,
|
||||
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
|
|
|||
40
spacetimedb/src/tables/player.rs
Normal file
40
spacetimedb/src/tables/player.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use spacetimedb::Identity;
|
||||
use spacetimedb::{SpacetimeType, table};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[table(name = player, public)]
|
||||
pub struct Player {
|
||||
#[primary_key]
|
||||
pub identity: Identity,
|
||||
|
||||
#[unique]
|
||||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
pub name: Option<String>,
|
||||
|
||||
#[index(btree)]
|
||||
pub lobby_id: u32,
|
||||
pub hand_id: u32,
|
||||
pub pond_id: u32,
|
||||
|
||||
pub ready: bool,
|
||||
}
|
||||
|
||||
#[table(name = bot)]
|
||||
pub struct Bot {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
#[index(btree)]
|
||||
pub lobby_id: u32,
|
||||
pub hand_id: u32,
|
||||
pub pond_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, SpacetimeType)]
|
||||
pub enum PlayerOrBot {
|
||||
Player { id: u32 },
|
||||
Bot { id: u32 },
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue