diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-12-22 16:46:30 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-12-22 16:46:30 -0500 |
commit | a60500b47c81d15c9b970b58b1c871821dbe934a (patch) | |
tree | 684caa791cb737c42ff981c7e9c0f26484e6bacb /server/src/main.rs | |
parent | f06fb735448926bdcc0e6448644895b4c83a4d1f (diff) |
Implement proper logging commands
Diffstat (limited to 'server/src/main.rs')
-rw-r--r-- | server/src/main.rs | 30 |
1 files changed, 4 insertions, 26 deletions
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" ))); |