summaryrefslogtreecommitdiff
path: root/server/src/play.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/play.rs')
-rw-r--r--server/src/play.rs40
1 files changed, 9 insertions, 31 deletions
diff --git a/server/src/play.rs b/server/src/play.rs
index ffb7407..e0d4733 100644
--- a/server/src/play.rs
+++ b/server/src/play.rs
@@ -3,10 +3,9 @@ use protocol::{
bot::{BiddingBot, PlayingBot},
bridge_engine::{
Bid, BiddingStatePlayerView, Deal, GameResult, GameState,
- PlayStatePlayerView, Player,
+ PlayStatePlayerView, Player, TableState,
},
card::Card,
- play_result::MoveResult,
simple_bots::{AlwaysPassBiddingBot, RandomPlayingBot},
};
use rand::random;
@@ -125,35 +124,7 @@ where
{
journal: J,
settings: TableSettings,
- state: TableState,
-}
-
-#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
-pub enum TableState {
- Unknown,
- Game(GameState),
- Result(GameResult),
-}
-
-impl Default for TableState {
- fn default() -> Self {
- TableState::Unknown
- }
-}
-
-impl Into<TableState> for MoveResult<GameState, GameResult> {
- fn into(self) -> TableState {
- match self {
- MoveResult::Stay(game) => TableState::Game(game),
- MoveResult::Go(result) => TableState::Result(result),
- }
- }
-}
-
-impl Into<TableState> for GameState {
- fn into(self) -> TableState {
- TableState::Game(self)
- }
+ pub state: TableState,
}
impl<J: Journal<TableUpdate>> Table<J> {
@@ -167,6 +138,13 @@ impl<J: Journal<TableUpdate>> Table<J> {
Ok(table)
}
+ pub fn game_in_progress(&self) -> bool {
+ match &self.state {
+ TableState::Game(_) => true,
+ _ => false,
+ }
+ }
+
pub fn game(&self) -> Result<&GameState, BridgeError> {
match &self.state {
TableState::Game(g) => Ok(g),