add a tile table

This commit is contained in:
Tao Tien 2026-02-12 17:06:28 -08:00
parent 9b01f6b96a
commit a1c72b2c48
14 changed files with 232 additions and 42 deletions

View file

@ -15,7 +15,8 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) {
lobby = ctx.db.lobby().id().update(lobby);
let tiles = new_shuffled_wall(ctx);
ctx.db.wall().insert(Wall {
ctx.db.wall().insert(DbWall {
// id: 0,
lobby_id,
tiles,
@ -29,9 +30,12 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) {
}
}
pub fn new_shuffled_wall(ctx: &ReducerContext) -> Vec<Tile> {
pub fn new_shuffled_wall(ctx: &ReducerContext) -> Vec<DbTile> {
let mut rng = ctx.rng();
let mut wall = tiles();
let mut wall: Vec<_> = tiles()
.into_iter()
.map(|tile| ctx.db.tile().insert(DbTile { id: 0, tile }))
.collect();
wall.shuffle(&mut rng);
wall