Commit bf2da99c authored by Jonathan Harker's avatar Jonathan Harker

Add some time delays, minor output improvements.

parent d76ec8a3
......@@ -213,18 +213,21 @@ class LolBot(SingleServerIRCBot):
self.quiz += 1
self.question = random.choice(self.qb)
print(str(self.question.question))
self.connection.notice(self.channel, str(self.question.question))
self.connection.notice(self.channel, "Question %s: %s" % (self.quiz, str(self.question.question)))
def quiz_award_points(self, nick):
score = "%s point" % self.question.score
if self.question.score != 1:
score += "s"
self.connection.notice(self.channel, 'Correct! The answer was %s. %s scores %s.' % (self.question.answer, nick, score))
if nick not in self.quiz_scores.keys():
self.quiz_scores[nick] = 0
self.quiz_scores[nick] += self.question.score
score = "%s point" % self.quiz_scores[nick]
if self.quiz_scores[nick] != 1:
score += "s"
self.connection.notice(self.channel, 'Correct! The answer was %s.' % self.question.answer)
time.sleep(1)
self.connection.notice(self.channel, '%s is on %s.' % (nick, score))
def quiz_check_win(self, nick):
if self.quiz_scores[nick] == 10:
self.connection.notice(self.channel, '%s wins with 10 points!' % nick)
......@@ -232,6 +235,10 @@ class LolBot(SingleServerIRCBot):
self.stop_quiz()
def quiz_scoreboard(self):
if not self.quiz:
self.connection.notice(self.channel, 'Quiz not running.')
return
self.connection.notice(self.channel, 'Scoreboard:')
for nick in self.quiz_scores.keys():
score = "%s point" % self.quiz_scores[nick]
......@@ -249,6 +256,7 @@ class LolBot(SingleServerIRCBot):
# see if anyone answered correctly.
if self.question.attempt(message):
self.quiz_award_points(nick)
time.sleep(1)
self.quiz_check_win(nick)
# if nobody has won, carry on
......@@ -258,6 +266,7 @@ class LolBot(SingleServerIRCBot):
if self.quiz % 10 == 0:
self.quiz_scoreboard()
time.sleep(1)
self.quiz_get_next()
def do_command(self, e, cmd):
......
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