Пример #1
0
 async Task Responce_Connect4_Play(string Msg, MessageEventArgs e)
 {
     if (Connect4Games.Where(x => !x.Finished).Any(x => x.Players.Any(y => e.User == y)))
     {
         var      Column = int.Parse(e.Message.RawText.Substring(2, 1));
         MainGame MG;
         if ((MG = Connect4.Play(e.User, Column)) != null)
         {
             if (MG.Players[MG._Turn].IsBot)
             {
                 Connect4.Play(MG.Players[MG._Turn], MG.PlayAI());
             }
         }
         else
         {
             (await e.Channel.SendMessage("It's not your turn, " + e.User.Mention)).Timed(40);
             WriteLine("Command Error: It is not the user's turn");
         }
     }
     else
     {
         (await e.Channel.SendMessage(":anger: You are not in a Connect 4 Game")).Timed(40);
         WriteLine("Command Error: User is not in a Connect 4 game");
         return;
     }
 }
Пример #2
0
        public async Task Unload()
        {
            _t.Change(Timeout.Infinite, Timeout.Infinite);
            _cmd.OnMessageNoTrigger -= PotentialFlowerGeneration;

            AcrophobiaGames.ForEach(x => x.Value.Dispose());
            AcrophobiaGames.Clear();
            Connect4Games.ForEach(x => x.Value.Dispose());
            Connect4Games.Clear();
            HangmanGames.ForEach(x => x.Value.Dispose());
            HangmanGames.Clear();
            await Task.WhenAll(RunningTrivias.Select(x => x.Value.StopGame()));

            RunningTrivias.Clear();

            TicTacToeGames.Clear();

            await Task.WhenAll(RunningContests.Select(x => x.Value.Stop()))
            .ConfigureAwait(false);

            RunningContests.Clear();
            NunchiGames.ForEach(x => x.Value.Dispose());
            NunchiGames.Clear();
        }