Exemplo n.º 1
0
 public async Task SendAnswer(int message)
 {
     if (CurrentGame.IsCorrect(message) && !CurrentGame.currentEquation.hasWinner)
     {
         CurrentGame.currentEquation.hasWinner = true;
         CountdownToNewGame();
     }
     else if (CurrentGame.currentEquation.hasWinner)
     {
         await Clients.Caller.SendAsync("ReceiveMessage", "MSG", "Game already finished!");
     }
     else
     {
         await Clients.Caller.SendAsync("ReceiveMessage", "MSG", "Wrong, try again.");
     }
 }
Exemplo n.º 2
0
        private async void CountdownToNewGame()
        {
            await Clients.All.SendAsync("ReceiveMessage", "GAME_RESTARTING", "WE HAVE A WINNER, CORRECT ANSWER WAS: " + CurrentGame.currentEquation.GetResult());

            int seconds = 5;

            for (; seconds >= 0; seconds--)
            {
                await Clients.All.SendAsync("ReceiveMessage", "GAME", "SERVER: " + seconds);

                Thread.Sleep(1000);
            }
            CurrentGame.StartNewGame();

            await Clients.All.SendAsync("Equation", CurrentGame.GetCurrentEquation());
        }
Exemplo n.º 3
0
 public async Task GetCurrentGame()
 {
     await Clients.Caller.SendAsync("Equation", CurrentGame.GetCurrentEquation());
 }