all clients trigger ready, then advance gamestate on last ready

This commit is contained in:
Tao Tien 2026-02-10 19:38:41 -08:00
parent 1e6a3ca84b
commit d183f5d993
18 changed files with 358 additions and 77 deletions

View file

@ -10,21 +10,20 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) {
debug!("lobby_id: {lobby_id}");
let mut lobby = ctx.db.lobby().id().find(lobby_id).unwrap();
lobby.game_state = GameState::Deal;
let mut lobby = ctx.db.lobby().id().update(lobby);
if lobby.game_state == GameState::Deal {
let tiles = new_shuffled_wall(ctx);
ctx.db.wall().insert(Wall {
// id: 0,
lobby_id,
tiles,
});
let tiles = new_shuffled_wall(ctx);
ctx.db.wall().insert(Wall {
// id: 0,
lobby_id,
tiles,
});
deal_hands(ctx, lobby_id);
deal_hands(ctx, lobby_id);
lobby.game_state = GameState::Play;
lobby.turn_state = TurnState::Tsumo;
ctx.db.lobby().id().update(lobby);
lobby.game_state = GameState::Play;
lobby.turn_state = TurnState::Tsumo;
ctx.db.lobby().id().update(lobby);
}
}
pub fn new_shuffled_wall(ctx: &ReducerContext) -> Vec<Tile> {