(stash) state advancer reducer

This commit is contained in:
Tao Tien 2026-02-20 03:20:29 -08:00
parent 1d9577ba42
commit c12667938e
9 changed files with 252 additions and 83 deletions

View file

@ -1,13 +1,10 @@
use spacetimedb::{SpacetimeType, table};
use jong_types::{
tiles::Tile,
states::{GameState, TurnState},
tiles::Tile,
};
pub mod player;
pub use player::*;
#[derive(Debug, Clone)]
#[table(name = lobby, public)]
pub struct Lobby {
@ -22,7 +19,6 @@ pub struct Lobby {
pub current_idx: u8,
pub game_state: GameState,
pub turn_state: TurnState,
}
#[table(name = wall)]
@ -48,3 +44,55 @@ pub enum PlayerOrBot {
Player { id: u32 },
Bot { id: u32 },
}
#[table(name = advance_state_timer)]
pub struct AdvanceStateTimer {
#[primary_key]
#[auto_inc]
scheduled_id: u64,
scheduled_at: spacetimedb::ScheduleAt,
lobby_id: u32,
}
// FIXME this shant be public, use views
#[table(name = player, public)]
#[derive(Debug)]
pub struct Player {
#[primary_key]
pub identity: spacetimedb::Identity,
#[unique]
#[auto_inc]
pub id: u32,
pub name: Option<String>,
#[index(btree)]
pub lobby_id: u32,
pub ready: bool,
pub turn_state: TurnState,
pub sort: bool,
pub hand: Vec<DbTile>,
pub pond: Vec<DbTile>,
pub drawn_tile: Option<DbTile>,
}
#[table(name = bot)]
pub struct Bot {
#[primary_key]
#[auto_inc]
pub id: u32,
#[index(btree)]
pub lobby_id: u32,
pub hand: Vec<DbTile>,
pub pond: Vec<DbTile>,
pub drawn_tile: Option<DbTile>,
}