From 170b8caf2d1fde1977e8d521215d9b36f82a1574 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 3 Sep 2019 19:13:03 +0200 Subject: [PATCH] Change score display --- royalnet/commands/royalgames/trivia.py | 3 ++- royalnet/database/tables/triviascores.py | 8 ++++++++ royalnet/version.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/royalnet/commands/royalgames/trivia.py b/royalnet/commands/royalgames/trivia.py index 44ac88f5..5dd2815c 100644 --- a/royalnet/commands/royalgames/trivia.py +++ b/royalnet/commands/royalgames/trivia.py @@ -47,6 +47,7 @@ class TriviaCommand(Command): correct_answer: str = question["correct_answer"] wrong_answers: typing.List[str] = question["incorrect_answers"] answers = [correct_answer, *wrong_answers] + if question["type"] == "multiple" random.shuffle(answers) # Find the correct index for index, answer in enumerate(answers): @@ -101,7 +102,7 @@ class TriviaCommand(Command): else: results += self._wrong_emoji 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) del self._answerers[question_id] await asyncify(self.interface.session.commit) diff --git a/royalnet/database/tables/triviascores.py b/royalnet/database/tables/triviascores.py index 5835623c..d0b75b2d 100644 --- a/royalnet/database/tables/triviascores.py +++ b/royalnet/database/tables/triviascores.py @@ -25,5 +25,13 @@ class TriviaScore: def wrong_answers(self): 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): return f"" diff --git a/royalnet/version.py b/royalnet/version.py index 9b2b69c1..98fdd50e 100644 --- a/royalnet/version.py +++ b/royalnet/version.py @@ -1 +1 @@ -semantic = "5.0a44" +semantic = "5.0a45"