Exemplo n.º 1
0
 public override Task DivideLine(string line)
 {
     Console.WriteLine($"{DateTime.Now} Thread {Thread.CurrentThread.ManagedThreadId} started job.");
     if (line.Contains(" LOGIN: "******" LOGIN MISC: "))
     {
         LoginMisc.Add(line);
     }
     if (line.Contains(" QUIT MISC: "))
     {
         QuitMisc.Add(line);
     }
     if (line.Contains("TC: [Civilian Workers]"))
     {
         Team.Add(line);
     }
     if (line.Contains(" Hosted Civilian event; "))
     {
         Events.Add(line);
     }
     if (line.Contains(" created a quiz of '"))
     {
         Quizzes.Add(line);
     }
     Console.WriteLine($"{DateTime.Now} Thread {Thread.CurrentThread.ManagedThreadId} ended job.");
     return(Task.CompletedTask);
 }
Exemplo n.º 2
0
 public void AddQuiz(string categoryName)
 {
     Quizzes.Add(new Quiz
     {
         Id        = Guid.NewGuid(),
         Category  = categoryName,
         Timestamp = DateTime.Now
     });
 }
Exemplo n.º 3
0
        public async Task CreateQuiz(bool priv, string name, string max)
        {
            string trimmedName = name == null ? "" : name.Trim();

            if (Quizzes.FirstOrDefault(quiz => quiz.Name == trimmedName) == null)
            {
                int maxPlayers;
                if (trimmedName == "none")
                {
                    Clients.Caller.message("Can not make room with name of 'none'");
                }
                else if (!int.TryParse(max, out maxPlayers))
                {
                    Clients.Caller.message("Room creation failed: max must be an integer");
                }
                else if (maxPlayers < 2)
                {
                    Clients.Caller.message("Room creation failed: maximum players must be greater than 1");
                }
                else
                {
                    var player = GetCurrentPlayer();

                    if (trimmedName == "")
                    {
                        trimmedName = player.Name + "'s room";
                    }
                    else if (trimmedName.Length > 35)
                    {
                        trimmedName = trimmedName.Substring(0, 35);
                    }

                    if (IsInRoom())
                    {
                        LeaveQuiz();
                    }

                    if (maxPlayers > 20)
                    {
                        maxPlayers = 20;
                    }

                    await Groups.Add(Context.ConnectionId, trimmedName);

                    Quizzes.Add(new Quiz(priv, trimmedName, maxPlayers, player));
                    Clients.Caller.message("Room '" + trimmedName + "' created");
                    Clients.Caller.inRoom(true, trimmedName, maxPlayers);
                    PlayersInLobby(GetCurrentQuiz());
                }
            }
            else
            {
                Clients.Caller.message("Room already exists");
            }
        }
Exemplo n.º 4
0
        public Repository()
        {
            // Questions
            Question q1 = new Question("Which American rapper is also known as Drizzy?");

            q1.AddOption(new Option("Drake", true, 11));
            q1.AddOption(new Option("D12", false, 12));
            q1.AddOption(new Option("Dizzee Rascal", false, 13));
            q1.AddOption(new Option("Dr. Dre", false, 14));
            Questions.Add(q1);

            Question q2 = new Question("Who released the song 'BUTTERFLY EFFECT' in 2018?");

            q2.AddOption(new Option("Travis Scott", true, 21));
            q2.AddOption(new Option("Tyler, The Creator", false, 22));
            q2.AddOption(new Option("Eminem", false, 23));
            q2.AddOption(new Option("50 Cent", false, 24));
            Questions.Add(q2);

            Question q3 = new Question("What League of Legends team does the midlaner 'Caps' play for?");

            q3.AddOption(new Option("Fnatic", false, 31));
            q3.AddOption(new Option("G2", true, 32));
            q3.AddOption(new Option("TSM", false, 33));
            q3.AddOption(new Option("Splyce", false, 34));
            Questions.Add(q3);

            Question q4 = new Question("What lane in League of Legends, do you usually send 2 players to?");

            q4.AddOption(new Option("Top lane", false, 41));
            q4.AddOption(new Option("Middle lane", false, 42));
            q4.AddOption(new Option("Jungle", false, 43));
            q4.AddOption(new Option("Bottom lane", true, 44));
            Questions.Add(q4);

            // Quizzes
            Quiz quiz1 = new Quiz("Music Quiz", "Questions about HipHop and Rap music", 1);

            quiz1.AddQuestion(q1);
            quiz1.AddQuestion(q2);
            Quizzes.Add(quiz1);

            Quiz quiz2 = new Quiz("Esports Quiz", "Questions about esports", 2);

            quiz2.AddQuestion(q3);
            quiz2.AddQuestion(q4);
            Quizzes.Add(quiz2);
        }
Exemplo n.º 5
0
        public async Task GetQuizzes()
        {
            if (initialized == true)
            {
                return;
            }
            IsBusy = true;
            IEnumerable <Quiz> quizzes = await quizService.GetQuizzes();

            // очищаем список
            while (Quizzes.Any())
            {
                Quizzes.RemoveAt(Quizzes.Count - 1);
            }

            // добавляем загруженные данные
            foreach (Quiz f in quizzes)
            {
                Quizzes.Add(f);
            }
            IsBusy      = false;
            initialized = true;
        }
Exemplo n.º 6
0
 public async Task <IActionResult> Add([FromBody] QuizFormModel model)
 {
     return(Ok(await Quizzes.Add(model)));
 }