|
| 1 | +class Hangman(): |
| 2 | + def __init__(self): |
| 3 | + print "Welcome to 'Hangman', are you ready to die?" |
| 4 | + print "(1)Yes, for I am already dead.\n(2)No, get me outta here!" |
| 5 | + user_choice_1 = raw_input("->") |
| 6 | + |
| 7 | + if user_choice_1 == '1': |
| 8 | + print "Loading nooses, murderers, rapists, thiefs, lunatics..." |
| 9 | + self.start_game() |
| 10 | + elif user_choice_1 == '2': |
| 11 | + print "Bye bye now..." |
| 12 | + exit() |
| 13 | + else: |
| 14 | + print "I'm sorry, I'm hard of hearing, could you repeat that?" |
| 15 | + self.__init__() |
| 16 | + |
| 17 | + def start_game(self): |
| 18 | + print "A crowd begins to gather, they can't wait to see some real" |
| 19 | + print "justice. There's just one thing, you aren't a real criminal." |
| 20 | + print "No, no. You're the wrong time, wrong place type. You may think" |
| 21 | + print "you're dead, but it's not like that at all. Yes, yes. You've" |
| 22 | + print "got a chance to live. All you've gotta do is guess the right" |
| 23 | + print "words and you can live to see another day. But don't get so" |
| 24 | + print "happy yet. If you make 6 wrong guess, YOU'RE TOAST! VAMANOS!" |
| 25 | + self.core_game() |
| 26 | + |
| 27 | + def core_game(self): |
| 28 | + guesses = 0 |
| 29 | + letters_used = "" |
| 30 | + the_word = "pizza" |
| 31 | + progress = ["?", "?", "?", "?", "?"] |
| 32 | + |
| 33 | + while guesses < 6: |
| 34 | + guess = raw_input("Guess a letter ->") |
| 35 | + |
| 36 | + if guess in the_word and not in letters_used: |
| 37 | + print "As it turns out, your guess was RIGHT!" |
| 38 | + letters_used += "," + guess |
| 39 | + self.hangman_graphic(guesses) |
| 40 | + print "Progress: " + self.progress_updater(guess, the_word, progress) |
| 41 | + print "Letter used: " + letters_used |
| 42 | + elif guess not in the_word and not(in letters_used): |
| 43 | + guesses += 1 |
| 44 | + print "Things aren't looking so good, that guess was WRONG!" |
| 45 | + print "Oh man, that crowd is getting happy, I thought you" |
| 46 | + print "wanted to make them mad?" |
| 47 | + letters_used += "," + guess |
| 48 | + self.hangman_graphic(guesses) |
| 49 | + print "Progress: " + "".join(progress) |
| 50 | + print "Letter used: " + letters_used |
| 51 | + else: |
| 52 | + print "That's the wrong letter, you wanna be out here all day?" |
| 53 | + print "Try again!" |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + def hangman_graphic(self, guesses): |
| 58 | + if guesses == 0: |
| 59 | + print "________ " |
| 60 | + print "| | " |
| 61 | + print "| " |
| 62 | + print "| " |
| 63 | + print "| " |
| 64 | + print "| " |
| 65 | + elif guesses == 1: |
| 66 | + print "________ " |
| 67 | + print "| | " |
| 68 | + print "| 0 " |
| 69 | + print "| " |
| 70 | + print "| " |
| 71 | + print "| " |
| 72 | + elif guesses == 2: |
| 73 | + print "________ " |
| 74 | + print "| | " |
| 75 | + print "| 0 " |
| 76 | + print "| / " |
| 77 | + print "| " |
| 78 | + print "| " |
| 79 | + elif guesses == 3: |
| 80 | + print "________ " |
| 81 | + print "| | " |
| 82 | + print "| 0 " |
| 83 | + print "| /| " |
| 84 | + print "| " |
| 85 | + print "| " |
| 86 | + elif guesses == 4: |
| 87 | + print "________ " |
| 88 | + print "| | " |
| 89 | + print "| 0 " |
| 90 | + print "| /|\ " |
| 91 | + print "| " |
| 92 | + print "| " |
| 93 | + elif guesses == 5: |
| 94 | + print "________ " |
| 95 | + print "| | " |
| 96 | + print "| 0 " |
| 97 | + print "| /|\ " |
| 98 | + print "| / " |
| 99 | + print "| " |
| 100 | + else: |
| 101 | + print "________ " |
| 102 | + print "| | " |
| 103 | + print "| 0 " |
| 104 | + print "| /|\ " |
| 105 | + print "| / \ " |
| 106 | + print "| " |
| 107 | + print "The noose tightens around your neck, and you feel the" |
| 108 | + print "sudden urge to urinate." |
| 109 | + print "GAME OVER!" |
| 110 | + self.__init__() |
| 111 | + |
| 112 | + def progress_updater(self, guess, the_word, progress): |
| 113 | + i = 0 |
| 114 | + while i < len(the_word): |
| 115 | + if guess == the_word[i]: |
| 116 | + progress[i] = guess |
| 117 | + i += 1 |
| 118 | + else: |
| 119 | + i += 1 |
| 120 | + |
| 121 | + return "".join(progress) |
| 122 | + |
| 123 | +game = Hangman() |
0 commit comments