Make sure we don't start a game if the file doesn't exist. Also, complete

sentences are nice to have.
This commit is contained in:
James Vega 2004-08-06 02:01:35 +00:00
parent 5728974ea2
commit 2952ed4d07
1 changed files with 9 additions and 3 deletions

View File

@ -217,7 +217,12 @@ class Words(callbacks.Privmsg):
game.prefix = self.registryValue('hangman.prefix', channel)
game.guessed = False
game.unused = copy.copy(self.validLetters)
game.hidden = game.getWord()
try:
game.hidden = game.getWord()
except IOError, e:
self.games[channel] = None
irc.error(str(e))
return
game.guess = re.sub('[%s]' % string.ascii_lowercase, '_',
game.hidden)
self._hangmanReply(irc, channel,
@ -296,11 +301,12 @@ class Words(callbacks.Privmsg):
# Verify if the user won or lost
if game.guessed and game.tries > 0:
self._hangmanReply(irc, channel,
'You win! The was indeed %r.' % game.hidden)
'You win! The word was indeed %r.' %
game.hidden)
self.endGame(channel)
elif not game.guessed and game.tries == 0:
self._hangmanReply(irc, channel,
'You lose! The was %r.' % game.hidden)
'You lose! The word was %r.' % game.hidden)
self.endGame(channel)
###
# END HANGMAN