diff --git a/Client/Client.cs b/Client/Client.cs
index 0a1ea72..00357e0 100644
--- a/Client/Client.cs
+++ b/Client/Client.cs
@@ -12,6 +12,7 @@ namespace Client
{
public delegate void LobbyCallback(int id);
public delegate void LobbyJoinCallback(bool isHost);
+ public delegate void RandomWord(string word);
class Client : ObservableObject
{
private TcpClient tcpClient;
@@ -30,6 +31,7 @@ namespace Client
public Callback OnClientJoinLobby;
public LobbyCallback OnLobbyCreated;
public LobbyCallback OnLobbyLeave;
+ public RandomWord RandomWord;
private ClientData data = ClientData.Instance;
public Lobby[] Lobbies { get; set; }
@@ -182,7 +184,8 @@ namespace Client
string randomWord = JSONConvert.GetRandomWord(payload);
if (data.Lobby?.ID == lobbyId)
- ViewModels.ViewModelGame.HandleRandomWord(randomWord);
+ RandomWord?.Invoke(randomWord);
+
break;
default:
Debug.WriteLine("[CLIENT] Received weird identifier: " + id);
diff --git a/Client/ViewModels/ViewModelGame.cs b/Client/ViewModels/ViewModelGame.cs
index 67be443..d2848b2 100644
--- a/Client/ViewModels/ViewModelGame.cs
+++ b/Client/ViewModels/ViewModelGame.cs
@@ -29,7 +29,8 @@ namespace Client.ViewModels
private dynamic _payload;
- private static string _randomWord;
+ private string _randomWord;
+
public string RandomWord
{
get { return _randomWord; }
@@ -97,6 +98,7 @@ namespace Client.ViewModels
public ViewModelGame()
{
OnKeyDown = new RelayCommand(ChatBox_KeyDown);
+ data.Client.RandomWord = HandleRandomWord;
}
private void ChatBox_KeyDown()
@@ -144,9 +146,9 @@ namespace Client.ViewModels
* MISC make this a callback
* Handles the random word that has been received from the server.
*/
- public static void HandleRandomWord(string randomWord)
+ public void HandleRandomWord(string randomWord)
{
- _randomWord = randomWord;
+ RandomWord = randomWord;
Debug.WriteLine($"[CLIENT] The random word is: {_randomWord}");
}
diff --git a/Client/Views/GameWindow.xaml b/Client/Views/GameWindow.xaml
index 3fad8dd..1e8832f 100644
--- a/Client/Views/GameWindow.xaml
+++ b/Client/Views/GameWindow.xaml
@@ -29,7 +29,7 @@
-
+