diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-12-18 11:41:04 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-12-18 11:41:04 -0500 |
commit | b5940c3ae2b6e23a6373383d5d78958fb23cb611 (patch) | |
tree | b96514acaea7a5624f8a04194cae7d784f8fe43a /server | |
parent | cebd93586f32fb47cea2f86b9c87f9daea3da9b0 (diff) |
Add Table::bid()
Diffstat (limited to 'server')
-rw-r--r-- | server/src/error.rs | 3 | ||||
-rw-r--r-- | server/src/play.rs | 7 |
2 files changed, 10 insertions, 0 deletions
diff --git a/server/src/error.rs b/server/src/error.rs index 344624c..a636ceb 100644 --- a/server/src/error.rs +++ b/server/src/error.rs @@ -35,6 +35,9 @@ pub enum BridgeError { #[error("User is not logged in")] NotLoggedIn, + #[error("Anyhow error")] + AnyhowError(#[from]anyhow::Error), + #[error("Authentication error")] SigningFailed(#[from] openidconnect::SigningError), diff --git a/server/src/play.rs b/server/src/play.rs index 9ea2f42..17d5819 100644 --- a/server/src/play.rs +++ b/server/src/play.rs @@ -114,6 +114,13 @@ impl<J: Journal> Table<J> { Ok(game) } + async fn bid(&mut self, bid: Bid) -> Result<(), BridgeError> { + let game = self.game.clone().bid(bid)?; + self.journal.append(self.journal.next(), json!(game)).await?; + self.game = game; + Ok(()) + } + pub async fn replay(mut journal: J) -> Result<Self, BridgeError> { let games = journal.replay(0).await?; if games.is_empty() { |