-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
65 lines (54 loc) · 1.32 KB
/
utils.py
File metadata and controls
65 lines (54 loc) · 1.32 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
# Save data helper
import json
import os
#filename = "character.json"
writing = False
template = {
"name": "N/A",
"inventory": {},
"hp": 0,
"stats": {
"strength": 0,
"dexterity": 0,
"consitution": 0,
"intelligence": 0,
"wisdom": 0,
"charisma": 0
},
"classes": {},
"cantrips": {},
"spells": {},
"spell-slots": {}
}
def checkForCharacter(filename):
# Checks for file if not exist make one!
if not os.path.exists('characters/'+filename+'.json'):
_file = open('characters/'+filename+'.json', 'w')
json.dump(template, _file)
_file.close()
return True
def getData(filename):
# Make it return not saved if its already being written!!
global writing
if writing == True:
return False
if checkForCharacter(filename) == True:
_file = open('characters/'+filename+'.json', 'r')
data = json.load(_file)
_file.close()
return data
else:
return False
# JSON utils not done i need to write a setData function
# Other utils
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'