diff --git a/Client/Client.cs b/Client/Client.cs index d2b5cff..1b8a4ef 100644 --- a/Client/Client.cs +++ b/Client/Client.cs @@ -226,13 +226,18 @@ namespace Client case JSONConvert.GameCommand.INITIALIZE: int lobbyID = JSONConvert.GetLobbyID(payload); string userName = JSONConvert.GetUsernameLogin(payload); - if (lobbyID == clientData.Lobby.ID) + if (lobbyID == clientData.Lobby.ID) + { if (userName == clientData.User.Username) { clientData.User.TurnToDraw = true; Debug.WriteLine("[CLIENT] Setting a player's turnToDraw to true"); - } - + } + clientData.Client.UpdateUserScores?.Invoke(clientData.Lobby); + + } + + break; } diff --git a/Client/ViewModels/ViewModel.cs b/Client/ViewModels/ViewModel.cs index 40a550f..349c814 100644 --- a/Client/ViewModels/ViewModel.cs +++ b/Client/ViewModels/ViewModel.cs @@ -121,13 +121,18 @@ namespace Client _lobbies.Clear(); + Lobby clientLobby = ClientData.Instance.Lobby; foreach (Lobby l in lobbiesArr) { _lobbies.Add(l); - Lobby clientLobby = ClientData.Instance.Lobby; if (l.ID == clientLobby?.ID) { - clientLobby = l; + clientLobby.Users.Clear(); + + foreach (User user in l.Users) + { + clientLobby.Users.Add(user); + } } } diff --git a/Client/ViewModels/ViewModelGame.cs b/Client/ViewModels/ViewModelGame.cs index a33e7ba..7e99cfb 100644 --- a/Client/ViewModels/ViewModelGame.cs +++ b/Client/ViewModels/ViewModelGame.cs @@ -122,7 +122,7 @@ namespace Client.ViewModels public void Canvas_MouseDown(MouseButtonEventArgs e, GameWindow window) { - if (e.ButtonState == MouseButtonState.Pressed && data.User.TurnToDraw) + if (e.ButtonState == MouseButtonState.Pressed) { currentPoint = e.GetPosition(window.CanvasForPaint); } @@ -130,7 +130,7 @@ namespace Client.ViewModels public void Canvas_MouseMove(MouseEventArgs e, GameWindow window) { - if (e.LeftButton == MouseButtonState.Pressed && data.User.TurnToDraw) + if (e.LeftButton == MouseButtonState.Pressed) { double[] coordinates = new double[4]; Line line = new Line(); @@ -167,7 +167,7 @@ namespace Client.ViewModels public void Canvas_MouseUp(object sender, MouseButtonEventArgs e) { - if (data.User.TurnToDraw) + sendArrayFromQueue(sender, null); } @@ -263,7 +263,7 @@ namespace Client.ViewModels Players.Clear(); foreach (var item in lobby.Users) { - Players.Add(item.Username + "\n" + item.Score); + Players.Add(item.Username + "\n" + item.Score + "\n" + item.TurnToDraw); } }); } diff --git a/Client/Views/GameWindow.xaml b/Client/Views/GameWindow.xaml index 02968ed..6834904 100644 --- a/Client/Views/GameWindow.xaml +++ b/Client/Views/GameWindow.xaml @@ -35,12 +35,12 @@