Possibly fixed #375 trivia bug

This commit is contained in:
Kwoth
2022-08-06 17:28:31 +02:00
parent 8c51cf8537
commit 71d6eeb9dd

View File

@@ -57,11 +57,14 @@ public sealed class TriviaGame
// loop until game is stopped
// each iteration is one round
var firstRun = true;
try
{
while (!_isStopped)
{
if (errorCount >= 5)
{
Log.Warning("Trivia errored 5 times and will quit");
await OnEnded(this);
break;
}
@@ -77,7 +80,7 @@ public sealed class TriviaGame
var maybeQuestion = await _questionPool.GetQuestionAsync();
if(!(maybeQuestion is TriviaQuestion question))
if (!(maybeQuestion is TriviaQuestion question))
{
// if question is null (ran out of question, or other bugg ) - stop
break;
@@ -87,7 +90,8 @@ public sealed class TriviaGame
try
{
// clear out all of the past guesses
while (_inputs.Reader.TryRead(out _)) ;
while (_inputs.Reader.TryRead(out _))
;
await OnQuestion(this, question);
}
@@ -169,11 +173,17 @@ public sealed class TriviaGame
}
}
}
}
catch
{
}
finally
{
// make sure game is set as ended
_isStopped = true;
await OnEnded(this);
_ = OnEnded(this);
}
}
public IReadOnlyList<(ulong User, int points)> GetLeaderboard()