mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +00:00
Change score display
This commit is contained in:
parent
56ebf58ce0
commit
170b8caf2d
3 changed files with 11 additions and 2 deletions
|
@ -47,6 +47,7 @@ class TriviaCommand(Command):
|
||||||
correct_answer: str = question["correct_answer"]
|
correct_answer: str = question["correct_answer"]
|
||||||
wrong_answers: typing.List[str] = question["incorrect_answers"]
|
wrong_answers: typing.List[str] = question["incorrect_answers"]
|
||||||
answers = [correct_answer, *wrong_answers]
|
answers = [correct_answer, *wrong_answers]
|
||||||
|
if question["type"] == "multiple"
|
||||||
random.shuffle(answers)
|
random.shuffle(answers)
|
||||||
# Find the correct index
|
# Find the correct index
|
||||||
for index, answer in enumerate(answers):
|
for index, answer in enumerate(answers):
|
||||||
|
@ -101,7 +102,7 @@ class TriviaCommand(Command):
|
||||||
else:
|
else:
|
||||||
results += self._wrong_emoji
|
results += self._wrong_emoji
|
||||||
answerer.trivia_score.wrong_answers += 1
|
answerer.trivia_score.wrong_answers += 1
|
||||||
results += f" {answerer} ({answerer.trivia_score.correct_answers}|{answerer.trivia_score.wrong_answers})\n"
|
results += f" {answerer} ({answerer.trivia_score.correct_answers}/{answerer.trivia_score.total_answers})\n"
|
||||||
await data.reply(results)
|
await data.reply(results)
|
||||||
del self._answerers[question_id]
|
del self._answerers[question_id]
|
||||||
await asyncify(self.interface.session.commit)
|
await asyncify(self.interface.session.commit)
|
||||||
|
|
|
@ -25,5 +25,13 @@ class TriviaScore:
|
||||||
def wrong_answers(self):
|
def wrong_answers(self):
|
||||||
return Column(Integer, nullable=False, default=0)
|
return Column(Integer, nullable=False, default=0)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def total_answers(self):
|
||||||
|
return self.correct_answers + self.wrong_answers
|
||||||
|
|
||||||
|
@property
|
||||||
|
def offset(self):
|
||||||
|
return self.correct_answers - self.wrong_answers
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<TriviaScore of {self.royal}: ({self.correct_answers}|{self.wrong_answers})>"
|
return f"<TriviaScore of {self.royal}: ({self.correct_answers}|{self.wrong_answers})>"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
semantic = "5.0a44"
|
semantic = "5.0a45"
|
||||||
|
|
Loading…
Reference in a new issue