diff --git a/server/src/game_handler.rs b/server/src/game_handler.rs index acf33a7..ea5e2ae 100644 --- a/server/src/game_handler.rs +++ b/server/src/game_handler.rs @@ -1,7 +1,9 @@ use crate::user_handler::*; use crate::AppState; use crate::GameHandlerMessage::*; +use crate::SendUserMessage::*; use crate::User; +use crate::UserHandlerMessage::*; use anyhow::{Context, Result}; use lib::*; use rand::prelude::IteratorRandom; @@ -108,6 +110,25 @@ impl GameHandler { .unwrap() .clone(); + if this_game + .read() + .unwrap() + .players + .contains_key(&this_user.read().unwrap().uuid) + { + self.state + .users_tx + .send(DmUserAddr { + addr, + message: SendChatMessage(ChatMessage { + text: "You're already in this game!".to_owned(), + }), + }) + .await + .unwrap(); + return; + } + // Create player this_game.write().unwrap().create_player(this_user);