Commit 6c3be383 authored by Jonathan Harker's avatar Jonathan Harker

Some quiz gameplay improvements around status and scoreboard.

parent 52fd6a5b
......@@ -142,6 +142,8 @@ class LolBot(SingleServerIRCBot):
if self.quiz_scores[nick] != 1:
score += "s"
self.connection.notice(self.channel, '%s has %s.' % (nick, score))
if not len(self.quiz_scores):
self.connection.notice(self.channel, 'So far, nobody has got anything right.')
def handle_quiz(self, nick, message):
# bail if there's no quiz or unanswered question.
......@@ -152,8 +154,14 @@ class LolBot(SingleServerIRCBot):
if self.question.attempt(message):
self.quiz_award_points(nick)
self.quiz_check_win(nick)
# if nobody has won, carry on
if self.quiz:
# scores every 10 questions.
if self.quiz % 10 == 0:
self.quiz_scoreboard()
self.quiz_get_next()
def do_command(self, e, cmd):
......@@ -170,7 +178,10 @@ class LolBot(SingleServerIRCBot):
c.notice(nick, self.helptext)
elif cmd == 'status':
c.notice(nick, "I know %s questions." % len(self.qb))
c.notice(self.channel, "I know %s questions." % len(self.qb))
if self.quiz:
c.notice(self.channel, "I am currently running a quiz.")
self.quiz_scoreboard()
elif cmd == 'halt' or cmd == 'quit':
if self.quiz:
......@@ -180,6 +191,10 @@ class LolBot(SingleServerIRCBot):
else:
c.notice(self.channel, "No quiz running.")
elif cmd == 'scores':
if self.quiz:
self.quiz_scoreboard()
elif cmd == 'ask':
if self.quiz:
c.notice(self.channel, "Quiz is running. Use halt or quit to stop.")
......@@ -261,4 +276,7 @@ def main():
if __name__ == "__main__":
main()
try:
main()
except KeyboardInterrupt:
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment