Esempio n. 1
0
        /// <summary>
        /// Start chat between 2 bots
        /// </summary>
        public void StartChat()
        {
            Start = DateTime.Now;
            CurrentGameHistory.Entries.Add(new GameHistoryEntry(SecondUser, "Hi"));
            string answer = First.Answer("Hi", Second);

            CurrentGameHistory.Entries.Add(new GameHistoryEntry(FirstUser, answer));


            while ((DateTime.Now - Start) < Game.Duration)
            {
                try
                {
                    answer = Second.Answer(answer, First);
                    CurrentGameHistory.Entries.Add(new GameHistoryEntry(SecondUser, answer));

                    answer = First.Answer(answer, Second);
                    CurrentGameHistory.Entries.Add(new GameHistoryEntry(FirstUser, answer));
                }
                catch (Exception ex)
                {
                    Platform.LogEvent("A bot caused error: " + ex.Message, ConsoleColor.Red);
                }
                Thread.Sleep(Game.PlayerSleepTime);
            }

            First.IsInGame  = false;
            Second.IsInGame = false;
            Platform.LogEvent("Game " + Game.Id.ToString() + " Started ", ConsoleColor.DarkCyan);
        }