various smol changes

This commit is contained in:
Tao Tien 2026-03-02 20:27:56 -08:00
parent bf23dbaf80
commit 0713d6869b
13 changed files with 108 additions and 93 deletions

View file

@ -121,7 +121,7 @@ pub fn advance_game_private(ctx: &ReducerContext, mut game_timer: GameTimer) ->
let mut hand = ctx.db.player_hand().player_id().find(player_id).unwrap();
match hand.turn_state {
TurnState::None => {
trace!("draw a tile");
// trace!("draw a tile");
if let Some(mut wall) = ctx.db.wall().lobby_id().find(lobby.id)
&& let Some(tile) = wall.tiles.pop()
{

View file

@ -68,7 +68,7 @@ pub fn add_bot(ctx: &ReducerContext, lobby_id: u32) -> Result<(), String> {
info!("added bot {} to lobby {}", bot.id, lobby_id);
Ok(())
} else {
Err("lobby doesn't exist".into())
Err(format!("lobby {lobby_id} doesn't exist or is full"))
}
}

View file

@ -129,11 +129,12 @@ fn view_hand(ctx: &ViewContext) -> Option<PlayerHand> {
.and_then(|p| ctx.db.player_hand().player_id().find(p.id))
}
#[derive(SpacetimeType, Clone, Copy)]
#[derive(SpacetimeType, Clone)]
pub struct HandView {
pub player: PlayerOrBot,
pub hand_length: u8,
// pub melds: u8,
pub pond: Vec<DbTile>,
pub drawn: bool,
}
@ -151,6 +152,7 @@ fn view_closed_hands(ctx: &ViewContext) -> Vec<HandView> {
Some(HandView {
player,
hand_length: player_hand.hand.len() as u8,
pond: player_hand.pond,
drawn: player_hand.turn_state == TurnState::Tsumo
&& player_hand.working_tile.is_some(),
})
@ -163,6 +165,7 @@ fn view_closed_hands(ctx: &ViewContext) -> Vec<HandView> {
Some(HandView {
player,
hand_length: bot.hand.len() as u8,
pond: bot.pond,
drawn: bot.turn_state == TurnState::Tsumo && bot.working_tile.is_some(),
})
} else {