skip_calls, discard drawn works
This commit is contained in:
parent
8c4132e628
commit
b6e7635122
16 changed files with 222 additions and 59 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use log::{info, trace};
|
||||
use spacetimedb::{ReducerContext, Table, rand::seq::SliceRandom, reducer};
|
||||
|
||||
use crate::tables::{player::player, wall, *};
|
||||
use crate::tables::{player::player, *};
|
||||
use jong_types::*;
|
||||
|
||||
mod deal;
|
||||
|
|
@ -24,7 +24,8 @@ pub fn join_or_create_lobby(ctx: &ReducerContext, mut lobby_id: u32) -> Result<(
|
|||
players: vec![PlayerOrBot::Player { id: player.id }],
|
||||
game_state: GameState::Lobby,
|
||||
turn_state: TurnState::None,
|
||||
// dealt_idx: -1,
|
||||
dealer_idx: 0,
|
||||
current_idx: 0,
|
||||
});
|
||||
info!("created lobby: {:?}", lobby);
|
||||
|
||||
|
|
@ -53,6 +54,7 @@ pub fn add_bot(ctx: &ReducerContext, lobby_id: u32) -> Result<(), String> {
|
|||
lobby_id,
|
||||
hand: vec![],
|
||||
pond: vec![],
|
||||
drawn_tile: None,
|
||||
});
|
||||
lobby.players.push(PlayerOrBot::Bot { id: bot.id });
|
||||
ctx.db.lobby().id().update(lobby);
|
||||
|
|
@ -83,6 +85,10 @@ pub fn start_game(ctx: &ReducerContext) {
|
|||
{
|
||||
lobby.game_state = GameState::Setup;
|
||||
lobby.players.shuffle(&mut ctx.rng());
|
||||
lobby.dealer_idx += 1;
|
||||
if lobby.dealer_idx > 3 {
|
||||
lobby.dealer_idx = 0;
|
||||
}
|
||||
ctx.db.lobby().id().update(lobby);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue