talespire-encoding 1.2.2__tar.gz
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.
- talespire_encoding-1.2.2/PKG-INFO +144 -0
- talespire_encoding-1.2.2/README.md +131 -0
- talespire_encoding-1.2.2/pyproject.toml +27 -0
- talespire_encoding-1.2.2/setup.cfg +4 -0
- talespire_encoding-1.2.2/talespire_encoding.egg-info/PKG-INFO +144 -0
- talespire_encoding-1.2.2/talespire_encoding.egg-info/SOURCES.txt +17 -0
- talespire_encoding-1.2.2/talespire_encoding.egg-info/dependency_links.txt +1 -0
- talespire_encoding-1.2.2/talespire_encoding.egg-info/requires.txt +3 -0
- talespire_encoding-1.2.2/talespire_encoding.egg-info/top_level.txt +1 -0
- talespire_encoding-1.2.2/tests/test_assets.py +63 -0
- talespire_encoding-1.2.2/tests/test_creature.py +115 -0
- talespire_encoding-1.2.2/tests/test_slab.py +65 -0
- talespire_encoding-1.2.2/ts_encoding/__init__.py +17 -0
- talespire_encoding-1.2.2/ts_encoding/assets.py +152 -0
- talespire_encoding-1.2.2/ts_encoding/common.py +210 -0
- talespire_encoding-1.2.2/ts_encoding/creature_bp.py +355 -0
- talespire_encoding-1.2.2/ts_encoding/exceptions.py +31 -0
- talespire_encoding-1.2.2/ts_encoding/slab.py +258 -0
- talespire_encoding-1.2.2/ts_encoding/slab_testing.py +164 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: talespire-encoding
|
|
3
|
+
Version: 1.2.2
|
|
4
|
+
Summary: Encoding and decoding tools for TaleSpire data
|
|
5
|
+
Author: Baldrax
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Baldrax/TaleSpire-Encoding-Python
|
|
8
|
+
Project-URL: Repository, https://github.com/Baldrax/TaleSpire-Encoding-Python
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest; extra == "dev"
|
|
13
|
+
|
|
14
|
+
# TaleSpire-Encoding-Python
|
|
15
|
+
Encoding/Decoding tools for TaleSpire
|
|
16
|
+
|
|
17
|
+
This repository is just getting started.
|
|
18
|
+
|
|
19
|
+
It currently contains two encoding types:
|
|
20
|
+
- Slabs (v1, v2)
|
|
21
|
+
- Creature Blueprints (v1, v2)
|
|
22
|
+
|
|
23
|
+
## Installation:
|
|
24
|
+
With pip you can install specific releases.
|
|
25
|
+
```
|
|
26
|
+
pip install git+https://github.com/Baldrax/TaleSpire-Encoding-Python.git@vX.X.X
|
|
27
|
+
```
|
|
28
|
+
Replace the version with the version you want to install:
|
|
29
|
+
- [Latest Releases](https://github.com/Baldrax/TaleSpire-Encoding-Python/releases)
|
|
30
|
+
|
|
31
|
+
## Slabs Example usage:
|
|
32
|
+
```python
|
|
33
|
+
from ts_encoding.slab import TSSlab
|
|
34
|
+
|
|
35
|
+
example_slab_code = ("H4sIAAAAAAAACjv369xFJgZGBgYGgUWHGX9Pme/S4z7T7pZ"
|
|
36
|
+
"doRonUGwCSIKhgRFMS0L4DTwMDCcYwOIsDBDADOZLQsRB8g"
|
|
37
|
+
"xQPgOcDwD7jJ0vaAAAAA==")
|
|
38
|
+
|
|
39
|
+
slab = TSSlab()
|
|
40
|
+
slab.decode_slab(example_slab_code)
|
|
41
|
+
|
|
42
|
+
# The slab contents are now in a dictionary `slab.data`
|
|
43
|
+
from pprint import pprint
|
|
44
|
+
pprint(slab.data)
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
{'layout_count': 1,
|
|
48
|
+
'layouts': [{'instance_count': 9,
|
|
49
|
+
'instances': [{'degrees': 90.0,
|
|
50
|
+
'pos_x': 0.0,
|
|
51
|
+
'pos_y': 0.0,
|
|
52
|
+
'pos_z': 4.0},
|
|
53
|
+
{'degrees': 0.0,
|
|
54
|
+
'pos_x': 4.0,
|
|
55
|
+
'pos_y': 0.0,
|
|
56
|
+
'pos_z': 4.0},
|
|
57
|
+
{'degrees': 0.0,
|
|
58
|
+
'pos_x': 2.0,
|
|
59
|
+
'pos_y': 0.0,
|
|
60
|
+
'pos_z': 4.0},
|
|
61
|
+
{'degrees': 270.0,
|
|
62
|
+
'pos_x': 0.0,
|
|
63
|
+
'pos_y': 0.0,
|
|
64
|
+
'pos_z': 2.0},
|
|
65
|
+
{'degrees': 180.0,
|
|
66
|
+
'pos_x': 0.0,
|
|
67
|
+
'pos_y': 0.0,
|
|
68
|
+
'pos_z': 0.0},
|
|
69
|
+
{'degrees': 0.0,
|
|
70
|
+
'pos_x': 4.0,
|
|
71
|
+
'pos_y': 0.0,
|
|
72
|
+
'pos_z': 2.0},
|
|
73
|
+
{'degrees': 0.0,
|
|
74
|
+
'pos_x': 2.0,
|
|
75
|
+
'pos_y': 0.0,
|
|
76
|
+
'pos_z': 2.0},
|
|
77
|
+
{'degrees': 0.0,
|
|
78
|
+
'pos_x': 4.0,
|
|
79
|
+
'pos_y': 0.0,
|
|
80
|
+
'pos_z': 0.0},
|
|
81
|
+
{'degrees': 0.0,
|
|
82
|
+
'pos_x': 2.0,
|
|
83
|
+
'pos_y': 0.0,
|
|
84
|
+
'pos_z': 0.0}],
|
|
85
|
+
'reserved': 0,
|
|
86
|
+
'uuid': '01c3a210-94fb-449f-8c47-993eda3e7126'}],
|
|
87
|
+
'magic_num': 3520002766,
|
|
88
|
+
'num_creatures': 0,
|
|
89
|
+
'version': 2}
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
# To encode the data
|
|
93
|
+
new_slab_code = slab.encode_slab()
|
|
94
|
+
# The new_slab_code can be pasted into TaleSpire
|
|
95
|
+
|
|
96
|
+
# To create the data start a new TSSlab and edit the data dictionary.
|
|
97
|
+
# Each uuid is a new layout in the dictionary it is currently up to you
|
|
98
|
+
# to format the dictionary properly so that it encodes correctly.
|
|
99
|
+
# In future versions there may be tools to help build the layouts.
|
|
100
|
+
|
|
101
|
+
# Here is an example of creating a single grass tile
|
|
102
|
+
new_slab = TSSlab()
|
|
103
|
+
new_slab.data["layout_count"] = 1
|
|
104
|
+
grass_layout = {
|
|
105
|
+
"instance_count": 1, # The number of grass tiles
|
|
106
|
+
"instances": [{
|
|
107
|
+
"degrees": 0.0, # Yaw rotation in degrees 0-360 it is up to you to give valid values
|
|
108
|
+
"pos_x": 0.0, # X position within slab
|
|
109
|
+
"pos_y": 0.0, # Y position within slab
|
|
110
|
+
"pos_z": 0.0}], # Z position within slab
|
|
111
|
+
"reserved": 0, # Always set to 0
|
|
112
|
+
"uuid": "01c3a210-94fb-449f-8c47-993eda3e7126" # Asset UUID
|
|
113
|
+
}
|
|
114
|
+
new_slab.data["layouts"].append(grass_layout)
|
|
115
|
+
new_slab_code = new_slab.encode_slab()
|
|
116
|
+
|
|
117
|
+
# You can paste that new_slab_code into TaleSpire to see your grass tile
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Creature Blueprint Example usage:
|
|
121
|
+
```python
|
|
122
|
+
from ts_encoding.creature_bp import TSCreature
|
|
123
|
+
from pprint import pprint
|
|
124
|
+
|
|
125
|
+
url_from_TS = ("talespire://creature-blueprint/"
|
|
126
|
+
"AgAMV2hpdGUgTWVlcGxlAQAAACMAYnI6MDAwMDAwMDAwMDAwMDAwMD"
|
|
127
|
+
"AwMDAwMDAwMDQ3MDQxMDABAAAAAI49u_vNJQRDrZctETEJKR8ABAAA"
|
|
128
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgQQAAIEEAACBBAAAgQQ"
|
|
129
|
+
"AAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEA"
|
|
130
|
+
"ACBBAAAgQQAAIEEAACBBAAAA")
|
|
131
|
+
|
|
132
|
+
bp = TSCreature()
|
|
133
|
+
bp.decode_url(url_from_TS)
|
|
134
|
+
pprint(bp.data)
|
|
135
|
+
|
|
136
|
+
# You can change any of the data in `bp.data`
|
|
137
|
+
bp.data["name"] = "New Name"
|
|
138
|
+
bp.data["stats"][0] = {"max": 100.0, "value": 100.0} # Changes hp to 100
|
|
139
|
+
|
|
140
|
+
# To re-encode the data
|
|
141
|
+
new_url = bp.encode_url()
|
|
142
|
+
|
|
143
|
+
print(new_url) # You can copy/paste this new URL into TaleSpire
|
|
144
|
+
```
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# TaleSpire-Encoding-Python
|
|
2
|
+
Encoding/Decoding tools for TaleSpire
|
|
3
|
+
|
|
4
|
+
This repository is just getting started.
|
|
5
|
+
|
|
6
|
+
It currently contains two encoding types:
|
|
7
|
+
- Slabs (v1, v2)
|
|
8
|
+
- Creature Blueprints (v1, v2)
|
|
9
|
+
|
|
10
|
+
## Installation:
|
|
11
|
+
With pip you can install specific releases.
|
|
12
|
+
```
|
|
13
|
+
pip install git+https://github.com/Baldrax/TaleSpire-Encoding-Python.git@vX.X.X
|
|
14
|
+
```
|
|
15
|
+
Replace the version with the version you want to install:
|
|
16
|
+
- [Latest Releases](https://github.com/Baldrax/TaleSpire-Encoding-Python/releases)
|
|
17
|
+
|
|
18
|
+
## Slabs Example usage:
|
|
19
|
+
```python
|
|
20
|
+
from ts_encoding.slab import TSSlab
|
|
21
|
+
|
|
22
|
+
example_slab_code = ("H4sIAAAAAAAACjv369xFJgZGBgYGgUWHGX9Pme/S4z7T7pZ"
|
|
23
|
+
"doRonUGwCSIKhgRFMS0L4DTwMDCcYwOIsDBDADOZLQsRB8g"
|
|
24
|
+
"xQPgOcDwD7jJ0vaAAAAA==")
|
|
25
|
+
|
|
26
|
+
slab = TSSlab()
|
|
27
|
+
slab.decode_slab(example_slab_code)
|
|
28
|
+
|
|
29
|
+
# The slab contents are now in a dictionary `slab.data`
|
|
30
|
+
from pprint import pprint
|
|
31
|
+
pprint(slab.data)
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
{'layout_count': 1,
|
|
35
|
+
'layouts': [{'instance_count': 9,
|
|
36
|
+
'instances': [{'degrees': 90.0,
|
|
37
|
+
'pos_x': 0.0,
|
|
38
|
+
'pos_y': 0.0,
|
|
39
|
+
'pos_z': 4.0},
|
|
40
|
+
{'degrees': 0.0,
|
|
41
|
+
'pos_x': 4.0,
|
|
42
|
+
'pos_y': 0.0,
|
|
43
|
+
'pos_z': 4.0},
|
|
44
|
+
{'degrees': 0.0,
|
|
45
|
+
'pos_x': 2.0,
|
|
46
|
+
'pos_y': 0.0,
|
|
47
|
+
'pos_z': 4.0},
|
|
48
|
+
{'degrees': 270.0,
|
|
49
|
+
'pos_x': 0.0,
|
|
50
|
+
'pos_y': 0.0,
|
|
51
|
+
'pos_z': 2.0},
|
|
52
|
+
{'degrees': 180.0,
|
|
53
|
+
'pos_x': 0.0,
|
|
54
|
+
'pos_y': 0.0,
|
|
55
|
+
'pos_z': 0.0},
|
|
56
|
+
{'degrees': 0.0,
|
|
57
|
+
'pos_x': 4.0,
|
|
58
|
+
'pos_y': 0.0,
|
|
59
|
+
'pos_z': 2.0},
|
|
60
|
+
{'degrees': 0.0,
|
|
61
|
+
'pos_x': 2.0,
|
|
62
|
+
'pos_y': 0.0,
|
|
63
|
+
'pos_z': 2.0},
|
|
64
|
+
{'degrees': 0.0,
|
|
65
|
+
'pos_x': 4.0,
|
|
66
|
+
'pos_y': 0.0,
|
|
67
|
+
'pos_z': 0.0},
|
|
68
|
+
{'degrees': 0.0,
|
|
69
|
+
'pos_x': 2.0,
|
|
70
|
+
'pos_y': 0.0,
|
|
71
|
+
'pos_z': 0.0}],
|
|
72
|
+
'reserved': 0,
|
|
73
|
+
'uuid': '01c3a210-94fb-449f-8c47-993eda3e7126'}],
|
|
74
|
+
'magic_num': 3520002766,
|
|
75
|
+
'num_creatures': 0,
|
|
76
|
+
'version': 2}
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
# To encode the data
|
|
80
|
+
new_slab_code = slab.encode_slab()
|
|
81
|
+
# The new_slab_code can be pasted into TaleSpire
|
|
82
|
+
|
|
83
|
+
# To create the data start a new TSSlab and edit the data dictionary.
|
|
84
|
+
# Each uuid is a new layout in the dictionary it is currently up to you
|
|
85
|
+
# to format the dictionary properly so that it encodes correctly.
|
|
86
|
+
# In future versions there may be tools to help build the layouts.
|
|
87
|
+
|
|
88
|
+
# Here is an example of creating a single grass tile
|
|
89
|
+
new_slab = TSSlab()
|
|
90
|
+
new_slab.data["layout_count"] = 1
|
|
91
|
+
grass_layout = {
|
|
92
|
+
"instance_count": 1, # The number of grass tiles
|
|
93
|
+
"instances": [{
|
|
94
|
+
"degrees": 0.0, # Yaw rotation in degrees 0-360 it is up to you to give valid values
|
|
95
|
+
"pos_x": 0.0, # X position within slab
|
|
96
|
+
"pos_y": 0.0, # Y position within slab
|
|
97
|
+
"pos_z": 0.0}], # Z position within slab
|
|
98
|
+
"reserved": 0, # Always set to 0
|
|
99
|
+
"uuid": "01c3a210-94fb-449f-8c47-993eda3e7126" # Asset UUID
|
|
100
|
+
}
|
|
101
|
+
new_slab.data["layouts"].append(grass_layout)
|
|
102
|
+
new_slab_code = new_slab.encode_slab()
|
|
103
|
+
|
|
104
|
+
# You can paste that new_slab_code into TaleSpire to see your grass tile
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Creature Blueprint Example usage:
|
|
108
|
+
```python
|
|
109
|
+
from ts_encoding.creature_bp import TSCreature
|
|
110
|
+
from pprint import pprint
|
|
111
|
+
|
|
112
|
+
url_from_TS = ("talespire://creature-blueprint/"
|
|
113
|
+
"AgAMV2hpdGUgTWVlcGxlAQAAACMAYnI6MDAwMDAwMDAwMDAwMDAwMD"
|
|
114
|
+
"AwMDAwMDAwMDQ3MDQxMDABAAAAAI49u_vNJQRDrZctETEJKR8ABAAA"
|
|
115
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgQQAAIEEAACBBAAAgQQ"
|
|
116
|
+
"AAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEA"
|
|
117
|
+
"ACBBAAAgQQAAIEEAACBBAAAA")
|
|
118
|
+
|
|
119
|
+
bp = TSCreature()
|
|
120
|
+
bp.decode_url(url_from_TS)
|
|
121
|
+
pprint(bp.data)
|
|
122
|
+
|
|
123
|
+
# You can change any of the data in `bp.data`
|
|
124
|
+
bp.data["name"] = "New Name"
|
|
125
|
+
bp.data["stats"][0] = {"max": 100.0, "value": 100.0} # Changes hp to 100
|
|
126
|
+
|
|
127
|
+
# To re-encode the data
|
|
128
|
+
new_url = bp.encode_url()
|
|
129
|
+
|
|
130
|
+
print(new_url) # You can copy/paste this new URL into TaleSpire
|
|
131
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "talespire-encoding"
|
|
7
|
+
version = "1.2.2"
|
|
8
|
+
description = "Encoding and decoding tools for TaleSpire data"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Baldrax" }
|
|
14
|
+
]
|
|
15
|
+
dependencies = []
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
Homepage = "https://github.com/Baldrax/TaleSpire-Encoding-Python"
|
|
19
|
+
Repository = "https://github.com/Baldrax/TaleSpire-Encoding-Python"
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
dev = [
|
|
23
|
+
"pytest"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[tool.setuptools]
|
|
27
|
+
packages = ["ts_encoding"]
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: talespire-encoding
|
|
3
|
+
Version: 1.2.2
|
|
4
|
+
Summary: Encoding and decoding tools for TaleSpire data
|
|
5
|
+
Author: Baldrax
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Baldrax/TaleSpire-Encoding-Python
|
|
8
|
+
Project-URL: Repository, https://github.com/Baldrax/TaleSpire-Encoding-Python
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest; extra == "dev"
|
|
13
|
+
|
|
14
|
+
# TaleSpire-Encoding-Python
|
|
15
|
+
Encoding/Decoding tools for TaleSpire
|
|
16
|
+
|
|
17
|
+
This repository is just getting started.
|
|
18
|
+
|
|
19
|
+
It currently contains two encoding types:
|
|
20
|
+
- Slabs (v1, v2)
|
|
21
|
+
- Creature Blueprints (v1, v2)
|
|
22
|
+
|
|
23
|
+
## Installation:
|
|
24
|
+
With pip you can install specific releases.
|
|
25
|
+
```
|
|
26
|
+
pip install git+https://github.com/Baldrax/TaleSpire-Encoding-Python.git@vX.X.X
|
|
27
|
+
```
|
|
28
|
+
Replace the version with the version you want to install:
|
|
29
|
+
- [Latest Releases](https://github.com/Baldrax/TaleSpire-Encoding-Python/releases)
|
|
30
|
+
|
|
31
|
+
## Slabs Example usage:
|
|
32
|
+
```python
|
|
33
|
+
from ts_encoding.slab import TSSlab
|
|
34
|
+
|
|
35
|
+
example_slab_code = ("H4sIAAAAAAAACjv369xFJgZGBgYGgUWHGX9Pme/S4z7T7pZ"
|
|
36
|
+
"doRonUGwCSIKhgRFMS0L4DTwMDCcYwOIsDBDADOZLQsRB8g"
|
|
37
|
+
"xQPgOcDwD7jJ0vaAAAAA==")
|
|
38
|
+
|
|
39
|
+
slab = TSSlab()
|
|
40
|
+
slab.decode_slab(example_slab_code)
|
|
41
|
+
|
|
42
|
+
# The slab contents are now in a dictionary `slab.data`
|
|
43
|
+
from pprint import pprint
|
|
44
|
+
pprint(slab.data)
|
|
45
|
+
|
|
46
|
+
"""
|
|
47
|
+
{'layout_count': 1,
|
|
48
|
+
'layouts': [{'instance_count': 9,
|
|
49
|
+
'instances': [{'degrees': 90.0,
|
|
50
|
+
'pos_x': 0.0,
|
|
51
|
+
'pos_y': 0.0,
|
|
52
|
+
'pos_z': 4.0},
|
|
53
|
+
{'degrees': 0.0,
|
|
54
|
+
'pos_x': 4.0,
|
|
55
|
+
'pos_y': 0.0,
|
|
56
|
+
'pos_z': 4.0},
|
|
57
|
+
{'degrees': 0.0,
|
|
58
|
+
'pos_x': 2.0,
|
|
59
|
+
'pos_y': 0.0,
|
|
60
|
+
'pos_z': 4.0},
|
|
61
|
+
{'degrees': 270.0,
|
|
62
|
+
'pos_x': 0.0,
|
|
63
|
+
'pos_y': 0.0,
|
|
64
|
+
'pos_z': 2.0},
|
|
65
|
+
{'degrees': 180.0,
|
|
66
|
+
'pos_x': 0.0,
|
|
67
|
+
'pos_y': 0.0,
|
|
68
|
+
'pos_z': 0.0},
|
|
69
|
+
{'degrees': 0.0,
|
|
70
|
+
'pos_x': 4.0,
|
|
71
|
+
'pos_y': 0.0,
|
|
72
|
+
'pos_z': 2.0},
|
|
73
|
+
{'degrees': 0.0,
|
|
74
|
+
'pos_x': 2.0,
|
|
75
|
+
'pos_y': 0.0,
|
|
76
|
+
'pos_z': 2.0},
|
|
77
|
+
{'degrees': 0.0,
|
|
78
|
+
'pos_x': 4.0,
|
|
79
|
+
'pos_y': 0.0,
|
|
80
|
+
'pos_z': 0.0},
|
|
81
|
+
{'degrees': 0.0,
|
|
82
|
+
'pos_x': 2.0,
|
|
83
|
+
'pos_y': 0.0,
|
|
84
|
+
'pos_z': 0.0}],
|
|
85
|
+
'reserved': 0,
|
|
86
|
+
'uuid': '01c3a210-94fb-449f-8c47-993eda3e7126'}],
|
|
87
|
+
'magic_num': 3520002766,
|
|
88
|
+
'num_creatures': 0,
|
|
89
|
+
'version': 2}
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
# To encode the data
|
|
93
|
+
new_slab_code = slab.encode_slab()
|
|
94
|
+
# The new_slab_code can be pasted into TaleSpire
|
|
95
|
+
|
|
96
|
+
# To create the data start a new TSSlab and edit the data dictionary.
|
|
97
|
+
# Each uuid is a new layout in the dictionary it is currently up to you
|
|
98
|
+
# to format the dictionary properly so that it encodes correctly.
|
|
99
|
+
# In future versions there may be tools to help build the layouts.
|
|
100
|
+
|
|
101
|
+
# Here is an example of creating a single grass tile
|
|
102
|
+
new_slab = TSSlab()
|
|
103
|
+
new_slab.data["layout_count"] = 1
|
|
104
|
+
grass_layout = {
|
|
105
|
+
"instance_count": 1, # The number of grass tiles
|
|
106
|
+
"instances": [{
|
|
107
|
+
"degrees": 0.0, # Yaw rotation in degrees 0-360 it is up to you to give valid values
|
|
108
|
+
"pos_x": 0.0, # X position within slab
|
|
109
|
+
"pos_y": 0.0, # Y position within slab
|
|
110
|
+
"pos_z": 0.0}], # Z position within slab
|
|
111
|
+
"reserved": 0, # Always set to 0
|
|
112
|
+
"uuid": "01c3a210-94fb-449f-8c47-993eda3e7126" # Asset UUID
|
|
113
|
+
}
|
|
114
|
+
new_slab.data["layouts"].append(grass_layout)
|
|
115
|
+
new_slab_code = new_slab.encode_slab()
|
|
116
|
+
|
|
117
|
+
# You can paste that new_slab_code into TaleSpire to see your grass tile
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Creature Blueprint Example usage:
|
|
121
|
+
```python
|
|
122
|
+
from ts_encoding.creature_bp import TSCreature
|
|
123
|
+
from pprint import pprint
|
|
124
|
+
|
|
125
|
+
url_from_TS = ("talespire://creature-blueprint/"
|
|
126
|
+
"AgAMV2hpdGUgTWVlcGxlAQAAACMAYnI6MDAwMDAwMDAwMDAwMDAwMD"
|
|
127
|
+
"AwMDAwMDAwMDQ3MDQxMDABAAAAAI49u_vNJQRDrZctETEJKR8ABAAA"
|
|
128
|
+
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgQQAAIEEAACBBAAAgQQ"
|
|
129
|
+
"AAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEA"
|
|
130
|
+
"ACBBAAAgQQAAIEEAACBBAAAA")
|
|
131
|
+
|
|
132
|
+
bp = TSCreature()
|
|
133
|
+
bp.decode_url(url_from_TS)
|
|
134
|
+
pprint(bp.data)
|
|
135
|
+
|
|
136
|
+
# You can change any of the data in `bp.data`
|
|
137
|
+
bp.data["name"] = "New Name"
|
|
138
|
+
bp.data["stats"][0] = {"max": 100.0, "value": 100.0} # Changes hp to 100
|
|
139
|
+
|
|
140
|
+
# To re-encode the data
|
|
141
|
+
new_url = bp.encode_url()
|
|
142
|
+
|
|
143
|
+
print(new_url) # You can copy/paste this new URL into TaleSpire
|
|
144
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
talespire_encoding.egg-info/PKG-INFO
|
|
4
|
+
talespire_encoding.egg-info/SOURCES.txt
|
|
5
|
+
talespire_encoding.egg-info/dependency_links.txt
|
|
6
|
+
talespire_encoding.egg-info/requires.txt
|
|
7
|
+
talespire_encoding.egg-info/top_level.txt
|
|
8
|
+
tests/test_assets.py
|
|
9
|
+
tests/test_creature.py
|
|
10
|
+
tests/test_slab.py
|
|
11
|
+
ts_encoding/__init__.py
|
|
12
|
+
ts_encoding/assets.py
|
|
13
|
+
ts_encoding/common.py
|
|
14
|
+
ts_encoding/creature_bp.py
|
|
15
|
+
ts_encoding/exceptions.py
|
|
16
|
+
ts_encoding/slab.py
|
|
17
|
+
ts_encoding/slab_testing.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ts_encoding
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
|
|
3
|
+
from tests.conftest import find_talespire_path
|
|
4
|
+
from ts_encoding import assets
|
|
5
|
+
|
|
6
|
+
# These tests should ensure that the index.json data stays consistent.
|
|
7
|
+
TEST_CASES = [
|
|
8
|
+
pytest.param(
|
|
9
|
+
{
|
|
10
|
+
"uuid": "01c3a210-94fb-449f-8c47-993eda3e7126",
|
|
11
|
+
"assert": {
|
|
12
|
+
"Id": "01c3a210-94fb-449f-8c47-993eda3e7126",
|
|
13
|
+
"Name": "Grass - Lush",
|
|
14
|
+
"ColliderBoundsBound": {"m_Center": {"x": 1.0, "y": 0.25, "z": 1.0},
|
|
15
|
+
"m_Extent": {"x": 1.0, "y": 0.25, "z": 1.0}}
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
id="Tile: Grass - Lush"
|
|
20
|
+
),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
LIBRARY = None
|
|
24
|
+
|
|
25
|
+
@pytest.fixture(scope="session")
|
|
26
|
+
def talespire_path():
|
|
27
|
+
path = find_talespire_path()
|
|
28
|
+
|
|
29
|
+
if not path:
|
|
30
|
+
pytest.skip("TaleSpire install not found")
|
|
31
|
+
|
|
32
|
+
return path
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_index_loading(talespire_path):
|
|
36
|
+
index_paths = assets.get_asset_index_paths(talespire_path)
|
|
37
|
+
|
|
38
|
+
passed = True
|
|
39
|
+
|
|
40
|
+
for path in index_paths:
|
|
41
|
+
if passed:
|
|
42
|
+
passed = path.exists()
|
|
43
|
+
|
|
44
|
+
assert passed
|
|
45
|
+
|
|
46
|
+
def test_library_load(talespire_path):
|
|
47
|
+
global LIBRARY
|
|
48
|
+
LIBRARY = assets.TSAssetLib(talespire_path)
|
|
49
|
+
|
|
50
|
+
assert LIBRARY is not None
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def assert_data(data: dict, assert_dict: dict):
|
|
54
|
+
for key, value in assert_dict.items():
|
|
55
|
+
assert data[key] == value
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pytest.mark.parametrize("input_data", TEST_CASES)
|
|
59
|
+
def test_asset_dict(input_data):
|
|
60
|
+
global LIBRARY
|
|
61
|
+
if LIBRARY is None:
|
|
62
|
+
pytest.skip("Library not loaded")
|
|
63
|
+
assert_data(LIBRARY.asset(input_data["uuid"]).asset_dict, input_data["assert"])
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from ts_encoding.creature_bp import TSCreature
|
|
3
|
+
|
|
4
|
+
# Blueprint v1 samples are from the 5e Database
|
|
5
|
+
# https://talestavern.com/talespire-5e-creature-blueprint-database-2/
|
|
6
|
+
|
|
7
|
+
TEST_CASES = [
|
|
8
|
+
pytest.param(
|
|
9
|
+
{
|
|
10
|
+
"url": "talespire://creature-blueprint"
|
|
11
|
+
"/AQAHQWJvbGV0aAFKbKpDJxNtSIiDNlZLt1zmAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWEMAAFhDAACIQQAA"
|
|
12
|
+
"iEEAACBBAAAgQgAAoEAAAKBAAACAvwAAgL8AAABAAAAAQAAAgEAAAIBAAAAAQAAAAEAAAIBAAACAQAAAAA==",
|
|
13
|
+
"assert": {
|
|
14
|
+
"name": "Aboleth",
|
|
15
|
+
"flying_enabled": False,
|
|
16
|
+
"morph_ids": [(None, "4a6caa43-2713-6d48-8883-36564bb75ce6")],
|
|
17
|
+
"stats": {0: (216.0, 216.0), 8: (4.0, 4.0)}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
id="Aboleth from the 5e Database - bp(v1)"
|
|
21
|
+
),
|
|
22
|
+
pytest.param(
|
|
23
|
+
{
|
|
24
|
+
"url": "talespire://creature-blueprint"
|
|
25
|
+
"/AQALV2F0ZXIgV2VpcmQBiP+KHsGG30W_tm3GProItwAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMZCAADGQ"
|
|
26
|
+
"gAAUEEAAFBBAAAAAAAAcEIAAEBAAABAQAAAQEAAAEBAAACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
|
|
27
|
+
"assert": {
|
|
28
|
+
"name": "Water Weird",
|
|
29
|
+
"flying_enabled": False,
|
|
30
|
+
"morph_ids": [(None, "88ff8a1e-c186-df45-bfb6-6dc63eba08b7")],
|
|
31
|
+
"stats": {0: (99.0, 99.0), 8: (0.0, 0.0)}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
id="Water Weird from the 5e Database - bp(v1)"
|
|
35
|
+
),
|
|
36
|
+
pytest.param(
|
|
37
|
+
{
|
|
38
|
+
"url": "talespire://creature-blueprint"
|
|
39
|
+
"/AgD_AQAAACMAYnI6MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwZjY2ZjQxMDABAAAAAIkMFyRfeChLqZlY6EwXNW0"
|
|
40
|
+
"ABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2QgAA9kIAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAg"
|
|
41
|
+
"QQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAyEIAAEhDAAAA",
|
|
42
|
+
"assert": {
|
|
43
|
+
"name": "",
|
|
44
|
+
"flying_enabled": False,
|
|
45
|
+
"morph_ids": [(0, "890c1724-5f78-284b-a999-58e84c17356d")],
|
|
46
|
+
"stats": {0: (123.0, 123.0), 8: (100.0, 200.0)}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
id="Orange Meeple Unnamed - bp(v2)"
|
|
50
|
+
),
|
|
51
|
+
pytest.param(
|
|
52
|
+
{
|
|
53
|
+
"url": "talespire://creature-blueprint"
|
|
54
|
+
"/AgAKWWVsbG93IE1hbgEAAAAjAGJyOjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMGZhNmY0MTAwAQAAAADS5CBwM3"
|
|
55
|
+
"vXRbkNwoZxgJ0UAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABEIAAEhCAAAgQQAAIEEAACBBAAAgQQAAI"
|
|
56
|
+
"EEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAAKBAAABwQQUAAaYlZoACj_5LujBOvpVTbAU=",
|
|
57
|
+
"assert": {
|
|
58
|
+
"name": "Yellow Man",
|
|
59
|
+
"flying_enabled": True,
|
|
60
|
+
"explicitly_hidden": False,
|
|
61
|
+
"torch_enabled": True,
|
|
62
|
+
"active_emote_ids": ["a6256680-028f-fe4b-ba30-4ebe95536c05"],
|
|
63
|
+
"morph_ids": [(0, "d2e42070-337b-d745-b90d-c28671809d14")],
|
|
64
|
+
"stats": {0: (33.0, 50.0), 8: (5.0, 15.0)}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
id="Yellow Meeple named, flying, torch, prone - bp(v2)"
|
|
68
|
+
),
|
|
69
|
+
pytest.param(
|
|
70
|
+
{
|
|
71
|
+
"url": "talespire://creature-blueprint"
|
|
72
|
+
"/AgAKQWxsIE1lZXBsZQgAAAAjAGJyOjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMGZmNmY0MTAwIwBicjowMDAwMDA"
|
|
73
|
+
"wMDAwMDAwMDAwMDAwMDAwMDBlZjZmNDEwMCMAYnI6MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDI3MDQxMDAjAGJy"
|
|
74
|
+
"OjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA0NzA0MTAwIwBicjowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDBlMjZmND"
|
|
75
|
+
"EwMCMAYnI6MDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwZjY2ZjQxMDAjAGJyOjAwMDAwMDAwMDAwMDAwMDAwMDAwMDAw"
|
|
76
|
+
"MGY4NmY0MTAwIwBicjowMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDBmYTZmNDEwMAgAAAAAlalY9W4iP0SsV_AIAIGtP"
|
|
77
|
+
"AEAAAC0SjjafjeGSogeqBD+9u58AgAAADBr214IKEhFjFU2QS5z9IsDAAAAjj27+80lBEOtly0RMQkpHwQAAADbolu"
|
|
78
|
+
"04318RYHZE1DqSF1dBQAAAIkMFyRfeChLqZlY6EwXNW0GAAAAuZTaylP3y0+ziTodox+gkgcAAADS5CBwM3vXRbkNw"
|
|
79
|
+
"oZxgJ0UAwRBEARBEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAg"
|
|
80
|
+
"QQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAAA==",
|
|
81
|
+
"assert": {
|
|
82
|
+
"name": "All Meeple"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
id="All Meeples as Morphs - bp(v2)"
|
|
86
|
+
),
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def assert_data(data: dict, assert_dict: dict):
|
|
91
|
+
for key, value in assert_dict.items():
|
|
92
|
+
if key == "stats":
|
|
93
|
+
for stat_index, stat_values in value.items():
|
|
94
|
+
data_stat = data["stats"][stat_index]
|
|
95
|
+
assert (data_stat["value"], data_stat["max"]) == stat_values
|
|
96
|
+
else:
|
|
97
|
+
assert data[key] == value
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@pytest.mark.parametrize("input_data", TEST_CASES)
|
|
101
|
+
def test_decode(input_data):
|
|
102
|
+
# Test that various parameters decode as expected.
|
|
103
|
+
bp = TSCreature()
|
|
104
|
+
bp.decode_url(input_data["url"])
|
|
105
|
+
assert_data(bp.data, input_data["assert"])
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@pytest.mark.parametrize("input_data", TEST_CASES)
|
|
109
|
+
def test_encode(input_data):
|
|
110
|
+
# Test that re-encoding the data results in the same URL
|
|
111
|
+
bp = TSCreature()
|
|
112
|
+
original_url = input_data["url"]
|
|
113
|
+
bp.decode_url(original_url)
|
|
114
|
+
new_url = bp.encode_url()
|
|
115
|
+
assert new_url == original_url
|