dfpyre 0.7.1__py3-none-any.whl → 0.7.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dfpyre might be problematic. Click here for more details.
- dfpyre/actiondump.py +77 -77
- dfpyre/items.py +372 -372
- dfpyre/pyre.py +457 -457
- dfpyre/scriptgen.py +152 -152
- dfpyre/style.py +21 -21
- dfpyre/util.py +28 -28
- {dfpyre-0.7.1.dist-info → dfpyre-0.7.3.dist-info}/LICENSE +21 -21
- {dfpyre-0.7.1.dist-info → dfpyre-0.7.3.dist-info}/METADATA +2 -2
- dfpyre-0.7.3.dist-info/RECORD +12 -0
- dfpyre-0.7.1.dist-info/RECORD +0 -12
- {dfpyre-0.7.1.dist-info → dfpyre-0.7.3.dist-info}/WHEEL +0 -0
dfpyre/actiondump.py
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import json
|
|
3
|
-
from dfpyre.util import warn
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ACTIONDUMP_PATH = os.path.join(os.path.dirname(__file__), 'data/actiondump_min.json')
|
|
7
|
-
|
|
8
|
-
CODEBLOCK_NAME_LOOKUP = {
|
|
9
|
-
'PLAYER ACTION': 'player_action',
|
|
10
|
-
'ENTITY ACTION': 'entity_action',
|
|
11
|
-
'GAME ACTION': 'game_action',
|
|
12
|
-
'SET VARIABLE': 'set_var',
|
|
13
|
-
'IF PLAYER': 'if_player',
|
|
14
|
-
'IF ENTITY': 'if_entity',
|
|
15
|
-
'IF GAME': 'if_game',
|
|
16
|
-
'IF VARIABLE': 'if_var',
|
|
17
|
-
'REPEAT': 'repeat',
|
|
18
|
-
'SELECT OBJECT': 'select_obj',
|
|
19
|
-
'CONTROL': 'control',
|
|
20
|
-
'PLAYER EVENT': 'event',
|
|
21
|
-
'ENTITY EVENT': 'entity_event',
|
|
22
|
-
'FUNCTION': 'func',
|
|
23
|
-
'CALL FUNCTION': 'call_func',
|
|
24
|
-
'PROCESS': 'process',
|
|
25
|
-
'START PROCESS': 'start_process',
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def get_action_tags(action_data: dict) -> list[dict]:
|
|
30
|
-
action_tags = []
|
|
31
|
-
for tag_data in action_data['tags']:
|
|
32
|
-
options = [o['name'] for o in tag_data['options']]
|
|
33
|
-
converted_tag_data = {
|
|
34
|
-
'name': tag_data['name'],
|
|
35
|
-
'options': options,
|
|
36
|
-
'default': tag_data['defaultOption'],
|
|
37
|
-
'slot': tag_data['slot']
|
|
38
|
-
}
|
|
39
|
-
action_tags.append(converted_tag_data)
|
|
40
|
-
return action_tags
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
def parse_actiondump():
|
|
44
|
-
codeblock_data = {n: {} for n in CODEBLOCK_NAME_LOOKUP.values()}
|
|
45
|
-
codeblock_data['else'] = {'tags': []}
|
|
46
|
-
|
|
47
|
-
if not os.path.exists(ACTIONDUMP_PATH):
|
|
48
|
-
warn('data.json not found -- Item tags and error checking will not work.')
|
|
49
|
-
return {}, set()
|
|
50
|
-
|
|
51
|
-
with open(ACTIONDUMP_PATH, 'r', encoding='utf-8') as f:
|
|
52
|
-
actiondump = json.loads(f.read())
|
|
53
|
-
|
|
54
|
-
for action_data in actiondump['actions']:
|
|
55
|
-
action_tags = get_action_tags(action_data)
|
|
56
|
-
parsed_action_data = {'tags': action_tags}
|
|
57
|
-
if dep_note := action_data['icon']['deprecatedNote']:
|
|
58
|
-
parsed_action_data['deprecatedNote'] = ' '.join(dep_note)
|
|
59
|
-
|
|
60
|
-
codeblock_name = CODEBLOCK_NAME_LOOKUP[action_data['codeblockName']]
|
|
61
|
-
codeblock_data[codeblock_name][action_data['name']] = parsed_action_data
|
|
62
|
-
if aliases := action_data['aliases']:
|
|
63
|
-
alias_data = parsed_action_data.copy()
|
|
64
|
-
alias_data['alias'] = action_data['name']
|
|
65
|
-
for alias in aliases:
|
|
66
|
-
codeblock_data[codeblock_name][alias] = alias_data
|
|
67
|
-
|
|
68
|
-
return codeblock_data
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def get_default_tags(codeblock_type: str|None, codeblock_action: str|None) -> dict[str, str]:
|
|
72
|
-
if codeblock_type is None or codeblock_action is None:
|
|
73
|
-
return {}
|
|
74
|
-
return {t['name']: t['default'] for t in CODEBLOCK_DATA[codeblock_type][codeblock_action]['tags']}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
CODEBLOCK_DATA = parse_actiondump()
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
from dfpyre.util import warn
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
ACTIONDUMP_PATH = os.path.join(os.path.dirname(__file__), 'data/actiondump_min.json')
|
|
7
|
+
|
|
8
|
+
CODEBLOCK_NAME_LOOKUP = {
|
|
9
|
+
'PLAYER ACTION': 'player_action',
|
|
10
|
+
'ENTITY ACTION': 'entity_action',
|
|
11
|
+
'GAME ACTION': 'game_action',
|
|
12
|
+
'SET VARIABLE': 'set_var',
|
|
13
|
+
'IF PLAYER': 'if_player',
|
|
14
|
+
'IF ENTITY': 'if_entity',
|
|
15
|
+
'IF GAME': 'if_game',
|
|
16
|
+
'IF VARIABLE': 'if_var',
|
|
17
|
+
'REPEAT': 'repeat',
|
|
18
|
+
'SELECT OBJECT': 'select_obj',
|
|
19
|
+
'CONTROL': 'control',
|
|
20
|
+
'PLAYER EVENT': 'event',
|
|
21
|
+
'ENTITY EVENT': 'entity_event',
|
|
22
|
+
'FUNCTION': 'func',
|
|
23
|
+
'CALL FUNCTION': 'call_func',
|
|
24
|
+
'PROCESS': 'process',
|
|
25
|
+
'START PROCESS': 'start_process',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_action_tags(action_data: dict) -> list[dict]:
|
|
30
|
+
action_tags = []
|
|
31
|
+
for tag_data in action_data['tags']:
|
|
32
|
+
options = [o['name'] for o in tag_data['options']]
|
|
33
|
+
converted_tag_data = {
|
|
34
|
+
'name': tag_data['name'],
|
|
35
|
+
'options': options,
|
|
36
|
+
'default': tag_data['defaultOption'],
|
|
37
|
+
'slot': tag_data['slot']
|
|
38
|
+
}
|
|
39
|
+
action_tags.append(converted_tag_data)
|
|
40
|
+
return action_tags
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def parse_actiondump():
|
|
44
|
+
codeblock_data = {n: {} for n in CODEBLOCK_NAME_LOOKUP.values()}
|
|
45
|
+
codeblock_data['else'] = {'tags': []}
|
|
46
|
+
|
|
47
|
+
if not os.path.exists(ACTIONDUMP_PATH):
|
|
48
|
+
warn('data.json not found -- Item tags and error checking will not work.')
|
|
49
|
+
return {}, set()
|
|
50
|
+
|
|
51
|
+
with open(ACTIONDUMP_PATH, 'r', encoding='utf-8') as f:
|
|
52
|
+
actiondump = json.loads(f.read())
|
|
53
|
+
|
|
54
|
+
for action_data in actiondump['actions']:
|
|
55
|
+
action_tags = get_action_tags(action_data)
|
|
56
|
+
parsed_action_data = {'tags': action_tags}
|
|
57
|
+
if dep_note := action_data['icon']['deprecatedNote']:
|
|
58
|
+
parsed_action_data['deprecatedNote'] = ' '.join(dep_note)
|
|
59
|
+
|
|
60
|
+
codeblock_name = CODEBLOCK_NAME_LOOKUP[action_data['codeblockName']]
|
|
61
|
+
codeblock_data[codeblock_name][action_data['name']] = parsed_action_data
|
|
62
|
+
if aliases := action_data['aliases']:
|
|
63
|
+
alias_data = parsed_action_data.copy()
|
|
64
|
+
alias_data['alias'] = action_data['name']
|
|
65
|
+
for alias in aliases:
|
|
66
|
+
codeblock_data[codeblock_name][alias] = alias_data
|
|
67
|
+
|
|
68
|
+
return codeblock_data
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def get_default_tags(codeblock_type: str|None, codeblock_action: str|None) -> dict[str, str]:
|
|
72
|
+
if codeblock_type is None or codeblock_action is None:
|
|
73
|
+
return {}
|
|
74
|
+
return {t['name']: t['default'] for t in CODEBLOCK_DATA[codeblock_type][codeblock_action]['tags']}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
CODEBLOCK_DATA = parse_actiondump()
|