trivia questions and pokemon data will be stored in redis, instead of per-shard

This commit is contained in:
Master Kwoth
2017-11-06 10:01:38 +01:00
parent 817fd7ce31
commit e79b3db818
13 changed files with 195 additions and 77 deletions

View File

@ -19,6 +19,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
{
private readonly SemaphoreSlim _guessLock = new SemaphoreSlim(1, 1);
private readonly Logger _log;
private readonly IDataCache _cache;
private readonly NadekoStrings _strings;
private readonly DiscordSocketClient _client;
private readonly IBotConfigProvider _bc;
@ -43,11 +44,15 @@ namespace NadekoBot.Modules.Games.Common.Trivia
public int WinRequirement { get; }
private readonly TriviaQuestionPool _questionPool;
public TriviaGame(NadekoStrings strings, DiscordSocketClient client, IBotConfigProvider bc,
CurrencyService cs, IGuild guild, ITextChannel channel,
IDataCache cache, CurrencyService cs, IGuild guild, ITextChannel channel,
bool showHints, int winReq, bool isPokemon)
{
_log = LogManager.GetCurrentClassLogger();
_cache = cache;
_questionPool = new TriviaQuestionPool(_cache);
_strings = strings;
_client = client;
_bc = bc;
@ -74,7 +79,7 @@ namespace NadekoBot.Modules.Games.Common.Trivia
_triviaCancelSource = new CancellationTokenSource();
// load question
CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(OldQuestions, IsPokemon);
CurrentQuestion = _questionPool.GetRandomQuestion(OldQuestions, IsPokemon);
if (string.IsNullOrWhiteSpace(CurrentQuestion?.Answer) || string.IsNullOrWhiteSpace(CurrentQuestion.Question))
{
await Channel.SendErrorAsync(GetText("trivia_game"), GetText("failed_loading_question")).ConfigureAwait(false);