aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/events/trivianight/_game.py
diff options
context:
space:
mode:
authorGravatar Shom770 <[email protected]>2022-01-09 18:26:08 -0500
committerGravatar Shom770 <[email protected]>2022-02-09 18:13:37 -0500
commitb68302524628573ee7e20ccd81db6bb60c05061b (patch)
treecf6b87ddf6f417147a7789ef384ae2cc01a490e4 /bot/exts/events/trivianight/_game.py
parentQoL: adding an emoji and the number of people who answered for when the quest... (diff)
fixing .tn next logic
Diffstat (limited to 'bot/exts/events/trivianight/_game.py')
-rw-r--r--bot/exts/events/trivianight/_game.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/bot/exts/events/trivianight/_game.py b/bot/exts/events/trivianight/_game.py
index 9d8b98c1..7f667dcf 100644
--- a/bot/exts/events/trivianight/_game.py
+++ b/bot/exts/events/trivianight/_game.py
@@ -33,6 +33,10 @@ class AlreadyUpdated(RuntimeError):
"""Exception raised when the user has already updated their guess once."""
+class AllQuestionsVisited(RuntimeError):
+ """Exception raised when all of the questions have been visited."""
+
+
class Question:
"""Interface for one question in a trivia night game."""
@@ -142,6 +146,8 @@ class TriviaNightGame:
question = [q for q in self._all_questions if q.number == number][0]
except IndexError:
raise ValueError(f"Question number {number} does not exist.")
+ elif len(self._questions) == 0:
+ raise AllQuestionsVisited("All of the questions have been visited.")
else:
question = self._questions.pop(randrange(len(self._questions)))
@@ -161,7 +167,7 @@ class TriviaNightGame:
self.current_question.stop()
self.current_question = None
- def list_questions(self) -> None:
+ def list_questions(self) -> str:
"""
List all the questions.