-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.py
More file actions
27 lines (24 loc) · 735 Bytes
/
util.py
File metadata and controls
27 lines (24 loc) · 735 Bytes
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
import re
class Util:
def is_valid_input(user_input, pattern):
try:
if re.search(pattern, user_input, re.I):
return True
except:
return False
def printTitle(str):
str = " %s " % str
hor = len(str) * "-"
pls = "+"
ver = "|"
return "{}{}{}\n{}{}{}\n{}{}{}\n".format(pls, hor, pls, ver, str, ver, pls, hor, pls)
def render_health_bar(person):
str = ""
# Always ten cells
health_percentage = round(person.health / person.MAX_HEALTH * 10)
for x in range(0, 10):
if health_percentage > x:
str += "[•]"
else:
str += "[ ]"
return str