Complete the hand of a player who has joined after the start of the game

This commit is contained in:
2023-03-25 12:58:58 +01:00
parent 0288254f75
commit 12f39ef275

View File

@@ -58,6 +58,7 @@ impl Room {
}
}
let mut is_new_player = false;
if let Some(i) = player_index {
// Reclaim the player's spot
self.broadcast(ServerMessage::PlayerReconnected(i));
@@ -65,6 +66,7 @@ impl Room {
} else {
self.broadcast(ServerMessage::PlayerConnected(player_name.clone()));
player_index = Some(self.players.len());
is_new_player = true;
self.players.push(Player {
name: player_name,
@@ -90,6 +92,14 @@ impl Room {
has_started: self.has_started,
})?;
if self.has_started && is_new_player {
self.players[player_index]
.hand
.complete(&mut self.deck)
.ok();
self.sync_hand(player_index);
}
Ok(())
}