-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest _code
More file actions
106 lines (89 loc) · 3.55 KB
/
test _code
File metadata and controls
106 lines (89 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from termcolor import cprint
from rich.console import Console
import time
import sys
console = Console()
## Function providing movie, year_quote, and correct_guess_quote.
def movie_match(year: int):
if year in [2005, 66]:
movie = movie_list[1]
year_quote = "Executing order 66."
correct_guess_quote = "Good Soldiers follow orders"
cprint(year_quote, "white" , "on_black")
elif year == 1963:
movie = movie_list[6]
year_quote = "There must be no regrets, no tears, no anxieties. Just go forward in all your beliefs, and prove to me that I am not mistaken in mine."
correct_guess_quote = "No, I am the Doctor."
cprint(year_quote, "white" , "on_black")
elif year == 1966:
movie = movie_list[2]
year_quote = "To explore strange new worlds.To seek out new life and new civilizations,To boldly go where no man has gone before."
correct_guess_quote = "Make it so."
cprint(year_quote, "white" , "on_black")
elif year == 1985:
movie = movie_list[0]
year_quote = " If my calculations are correct, when this baby hits 88 miles per hour... you're gonna see some serious shit."
correct_guess_quote = "Far out, Doc!"
cprint(year_quote, "white" , "on_black")
elif year == 5555:
movie = movie_list[1]
year_quote = "This is the end. Forget the mission. Oh, nightmare. I'm free"
correct_guess_quote = " We should have listened to Fives..."
cprint(year_quote, "white", "on_black")
return movie, year_quote, correct_guess_quote
## Timer function.
def timer():
for remaining in range(5, 0, -1):
sys.stdout.write("\r")
sys.stdout.write("{:2d} seconds to next question".format(remaining))
sys.stdout.flush()
time.sleep(1)
## List of movies.
movie_list =["back to the future", 'star wars', 'star trek', 'bladerunner', 'johnny five', 'doctor who', "jumanji" 'johnny mnemonic']
## initialize year and score_count variables.
year = 1
score_count = 0
## Start the geekology test by clearing the screen.
console.clear()
## while loop that includes all game logic.
while year != 0:
print()
cprint("Geekology test!!!", "yellow", "on_dark_grey")
print()
## try/except that allows user to type anything on year variable without crashing.
try:
year =int(float(input('Give me a year... \n Jumanji drums begin playing: ')))
movie, year_quote, correct_guess_quote = movie_match(year)
except UnboundLocalError:
print("That year is not in my database")
timer()
console.clear()
continue
guess = input("What movie is this from? ").lower()
## Correct guess logic.
if guess == movie:
cprint(correct_guess_quote, "white", "on_black")
if year == 5555:
score_count += 10
print("bonus points awarded +10 pts for answering correctly")
print()
timer()
console.clear()
else:
score_count += 1
print("+1 pts for answering correctly")
print()
timer()
console.clear()
## Incorrect guess logic.
else:
cprint(f"Ha, Neeeerd that was incorrect here is your score! {score_count}.", "red", "on_white")
cont = input("Would you like to try again yes/no. ")
if cont == "yes, y":
score_count = 0
timer()
console.clear()
continue
else:
print("Thanks for playing my geekology test.")
break