This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstellation_talents_img.py
79 lines (52 loc) · 2.05 KB
/
constellation_talents_img.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
from base.image_generator import ImageGenerator
from base.resource_manager import ResourceManager
from sys import exit, argv
from json import load, dump
'''
CLI SCRIPT
_____________________________________
arg to passed: 1
Allowed:
talents
constellations
Example:
python3 constellation_talents_img.py talents
Result:
Generates and stores images in images/characters/character_name/
'''
def main():
rm = ResourceManager()
im = ImageGenerator(rm)
characters = rm.genpath('data',rm.search('character',rm.goto("data").get('files')))
print(characters)
with open(characters, 'r') as f:
data = load(f)
arg_passed = ''
if len(argv) > 1:
arg_passed = argv[1]
if arg_passed != '':
if arg_passed in ['talents', 'constellations']:
for char in data:
path = rm.genpath("images/characters", rm.search(char, rm.goto('images/characters').get('folders')))
if path.split('/')[-1] == 'None':
pass
else:
text_list = []
image_list = []
if arg_passed == 'talents':
for i in data[char]['talents']:
text_list.append(i['name'])
image_list.append(i['icon'])
if arg_passed == 'constellations':
for i in data[char]['constellations']:
text_list.append(data[char]['constellations'][i]['name'])
image_list.append(data[char]['constellations'][i]['icon'])
if len(text_list) > 0 and len(image_list) > 0:
img = im.create_image(image_list, text_list, True, filename=arg_passed+'.png', filepath=path)
print(f'Generated {arg_passed} for character {char}\nSaved in {path}')
else:
exit('Argument not supported!')
else:
exit('No arguments passed')
if __name__ == '__main__':
main()