Complete the hand of a player who has joined after the start of the game
This commit is contained in:
@@ -58,6 +58,7 @@ impl Room {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut is_new_player = false;
|
||||||
if let Some(i) = player_index {
|
if let Some(i) = player_index {
|
||||||
// Reclaim the player's spot
|
// Reclaim the player's spot
|
||||||
self.broadcast(ServerMessage::PlayerReconnected(i));
|
self.broadcast(ServerMessage::PlayerReconnected(i));
|
||||||
@@ -65,6 +66,7 @@ impl Room {
|
|||||||
} else {
|
} else {
|
||||||
self.broadcast(ServerMessage::PlayerConnected(player_name.clone()));
|
self.broadcast(ServerMessage::PlayerConnected(player_name.clone()));
|
||||||
player_index = Some(self.players.len());
|
player_index = Some(self.players.len());
|
||||||
|
is_new_player = true;
|
||||||
|
|
||||||
self.players.push(Player {
|
self.players.push(Player {
|
||||||
name: player_name,
|
name: player_name,
|
||||||
@@ -90,6 +92,14 @@ impl Room {
|
|||||||
has_started: self.has_started,
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user