[REMOVE] removed the checks for who is host
This commit is contained in:
@@ -226,13 +226,18 @@ namespace Client
|
|||||||
case JSONConvert.GameCommand.INITIALIZE:
|
case JSONConvert.GameCommand.INITIALIZE:
|
||||||
int lobbyID = JSONConvert.GetLobbyID(payload);
|
int lobbyID = JSONConvert.GetLobbyID(payload);
|
||||||
string userName = JSONConvert.GetUsernameLogin(payload);
|
string userName = JSONConvert.GetUsernameLogin(payload);
|
||||||
if (lobbyID == clientData.Lobby.ID)
|
if (lobbyID == clientData.Lobby.ID)
|
||||||
|
{
|
||||||
if (userName == clientData.User.Username)
|
if (userName == clientData.User.Username)
|
||||||
{
|
{
|
||||||
clientData.User.TurnToDraw = true;
|
clientData.User.TurnToDraw = true;
|
||||||
Debug.WriteLine("[CLIENT] Setting a player's turnToDraw to true");
|
Debug.WriteLine("[CLIENT] Setting a player's turnToDraw to true");
|
||||||
}
|
}
|
||||||
|
clientData.Client.UpdateUserScores?.Invoke(clientData.Lobby);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,13 +121,18 @@ namespace Client
|
|||||||
|
|
||||||
_lobbies.Clear();
|
_lobbies.Clear();
|
||||||
|
|
||||||
|
Lobby clientLobby = ClientData.Instance.Lobby;
|
||||||
foreach (Lobby l in lobbiesArr)
|
foreach (Lobby l in lobbiesArr)
|
||||||
{
|
{
|
||||||
_lobbies.Add(l);
|
_lobbies.Add(l);
|
||||||
Lobby clientLobby = ClientData.Instance.Lobby;
|
|
||||||
if (l.ID == clientLobby?.ID)
|
if (l.ID == clientLobby?.ID)
|
||||||
{
|
{
|
||||||
clientLobby = l;
|
clientLobby.Users.Clear();
|
||||||
|
|
||||||
|
foreach (User user in l.Users)
|
||||||
|
{
|
||||||
|
clientLobby.Users.Add(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ namespace Client.ViewModels
|
|||||||
|
|
||||||
public void Canvas_MouseDown(MouseButtonEventArgs e, GameWindow window)
|
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);
|
currentPoint = e.GetPosition(window.CanvasForPaint);
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ namespace Client.ViewModels
|
|||||||
|
|
||||||
public void Canvas_MouseMove(MouseEventArgs e, GameWindow window)
|
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];
|
double[] coordinates = new double[4];
|
||||||
Line line = new Line();
|
Line line = new Line();
|
||||||
@@ -167,7 +167,7 @@ namespace Client.ViewModels
|
|||||||
|
|
||||||
public void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
|
public void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (data.User.TurnToDraw)
|
|
||||||
sendArrayFromQueue(sender, null);
|
sendArrayFromQueue(sender, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ namespace Client.ViewModels
|
|||||||
Players.Clear();
|
Players.Clear();
|
||||||
foreach (var item in lobby.Users)
|
foreach (var item in lobby.Users)
|
||||||
{
|
{
|
||||||
Players.Add(item.Username + "\n" + item.Score);
|
Players.Add(item.Username + "\n" + item.Score + "\n" + item.TurnToDraw);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,12 +35,12 @@
|
|||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" FontSize="20" Content="Pick a color -->"/>
|
<Label Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" FontSize="20" Content="Pick a color -->"/>
|
||||||
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="22" Width="100" IsEnabled="{Binding UserTurnToDraw}"/>
|
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center" Height="22" Width="100" />
|
||||||
|
|
||||||
|
|
||||||
<Label Name="GuessWord" Grid.Row="0" Grid.Column="2" Content="{Binding Path=RandomWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20"/>
|
<Label Name="GuessWord" Grid.Row="0" Grid.Column="2" Content="{Binding Path=RandomWord, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20"/>
|
||||||
|
|
||||||
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="3" Content="RESET" IsEnabled="{Binding UserTurnToDraw}"/>
|
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="3" Content="RESET"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Button Name="StartGame" Grid.Row="0" Grid.Column="2" Content="Start Game" FontSize="20" Command="{Binding ButtonStartGame}" IsEnabled="{Binding IsHost}"/>
|
<Button Name="StartGame" Grid.Row="0" Grid.Column="2" Content="Start Game" FontSize="20" Command="{Binding ButtonStartGame}" IsEnabled="{Binding IsHost}"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user