#Hang-man game for fun

import random, time

stages = ['''
  +---+
  |   |
  O   |
 /|\  |
 / \  |
      |
=========
''', '''
  +---+
  |   |
  O   |
 /|\  |
 /    |
      |
=========
''', '''
  +---+
  |   |
  O   |
 /|\  |
      |
      |
=========
''', '''
  +---+
  |   |
  O   |
 /|   |
      |
      |
=========''', '''
  +---+
  |   |
  O   |
  |   |
      |
      |
=========
''', '''
  +---+
  |   |
  O   |
      |
      |
      |
=========
''', '''
  +---+
  |   |
      |
      |
      |
      |
=========
''']

logo = ''' 
 _                                             
| |                                            
| |__   __ _ _ __   __ _ _ __ ___   __ _ _ __  
| '_ \ / _` | '_ \ / _` | '_ ` _ \ / _` | '_ \ 
| | | | (_| | | | | (_| | | | | | | (_| | | | |
|_| |_|\__,_|_| |_|\__, |_| |_| |_|\__,_|_| |_|
                    __/ |                      
                   |___/    '''



dict_words = ['abruptly', 'absent', 'awesome', 'monkey', 'chili', 'pudding', 'luffy', 'cowboy', 'xenomorph', 'basketball', 'poetry', 'science', 'funky', 'pickel', 'vitamins',
'absurd','abyss','affix','askew','avenue','awkward', 'axiom', 'azure', 'bagpipes', 'bandwagon', 'banjo', 'bayou', 'beekeeper','bikini', 'blitz', 'blizzard', 'boggle','bookworm', 'boxcar', 'boxful', 
'buckaroo','buffalo','buffoon', 'buxom', 'buzzard', 'buzzing', 'buzzwords','caliph', 'cobweb', 'cockiness', 'croquet', 'crypt', 'curacao', 'cycle', 'daiquiri','dirndl', 'disavow', 'dizzying', 
'duplex', 'dwarves', 'embezzle', 'equip', 'espionage','euouae', 'exodus', 'faking', 'fishhook', 'fixable', 'fjord', 'flapjack', 'flopping','fluffiness', 'flyby', 'foxglove', 'frazzled', 'frizzled', 'fuchsia', 'funny', 
'gabby', 'galaxy', 'galvanize','gazebo', 'giaour', 'gizmo', 'glowworm', 'glyph', 'gnarly', 'gnostic', 'gossip', 'grogginess', 'haiku', 'haphazard', 'hyphen', 'iatrogenic', 'icebox', 'injury', 'ivory', 'ivy', 
'jackpot', 'jaundice', 'jawbreaker','jaywalk', 'jazziest', 'jazzy', 'jelly', 'jigsaw', 'jinx', 'jiujitsu', 'jockey', 'jogging', 'joking', 'jovial', 'joyful', 'juicy', 'jukebox', 'jumbo', 'kayak', 'kazoo', 
'keyhole', 'khaki', 'kilobyte', 'kiosk', 'kitsch', 'kiwifruit', 'klutz', 'knapsack', 'larynx', 'lengths', 'lucky', 'linux', 'luxury', 'lymph', 'marquis', 'matrix', 'megahertz', 'microwave','mnemonic', 'mystify', 'naphtha', 
'nightclub', 'nowadays', 'numbskull', 'nymph', 'onyx', 'ovary', 'oxidize', 'oxygen', 'pajama', 'peekaboo', 'phlegm', 'pixel', 'pizazz', 'pneumonia', 'polka', 'pshaw', 'psyche', 'puppy', 'puzzling', 'quartz', 
'queue', 'quips', 'quixotic', 'quiz', 'quizzes', 'quorum', 'razzmatazz', 'rhubarb', 'rhythm', 'rickshaw', 'schnapps', 'scratch', 'shiv', 'snazzy', 'sphinx', 'spritz', 'squawk', 'staff', 'strength', 'strengths', 'stretch', 'stronghold', 
'stymied', 'subway', 'swivel', 'syndrome', 'thriftless','thumbscrew', 'topaz', 'transcript', 'transgress','transplant', 'triphthong','twelfth', 'twelfths', 'unknown', 'unworthy', 'unzip', 'uptown', 'vaporize', 
'vixen', 'vodka', 'voodoo', 'vortex', 'voyeurism', 'walkway', 'waltz', 'wave', 'wavy', 'waxy', 'wellspring','wheezy', 'whiskey', 'whizzing', 'whomever','wimpy', 'witchcraft','wizard', 'woozy', 'wristwatch', 
'wyvern', 'xylophone', 'yachtsman', 'yippee', 'yoked', 'youthful','yummy', 'zephyr', 'zigzag', 'zigzagging','zilch', 'zipper', 'zodiac', 'zombie', "zebra","pineapple","pipe","butter","cream","bread","donkey","cricket","tumbler","venus","telephone"]

game_word = random.choice(dict_words)
word_length = len(game_word)
fail_num = 0
stag_pos = 6

prev_let = ""
blank_word = []
list_of_prev = []

for num in range(0, word_length):
    blank_word.append("_")

end_game = False

print(f"Welcome to\n{logo}\nHope you enjoy this game!\n")

game_over = False

while end_game is not True:

  while game_over == False:
      player_guess = input("Enter a letter: \n").lower()
      guess_count = 0

      if player_guess in list_of_prev:
            print("Sorry you have already guessed that letter. Please guess again!\n")
      else:
        for w_position in range(word_length):
          letter = game_word[w_position]
          if player_guess == letter:
            blank_word[w_position] = player_guess
            guess_count = 1
        if guess_count == 0:
          fail_num += 1
          stag_pos -= 1


      blank_list = ' '.join(blank_word)

      if player_guess not in list_of_prev:
        list_of_prev.append(player_guess)

      prev_list = ' '.join(list_of_prev)

      print(f"{stages[stag_pos]}\nThe word is: {blank_list}\nYour previous guesses were: '{prev_list}'")
      
      if "_" not in blank_word:
          game_over = True
          print("You are winner! Ha Ha Ha")
      elif fail_num == 6:
          game_over = True
          print(f"You Lose! The word was: {game_word}")
      
  replay = int(input("\nWould you like to play again?\n1 = Yes\n2 = No\n"))

  if replay == 2:
    end_game = True
  else:
    end_game = False

print("Thanks for playing!")
time.sleep(5)
