Some quiz gameplay improvements around status and scoreboard.
This commit is contained in:
parent
52fd6a5b37
commit
6c3be38300
1 changed files with 20 additions and 2 deletions
22
lolbot.py
22
lolbot.py
|
|
@ -142,6 +142,8 @@ class LolBot(SingleServerIRCBot):
|
||||||
if self.quiz_scores[nick] != 1:
|
if self.quiz_scores[nick] != 1:
|
||||||
score += "s"
|
score += "s"
|
||||||
self.connection.notice(self.channel, '%s has %s.' % (nick, score))
|
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):
|
def handle_quiz(self, nick, message):
|
||||||
# bail if there's no quiz or unanswered question.
|
# bail if there's no quiz or unanswered question.
|
||||||
|
|
@ -152,8 +154,14 @@ class LolBot(SingleServerIRCBot):
|
||||||
if self.question.attempt(message):
|
if self.question.attempt(message):
|
||||||
self.quiz_award_points(nick)
|
self.quiz_award_points(nick)
|
||||||
self.quiz_check_win(nick)
|
self.quiz_check_win(nick)
|
||||||
|
|
||||||
# if nobody has won, carry on
|
# if nobody has won, carry on
|
||||||
if self.quiz:
|
if self.quiz:
|
||||||
|
|
||||||
|
# scores every 10 questions.
|
||||||
|
if self.quiz % 10 == 0:
|
||||||
|
self.quiz_scoreboard()
|
||||||
|
|
||||||
self.quiz_get_next()
|
self.quiz_get_next()
|
||||||
|
|
||||||
def do_command(self, e, cmd):
|
def do_command(self, e, cmd):
|
||||||
|
|
@ -170,7 +178,10 @@ class LolBot(SingleServerIRCBot):
|
||||||
c.notice(nick, self.helptext)
|
c.notice(nick, self.helptext)
|
||||||
|
|
||||||
elif cmd == 'status':
|
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':
|
elif cmd == 'halt' or cmd == 'quit':
|
||||||
if self.quiz:
|
if self.quiz:
|
||||||
|
|
@ -180,6 +191,10 @@ class LolBot(SingleServerIRCBot):
|
||||||
else:
|
else:
|
||||||
c.notice(self.channel, "No quiz running.")
|
c.notice(self.channel, "No quiz running.")
|
||||||
|
|
||||||
|
elif cmd == 'scores':
|
||||||
|
if self.quiz:
|
||||||
|
self.quiz_scoreboard()
|
||||||
|
|
||||||
elif cmd == 'ask':
|
elif cmd == 'ask':
|
||||||
if self.quiz:
|
if self.quiz:
|
||||||
c.notice(self.channel, "Quiz is running. Use halt or quit to stop.")
|
c.notice(self.channel, "Quiz is running. Use halt or quit to stop.")
|
||||||
|
|
@ -261,4 +276,7 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
try:
|
||||||
|
main()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue