From 2952ed4d0780b192884cde4ed74520feaf1d02e3 Mon Sep 17 00:00:00 2001 From: James Vega Date: Fri, 6 Aug 2004 02:01:35 +0000 Subject: [PATCH] Make sure we don't start a game if the file doesn't exist. Also, complete sentences are nice to have. --- plugins/Words.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/Words.py b/plugins/Words.py index 66b248efd..14f0dcc59 100644 --- a/plugins/Words.py +++ b/plugins/Words.py @@ -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