use spacetimedb::{Identity, SpacetimeType, 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, #[index(btree)] pub lobby_id: u32, pub hand_id: u32, pub pond_id: u32, } #[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 }, } #[derive(Debug, Clone)] #[table(name = lobby, public)] pub struct Lobby { #[primary_key] #[auto_inc] pub id: u32, #[unique] pub host_player_id: u32, pub players: Vec, pub game_state: GameState, } #[table(name = wall)] pub struct Wall { #[primary_key] pub lobby_id: u32, pub tiles: Vec, } #[table(name = hand)] pub struct Hand { #[primary_key] #[auto_inc] pub id: u32, pub owner: PlayerOrBot, pub sort: bool, pub tiles: Vec, } #[table(name = pond, public)] pub struct Pond { #[primary_key] #[auto_inc] pub id: u32, pub owner: PlayerOrBot, pub tiles: Vec, }