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

@ -9,15 +9,12 @@ pub fn shuffle_deal(ctx: &ReducerContext, lobby_id: u32) {
if lobby.game_state == jong_types::states::GameState::Deal {
let tiles = new_shuffled_wall(ctx);
ctx.db.wall().insert(DbWall {
// id: 0,
lobby_id,
tiles,
});
deal_hands(ctx, lobby_id);
lobby.game_state = jong_types::states::GameState::Play;
ctx.db.lobby().id().update(lobby);
}

View file

@ -15,6 +15,8 @@ pub fn join_or_create_lobby(ctx: &ReducerContext, mut lobby_id: u32) -> Result<(
.ok_or(format!("cannot find player {}", ctx.sender))?;
if lobby_id == 0 {
// TODO check first if player is already in a lobby
let lobby = ctx.db.lobby().insert(Lobby {
id: 0,
players: vec![PlayerOrBot::Player { id: player.id }],