diff options
| author | Thomas Kluyver <takowl@gmail.com> | 2013-01-07 03:42:50 -0800 |
|---|---|---|
| committer | Thomas Kluyver <takowl@gmail.com> | 2013-01-07 03:42:50 -0800 |
| commit | 82d34a184b272f9578424d7753139f3dcf313895 (patch) | |
| tree | 3145d983b5bd23879d9a77f56a9293455fd50c52 /weatbag | |
| parent | 1ea9764c84c6c01794724ec8a6dc8c28931a3229 (diff) | |
| parent | d37270bc9978e55928509b89bd31a127d5792e06 (diff) | |
Merge pull request #3 from ben174/master
Torch in e2 is now unlit...
Diffstat (limited to 'weatbag')
| -rw-r--r-- | weatbag/tiles/e2.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/weatbag/tiles/e2.py b/weatbag/tiles/e2.py index a501985..2a8690b 100644 --- a/weatbag/tiles/e2.py +++ b/weatbag/tiles/e2.py @@ -3,34 +3,38 @@ import random class Tile: def __init__(self): - self.contents = {'flaming torch': 1} + self.contents = {'unlit torch': 1} self.lucky_number = random.randrange(1,100) + self.guess_count = 0 def describe(self): - if self.contents['flaming torch']: + if self.contents['unlit torch']: self.challenge() else: print("You see a pile of dust on the ground.") def challenge(self): - print("A wizard suddenly appears and says 'If you guess my " + print("A dwarf suddenly appears and says 'If you guess my " "lucky number, I might give you a reward!'") - print("Say 'guess' followed by a number between 1-100 to guess.") + print("To make a guess, type 'guess' followed by a number " + "between 1-100.") def action(self, player, do): - if do[0] == "guess" and self.contents['flaming torch']: + if do[0] == "guess" and self.contents['unlit torch']: try: guess = int(do[1]) + self.guess_count += 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! " + print("You guessed my lucky number in %d guesses!" % + (self.guess_count)) + print("The dwarf hands you a torch! " "He then suddenly vanishes, leaving behind a pile of dust.") - self.contents['flaming torch'] -= 1 - player.give('flaming torch') + self.contents['unlit torch'] -= 1 + player.give('unlit torch') except: print("Please try guessing a number, like 'guess 7'.") elif (do[0] in words.take): |
