Send the complete board when joining a room

This commit is contained in:
2023-03-07 11:48:47 +01:00
parent 091aa81e70
commit 60e4713f7f
4 changed files with 100 additions and 20 deletions

View File

@@ -71,6 +71,7 @@ impl Room {
.iter()
.map(|p| (p.name.clone(), p.score, p.ws.is_some()))
.collect(),
board: (&self.board).into(),
active_player: self.active_player,
has_started: self.has_started,
})?;
@@ -103,7 +104,7 @@ impl Room {
ClientMessage::TileUse(pos, tile_idx) => {
if let Some(p) = self.connections.get(&addr) {
if *p == self.active_player {
self.on_tile_use(pos, tile_idx);
self.on_tile_use(pos.into(), tile_idx);
}
}
}
@@ -176,7 +177,7 @@ impl Room {
fn reset_player_moves(&mut self) {
let diff = self.board.difference(&self.validated_board);
for pos in diff {
self.broadcast(ServerMessage::TileRemoved(pos));
self.broadcast(ServerMessage::TileRemoved(pos.into()));
}
self.board = self.validated_board.clone();
}