This commit is contained in:
Tao Tien 2026-02-22 00:39:51 -08:00
parent d7b4221727
commit 2d3993452b
33 changed files with 920 additions and 143 deletions

View file

@ -1,6 +1,4 @@
use std::time::Instant;
use spacetimedb::{SpacetimeType, table};
use spacetimedb::{SpacetimeType, ViewContext, table, view};
use jong_types::{
states::{GameState, TurnState},
@ -47,7 +45,6 @@ pub enum PlayerOrBot {
Bot { id: u32 },
}
// FIXME this shant be public, use views
#[table(name = player, public)]
#[table(name = logged_out_player)]
#[derive(Debug)]
@ -98,7 +95,7 @@ pub struct PlayerHand {
pub working_tile: Option<DbTile>,
}
#[table(name = bot)]
#[table(name = bot, public)]
pub struct Bot {
#[primary_key]
#[auto_inc]
@ -126,3 +123,12 @@ pub struct GameTimer {
pub scheduled_at: spacetimedb::ScheduleAt,
}
#[view(name = view_hand, public)]
fn view_hand(ctx: &ViewContext) -> Option<PlayerHand> {
ctx.db
.player()
.identity()
.find(ctx.sender)
.and_then(|p| ctx.db.player_hand().player_id().find(p.id))
}