extract player tables

This commit is contained in:
Tao Tien 2026-02-11 10:14:02 -08:00
parent 7cef787f38
commit 71ad4cada6
5 changed files with 49 additions and 44 deletions

View file

@ -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>,
}