diff options
| author | Ben Friedland <ben174@gmail.com> | 2013-01-07 02:35:32 -0800 |
|---|---|---|
| committer | Ben Friedland <ben174@gmail.com> | 2013-01-07 02:35:32 -0800 |
| commit | d2c76307481938fe10cdec93a833b5b9f0577b13 (patch) | |
| tree | d357a022dfd178a7201e6c262d6c12c07a543be0 /weatbag/tiles/e2.py | |
| parent | 0365b19449ec05b3e1bf39b67e88eb8f800bda25 (diff) | |
Error handling for invalid guesses in wizard's challenge.
Diffstat (limited to 'weatbag/tiles/e2.py')
| -rw-r--r-- | weatbag/tiles/e2.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/weatbag/tiles/e2.py b/weatbag/tiles/e2.py index b71bc5e..a501985 100644 --- a/weatbag/tiles/e2.py +++ b/weatbag/tiles/e2.py @@ -19,17 +19,20 @@ class Tile: def action(self, player, do): if do[0] == "guess" and self.contents['flaming torch']: - guess = int(do[1]) - if guess > self.lucky_number: - print("Too high! Guess again!") - elif guess < self.lucky_number: - print("Too low! Guess again!") - else: - print("You guessed my lucky number!") - print("The wizard hands you a flaming torch! " - "He then suddenly vanishes, leaving behind a pile of dust.") - self.contents['flaming torch'] -= 1 - player.give('flaming torch') + try: + guess = int(do[1]) + if guess > self.lucky_number: + print("Too high! Guess again!") + elif guess < self.lucky_number: + print("Too low! Guess again!") + else: + print("You guessed my lucky number!") + print("The wizard hands you a flaming torch! " + "He then suddenly vanishes, leaving behind a pile of dust.") + self.contents['flaming torch'] -= 1 + player.give('flaming torch') + except: + print("Please try guessing a number, like 'guess 7'.") elif (do[0] in words.take): print("You can't have my prize, you have to guess the lucky number!") else: |
