-
Notifications
You must be signed in to change notification settings - Fork 2
/
RPG_IO.py
124 lines (99 loc) · 3.1 KB
/
RPG_IO.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
import time
def print_logo(str):
for letter in str:
print(letter, end="")
time.sleep(.005177)
print()
def print_title(str):
for letter in str:
print(letter, end="")
time.sleep(.02)
print()
def print_real_slow(str):
for letter in str:
print(letter, end="")
time.sleep(.6)
print()
def print_slow(str):
for letter in str:
print(letter, end="")
time.sleep(.06)
print()
def putin(string_msg, typ, alternative_text="Enter proper choice"):
"""
The function makes sure the user inputs the proper value and persists until the user gives a proper value
:param string_msg: Storing the input message prompt.
:param typ: What type of input is to be expected from the user. Either "int" or "str".
:param alternative_text: The message to be displayed when wrong input is given.
:return:
"""
ans = input(string_msg)
if typ == 'int':
while True:
if not ans.isdigit():
print_slow(alternative_text)
ans = input(string_msg)
else:
break
return ans
elif typ == 'str':
while True:
if not ans.isalpha():
print_slow(alternative_text)
ans = input(string_msg)
else:
break
return ans
# functions for colored text output - regular fashion
def prRed(stmt): print("\033[91m {}\033[00m".format(stmt))
def prGreen(stmt): print("\033[92m {}\033[00m".format(stmt))
def prYellow(stmt): print("\033[93m {}\033[00m".format(stmt))
def prLightPurple(stmt): print("\033[94m {}\033[00m".format(stmt))
def prPurple(stmt): print("\033[95m {}\033[00m".format(stmt))
def prCyan(stmt): print("\033[96m {}\033[00m".format(stmt))
def prLightGray(stmt): print("\033[97m {}\033[00m".format(stmt))
def prBlack(stmt): print("\033[98m {}\033[00m".format(stmt))
# colored text in slow-fashion
def prSloRed(stmt):
for letter in stmt:
print("\033[91m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
def prSloGreen(stmt):
for letter in stmt:
print("\033[92m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
def prSloYellow(stmt):
for letter in stmt:
print("\033[93m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
time.sleep(1)
def prSloLightPurple(stmt):
for letter in stmt:
print("\033[94m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
time.sleep(1)
def prSloPurple(stmt):
for letter in stmt:
print("\033[95m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
def prSloCyan(stmt):
for letter in stmt:
print("\033[96m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
time.sleep(1)
def prSloLightGray(stmt):
for letter in stmt:
print("\033[97m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()
def prSloBlack(stmt):
for letter in stmt:
print("\033[98m {}\033[00m".format(letter), end="")
time.sleep(.06)
print()