trivia fix
This commit is contained in:
parent
1f56c7c2f9
commit
9beeaf6a0e
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NadekoBot.Extensions;
|
||||||
|
|
||||||
namespace NadekoBot.Classes.Trivia {
|
namespace NadekoBot.Classes.Trivia {
|
||||||
public class TriviaQuestionPool {
|
public class TriviaQuestionPool {
|
||||||
@ -20,7 +21,7 @@ namespace NadekoBot.Classes.Trivia {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TriviaQuestion GetRandomQuestion(List<TriviaQuestion> exclude) =>
|
public TriviaQuestion GetRandomQuestion(List<TriviaQuestion> exclude) =>
|
||||||
pool.Except(exclude).OrderBy(x => _r.Next()).FirstOrDefault();
|
pool.Except(exclude).FirstOrDefault();
|
||||||
|
|
||||||
internal void Reload() {
|
internal void Reload() {
|
||||||
JArray arr = JArray.Parse(File.ReadAllText("data/questions.txt"));
|
JArray arr = JArray.Parse(File.ReadAllText("data/questions.txt"));
|
||||||
@ -28,9 +29,10 @@ namespace NadekoBot.Classes.Trivia {
|
|||||||
foreach (var item in arr) {
|
foreach (var item in arr) {
|
||||||
TriviaQuestion tq;
|
TriviaQuestion tq;
|
||||||
tq = new TriviaQuestion(item["Question"].ToString(), item["Answer"].ToString(),item["Category"]?.ToString());
|
tq = new TriviaQuestion(item["Question"].ToString(), item["Answer"].ToString(),item["Category"]?.ToString());
|
||||||
|
|
||||||
pool.Add(tq);
|
pool.Add(tq);
|
||||||
}
|
}
|
||||||
|
var r = new Random();
|
||||||
|
pool = pool.OrderBy(x => r.Next()).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user