Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import data
- words = data.words
- comments = data.comments
- intro1 = data.intro1
- instruc1 = data.instruc1
- instruc2 = data.instruc2
- import random
- import sys
- import os
- sboard = []
- bad_guesses = []
- good_guesses = []
- check = []
- score = 0
- secret_word = random.choice(words)
- wordindex = words.index("{}".format(secret_word))
- def introduction():
- clear()
- print(intro1)
- while True:
- start = input("Press enter to start: ").lower()
- if start == "quit":
- clear()
- sys.exit()
- elif start == "instructions":
- instructions()
- elif start == "menu":
- continue
- elif start == "guess":
- print("\nYou cannot guess yet!")
- continue
- elif start == "score":
- scoreboard()
- else:
- setupgame()
- main()
- def setupgame():
- clear()
- global name
- name = input("\n\n\nEnter your name (for the scoreboard): ")
- if name.lower() == "menu":
- introduction()
- elif name.lower() == "quit":
- clear()
- sys.exit()
- clear()
- for letters in secret_word:
- if letters not in check:
- check.append(letters)
- else:
- continue
- print('\n\n')
- main()
- def main():
- print('\n\n')
- while len(bad_guesses) <= 7:
- print("\n\n\nClue:\n\n")
- print(comments[wordindex])
- print('\n\n\n')
- for letter in secret_word:
- if letter in good_guesses:
- print(letter, " ", end='')
- else:
- print("_ ", end='')
- print("\n\nYour score is: {}".format(score))
- print("\nStrikes: {}/7\n".format(len(bad_guesses)))
- print("Wrong guesses: \n")
- for bguess in bad_guesses:
- print(bguess, " ", end='')
- print("\n\n\nOptions: 'guess' 'menu' 'quit'\n")
- guess()
- else:
- clear()
- print("\n\n\nYou didn't get it! LOSER!!! My word was '{}'.".format(secret_word))
- print("\n\nYour score was: {}!\n".format(score))
- result = name + " " + str(score)
- sboard.append(result)
- playagain()
- def guess():
- global userguess
- userguess = input("Guess a letter: ").lower()
- clear()
- if userguess == "quit":
- sys.exit()
- elif userguess == "menu":
- introduction()
- elif userguess == "guess":
- fullguess()
- elif len(userguess) != 1:
- print("\n\nYou must guess a (single) letter!")
- main()
- elif userguess in bad_guesses or userguess in good_guesses:
- print("\n\nYou've already guessed that letter!")
- main()
- elif not userguess.isalpha():
- print("\n\nYou can only guess letters!")
- main()
- good_bad()
- def good_bad():
- global score
- if userguess in secret_word:
- good_guesses.append(userguess)
- score += 10
- print("\n\nGood guess!")
- if len(good_guesses) == len(check):
- clear()
- print("\n\n\nYOU WIN!!! The word was '{}'.\n".format(secret_word))
- print("\n\nYour score was: {}!\n".format(score))
- result = name + " " + str(score)
- sboard.append(result)
- playagain()
- main()
- else:
- bad_guesses.append(userguess)
- score -= 20
- bad1 = int(len(bad_guesses))
- if bad1 == 7:
- print("\n\nNext incorrect answer means that you lose!!")
- else:
- print("\n\nUnlucky! You have used {} of your 7 wrong guesses!".format(bad1))
- main()
- def clear():
- if os.name == 'nt':
- os.system('cls')
- else:
- os.system('clear')
- def playagain():
- while True:
- global bad_guesses, good_guesses, check, score, secret_word, wordindex
- bad_guesses = []
- good_guesses = []
- check = []
- score = 0
- secret_word = random.choice(words)
- wordindex = words.index("{}".format(secret_word))
- play_again = input("""
- Options: 'yes' 'no' 'menu' 'score' 'quit'\n
- Would you like to play again?: """).lower()
- if play_again == "yes":
- setupgame()
- elif play_again == "no" or play_again == "quit":
- clear()
- sys.exit()
- elif play_again == "menu":
- introduction()
- elif play_again == "score":
- scoreboard()
- else:
- clear()
- print("\n\nYou must type either 'yes' or 'no'!\n\n")
- continue
- def instructions():
- clear()
- print(instruc1)
- cont = input("Press enter to continue to page 2, 'Scoring And Scoreboard': ").lower()
- if cont == "quit":
- clear()
- sys.exit()
- elif cont == "menu":
- introduction()
- clear()
- print(instruc2)
- while True:
- end = input("""Type 'menu' to return to the main menu, 'quit' to exit the game,
- or 'back' to go back to the previous page: """).lower()
- if end == "menu":
- introduction()
- elif end == "quit":
- clear()
- sys.exit()
- elif end == "back":
- instructions()
- else:
- continue
- def fullguess():
- global score
- clear()
- print("\n\n\nThis is what you have so far:\n")
- for letter in secret_word:
- if letter in good_guesses:
- print(letter, " ", end='')
- else:
- print("_ ", end='')
- print("\nThe clue was:")
- print(comments[wordindex])
- print("\n\nEnter the word/phrase that you think is correct:")
- print("(Type 'letters' to go back to guessing letter by letter)")
- fguess = input("> ").lower()
- if fguess == "quit":
- clear()
- sys.exit()
- elif fguess == "menu":
- introduction()
- elif fguess == "letters":
- clear()
- print('\n\n')
- main()
- elif fguess == secret_word:
- clear()
- print("\n\n\nCONGRATULATIONS!!! You got it right!\n")
- gscore = len(check) - len(good_guesses)
- gscore *= 30
- score += gscore
- print("\nYour score was: {}!\n".format(score))
- result = name + " " + str(score)
- sboard.append(result)
- playagain()
- else:
- clear()
- print("\n\n\nOUCH!!! Bad luck, keep trying!")
- score -= 50
- print("\nYour score is: {}!\n".format(score))
- while True:
- g_again = input("Type 'again' to guess again, or 'letters' to go back to guessing by letter: ").lower()
- if g_again == "again":
- fullguess()
- elif g_again == "letters":
- clear()
- print('\n\n')
- main()
- elif g_again == "quit":
- clear()
- sys.exit()
- elif g_again == "menu":
- introduction()
- main()
- def scoreboard():
- clear()
- print("\n\n\nSCOREBOARD\n\n")
- try:
- print("1st PLACE: ", sboard[0], "\n")
- except IndexError:
- print("1st PLACE: \n")
- num1 = 2
- num2 = 1
- while num1 <= 9:
- try:
- print("{} > ".format(num1), sboard[num2])
- except IndexError:
- print("{} > ".format(num1))
- num1 += 1
- num2 += 1
- try:
- print("10 > ", sboard[9])
- except IndexError:
- print("10 > ")
- print("\n\n\n(Note: Type 'wipe' to refresh the scoreboard!)\n")
- while True:
- back = input("Type 'menu' to go back to the main menu, or 'quit' to exit the game: ").lower()
- if back == "menu":
- introduction()
- elif back == "quit":
- clear()
- sys.exit()
- elif back == "wipe":
- global sboard
- sboard = []
- scoreboard()
- else:
- continue
- introduction()
Advertisement
Add Comment
Please, Sign In to add comment