-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
56 lines (50 loc) · 1.32 KB
/
config.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
import os
import json
KEYS = None
TEMP_DIR = None
AUTHOR = None
LEVEL = None
RANDOM = None
SAME = None
ONGEKI = None
ONGEKI_KEYS = None
def init_config_file(file_path='config.json'):
global KEYS, TEMP_DIR, AUTHOR, LEVEL, RANDOM, SAME, ONGEKI, ONGEKI_KEYS
default_content = {
"KEYS": [
[],
[],
[5, 4],
[],
[6, 5, 4, 3],
[],
[7, 6, 5, 4, 3, 2],
[8, 7, 6, 5, 4, 3, 2],
[8, 7, 6, 5, 4, 3, 2, 1]
],
"TEMP_DIR": "./tmp",
"AUTHOR": "OSU2Simai",
"LEVEL": 15,
"RANDOM": 0,
"SAME": False,
"ONGEKI": False,
"ONGEKI_KEYS": [
-16, -10, -4, 4, 10, 16
]
}
if not os.path.exists(file_path):
with open(file_path, 'w') as f:
json.dump(default_content, f, indent=2)
print(f"Config file '{file_path}' created with default content.")
else:
print(f"Config file '{file_path}' already exists.")
with open('config.json', 'r') as f:
config = json.load(f)
KEYS = config["KEYS"]
TEMP_DIR = config["TEMP_DIR"]
AUTHOR = config["AUTHOR"]
LEVEL = config["LEVEL"]
RANDOM = config["RANDOM"]
SAME = config["SAME"]
ONGEKI = config["ONGEKI"]
ONGEKI_KEYS = config["ONGEKI_KEYS"]