From a60500b47c81d15c9b970b58b1c871821dbe934a Mon Sep 17 00:00:00 2001 From: Kjetil Orbekk Date: Thu, 22 Dec 2022 16:46:30 -0500 Subject: Implement proper logging commands --- server/src/main.rs | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'server/src/main.rs') diff --git a/server/src/main.rs b/server/src/main.rs index 35019c5..735258f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -153,20 +153,11 @@ async fn get_table_view( let jnl = DbJournal::new(extension.db.clone(), id); let mut table = play::Table::new_or_replay(jnl).await?; info!("Advancing play"); - while table - .game() - .ok_or(BridgeError::InvalidRequest( - "game not in progress".to_string(), - ))? - .current_player() - != player_position - { + while table.game()?.current_player() != player_position { advance_play(&mut table).await?; } let response = Json(GameStatePlayerView::from_game_state( - table.game().ok_or(BridgeError::InvalidRequest( - "game not in progress".to_string(), - ))?, + table.game()?, player_position, )); info!("Response: {response:#?}"); @@ -182,27 +173,14 @@ async fn post_bid( info!("Getting table state for {id:}"); let jnl = DbJournal::new(extension.db.clone(), id); let mut table = play::Table::replay(jnl).await?; - if !table - .game() - .ok_or(BridgeError::InvalidRequest( - "game not in progress".to_string(), - ))? - .is_bidding() - { + if !table.game()?.is_bidding() { return Err(BridgeError::InvalidRequest( "Posting a bid requires that the game is in the bidding phase" .to_string(), )); } let player_position = Player::South; - if table - .game() - .ok_or(BridgeError::InvalidRequest( - "game not in progress".to_string(), - ))? - .current_player() - != player_position - { + if table.game()?.current_player() != player_position { return Err(BridgeError::InvalidRequest(format!( "It is not {player_position:?} to play" ))); -- cgit v1.2.3