-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreativeTask.py
167 lines (147 loc) · 4.05 KB
/
CreativeTask.py
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import time
import os
import random
#1 Tables
Stanza = [[], [], []]
StanzaIn = [[], [], []]
#2 Lists
Stanza[0] = [
"We're no strangers to love",
"A full commitment's what I'm thinking of",
"I just wanna tell you how I'm feeling",
]
StanzaIn[0] = [
"You know the rules and so do I",
"You wouldn't get this from any other guy",
"Gotta make you understand",
]
Stanza[1] = [
"We've known each other for so long",
"Inside, we both know what's been going on (going on)",
"And if you ask me how I'm feeling",
]
StanzaIn[1] = [
"Your hearts been aching but you're too shy to say it",
"We know the game and we're gonna play it",
"Don't tell me you're too blind to see",
]
Stanza[2] = [
"We've known each other for so long",
"Inside, we both know what's been going on (going on)",
"I just wanna tell you how I'm feeling",
]
StanzaIn[2] = [
"Your hearts been aching but you're too shy to say it",
"We know the game and we're gonna play it",
"Gotta make you understand",
]
chorus = [
"Never gonna give you up",
"Never gonna let you down",
"Never gonna run around and desert you",
"Never gonna make you cry",
"Never gonna say goodbye",
"Never gonna tell a lie and hurt you",
]
#2 Variables
lives: int = 5
score: int = 0
#4 endGame function
# Process for ending the game
def endGame():
os.system("clear")
time.sleep(0.5)
if lives > 0:
print("You Won!")
else:
print("You Lost!")
#5 sleep function
time.sleep(0.5)
#6 print function
print()
print("You finished the game with:")
time.sleep(0.75)
print("Score: " + str(score) + "\t\t\tLives: " + str(lives))
time.sleep(2)
print()
print()
#7 abort function
os.abort()
#8 chooseOptions function
# Makes sure that nothing gets chosen twice
def chooseOptions(chosenNum: int, chosenOption: str, options: list[str], x: int) -> str:
if x == (chosenNum - 1):
return chosenOption
else:
#9 random int
returnStr = StanzaIn[random.randint(0, 2)][random.randint(0, 2)]
#10 for loop
#11 string length
for y in range(options.__len__()):
#12 if statement
if returnStr == options[y]:
returnStr = chooseOptions(chosenNum, chosenOption, options, x)
return returnStr
#13 prompt function
def prompt(stanzaNum: int, stanzaLine: int):
global lives, score
if stanzaLine < 3:
option = ["", "", "", ""]
chosenOption: str = StanzaIn[stanzaNum][stanzaLine]
chosenNum = random.randint(1, 4)
for x in range(4):
option[x] = chooseOptions(chosenNum, chosenOption, option, x)
#14 clear console
os.system("clear")
print(Stanza[stanzaNum][stanzaLine])
print()
time.sleep(1)
print("Option 1: ", option[0])
time.sleep(0.7)
print("Option 2: ", option[1])
time.sleep(0.7)
print("Option 3: ", option[2])
time.sleep(0.7)
print("Option 4: ", option[3])
print()
time.sleep(0.4)
#15 input
humInput = int(input("Option: "))
if humInput == chosenNum:
#16 increment
score += 100
return
else:
#17 decrement
lives -= 1
score -= 100
if lives > 0:
#18 recursive function
prompt(stanzaNum, stanzaLine)
else:
endGame()
else:
os.system("clear")
for i in chorus:
print(i)
time.sleep(1.3)
time.sleep(2)
os.system("clear")
print("Welcome to Song Quiz")
time.sleep(2)
print("In this game you will be given a line of a song")
time.sleep(2)
print("Your job is to respond with the correct option number")
time.sleep(3)
print("The song will be:\n\tNever Gonna Give You Up\n\tby Rick Astley")
time.sleep(2)
print("Good Luck!")
time.sleep(2)
#19 for loop
for x in range(3):
os.system("clear")
time.sleep(0.1)
#20 for loop
for y in range(4):
prompt(x, y)
endGame()