generated from Code-Institute-Org/python-essentials-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
72 lines (59 loc) · 1.95 KB
/
run.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
"""Run a quiz game via a CLI"""
from time import sleep
from html import unescape
from keywords import Keywords
from tokens import initial_token_setup
from matrix import matrix_block
from user_name import User
from quiz import quiz
from validate_yn import validate_yes_no
from prints import yellow_print, cyan_print, print_intro
def introduction_to_quiz():
"""Print initial welcome strings and allow user to input username
---
Returns:
object: A `User` instance
"""
print(f"\n{80*'='}")
print("\nWelcome!\nAre you clued up enough on code and computers?")
print("Think you have the knowledge to go all the way?")
print("Let's see how you do! First, introduce yourself.\n")
new_user = User()
print(f"\nWelcome, {new_user.user_name}!")
return new_user
# * section to run once when program started
# * user's name will be unchangeable
# * introduction will not run on replay
# region initial setup
print_intro()
sleep(2)
cyan_print("Computer Literate Investigator".center(80))
cyan_print(f"{'=' * len('Computer Literate Investigator')}".center(80))
matrix_block()
cyan_print("Configuring program...")
sleep(.5)
yellow_print("Initializing Active:Personnel:Inquisitor...")
easy_token, medium_token, hard_token = (initial_token_setup())
current_tokens = (easy_token, medium_token, hard_token)
sleep(.5)
yellow_print(
"Engaging Automated:Neuro:Solution:Work:Experimentation:"
"Resources..."
)
sleep(.5)
cyan_print("Configuration complete...")
matrix_block()
user = introduction_to_quiz()
Keywords.help_info(True)
# endregion
quiz(user.user_name, current_tokens)
while validate_yes_no("Play again?"):
quiz(user.user_name, current_tokens, False)
print("")
matrix_block(7)
print("\n" * 2)
print(f"{'=' * 15} Thanks for playing! {'=' * 15}".center(80))
print(f"|{' ' * 10}Questions generated by opentdb.com{' ' * 9}|".center(80))
print(unescape(f"{'=' * 20} © DaveyJH {'=' * 20}").center(80))
print("\n" * 2)
matrix_block(7)