hack for player-lobby and Res<Player> race?
This commit is contained in:
parent
9f6a5b6423
commit
47735931b4
34 changed files with 536 additions and 1340 deletions
84
spacetimedb/src/tables.rs
Normal file
84
spacetimedb/src/tables.rs
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
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<String>,
|
||||
|
||||
#[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<PlayerOrBot>,
|
||||
|
||||
pub game_state: GameState,
|
||||
}
|
||||
|
||||
#[table(name = wall)]
|
||||
pub struct Wall {
|
||||
#[primary_key]
|
||||
pub lobby_id: u32,
|
||||
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
||||
#[table(name = hand)]
|
||||
pub struct Hand {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
pub owner: PlayerOrBot,
|
||||
|
||||
pub sort: bool,
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
|
||||
#[table(name = pond, public)]
|
||||
pub struct Pond {
|
||||
#[primary_key]
|
||||
#[auto_inc]
|
||||
pub id: u32,
|
||||
|
||||
pub owner: PlayerOrBot,
|
||||
|
||||
pub tiles: Vec<Tile>,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue