More event handling improvements.

- Added fourth game state: pre-question
- Added logging (and graceful failure) of any attempts to schedule more
  than one concurrent event
This commit is contained in:
Yizhe Shen 2015-02-19 20:18:53 -05:00
parent bc98efd54d
commit 92aa35f578
1 changed files with 6 additions and 2 deletions

View File

@ -489,6 +489,7 @@ class Game:
return
# Reset and increment question properties
self.state = 'pre-question'
self.skipList = []
self.guessedAnswers = []
self.totalAmountWon = 0
@ -528,7 +529,7 @@ class Game:
# Send question to channel
self.sendQuestion()
# Reset state variables only after question has been sent
# Set state variables after question has been sent
self.state = 'in-question'
self.questionRepeated = False
self.shownHint = False
@ -546,7 +547,10 @@ class Game:
"""
# Schedule a new event to happen at the specified time
if self.active:
schedule.addEvent(event, time, '%s.trivia' % self.channel)
try:
schedule.addEvent(event, time, '%s.trivia' % self.channel)
except AssertionError as e:
log.error('Unable to queue {0} because another event is already scheduled.'.format(event.func_name))
def removeAccents(self, text):
text = unicode(text.decode('utf-8'))