From 9beeaf6a0efd36e1ba0442b4bbe81caf813d181f Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Mon, 8 Feb 2016 20:35:43 +0100 Subject: [PATCH] trivia fix --- NadekoBot/Classes/Trivia/TriviaQuestionPool.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/NadekoBot/Classes/Trivia/TriviaQuestionPool.cs b/NadekoBot/Classes/Trivia/TriviaQuestionPool.cs index 4bb59f23..84670f15 100644 --- a/NadekoBot/Classes/Trivia/TriviaQuestionPool.cs +++ b/NadekoBot/Classes/Trivia/TriviaQuestionPool.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; +using NadekoBot.Extensions; namespace NadekoBot.Classes.Trivia { public class TriviaQuestionPool { @@ -19,8 +20,8 @@ namespace NadekoBot.Classes.Trivia { Reload(); } - public TriviaQuestion GetRandomQuestion(List exclude) => - pool.Except(exclude).OrderBy(x => _r.Next()).FirstOrDefault(); + public TriviaQuestion GetRandomQuestion(List exclude) => + pool.Except(exclude).FirstOrDefault(); internal void Reload() { JArray arr = JArray.Parse(File.ReadAllText("data/questions.txt")); @@ -28,9 +29,10 @@ namespace NadekoBot.Classes.Trivia { foreach (var item in arr) { TriviaQuestion tq; tq = new TriviaQuestion(item["Question"].ToString(), item["Answer"].ToString(),item["Category"]?.ToString()); - pool.Add(tq); } + var r = new Random(); + pool = pool.OrderBy(x => r.Next()).ToList(); } } }