Skip to main content

Encoding and decoding tools for TaleSpire data

Project description

TaleSpire Encoding

This is a Python package for encoding and decoding TaleSpire data.

It currently supports the following encoding types:

  • Slabs (v1, v2)
  • Creature Blueprints (v1, v2)
  • Stats Links (v1)

It also contains tools for reading in TaleSpire Assets. This requires a path to the installation location of TaleSpire on your machine.

Installation:

Install the latest release from PyPI:

pip install talespire-encoding

To upgrade to the latest version:

pip install --upgrade talespire-encoding

To install a specific version:

pip install talespire-encoding==1.2.3

Usage:

The Python import package is ts_encoding

# Core API
from ts_encoding import TSSlab, TSCreature, TSStatsLink, TSAssetLib

Slabs Example usage:

from ts_encoding import TSSlab

example_slab_code = ("H4sIAAAAAAAACjv369xFJgZGBgYGgUWHGX9Pme/S4z7T7pZ"
                     "doRonUGwCSIKhgRFMS0L4DTwMDCcYwOIsDBDADOZLQsRB8g"
                     "xQPgOcDwD7jJ0vaAAAAA==")

slab = TSSlab()
slab.decode_slab(example_slab_code)

# The slab contents are now in a dictionary `slab.data`
from pprint import pprint
pprint(slab.data)

"""
{'layout_count': 1,
 'layouts': [{'instance_count': 9,
              'instances': [{'degrees': 90.0,
                             'pos_x': 0.0,
                             'pos_y': 0.0,
                             'pos_z': 4.0},
                            {'degrees': 0.0,
                             'pos_x': 4.0,
                             'pos_y': 0.0,
                             'pos_z': 4.0},
                            {'degrees': 0.0,
                             'pos_x': 2.0,
                             'pos_y': 0.0,
                             'pos_z': 4.0},
                            {'degrees': 270.0,
                             'pos_x': 0.0,
                             'pos_y': 0.0,
                             'pos_z': 2.0},
                            {'degrees': 180.0,
                             'pos_x': 0.0,
                             'pos_y': 0.0,
                             'pos_z': 0.0},
                            {'degrees': 0.0,
                             'pos_x': 4.0,
                             'pos_y': 0.0,
                             'pos_z': 2.0},
                            {'degrees': 0.0,
                             'pos_x': 2.0,
                             'pos_y': 0.0,
                             'pos_z': 2.0},
                            {'degrees': 0.0,
                             'pos_x': 4.0,
                             'pos_y': 0.0,
                             'pos_z': 0.0},
                            {'degrees': 0.0,
                             'pos_x': 2.0,
                             'pos_y': 0.0,
                             'pos_z': 0.0}],
              'reserved': 0,
              'uuid': '01c3a210-94fb-449f-8c47-993eda3e7126'}],
 'magic_num': 3520002766,
 'num_creatures': 0,
 'version': 2}
"""

# To encode the data
new_slab_code = slab.encode_slab()
# The new_slab_code can be pasted into TaleSpire

# To create the data start a new TSSlab and edit the data dictionary.
# Each uuid is a new layout in the dictionary it is currently up to you
#  to format the dictionary properly so that it encodes correctly.
# In future versions there may be tools to help build the layouts.

# Here is an example of creating a single grass tile
new_slab = TSSlab()
new_slab.data["layout_count"] = 1
grass_layout = {
    "instance_count": 1, # The number of grass tiles
    "instances": [{
        "degrees": 0.0, # Yaw rotation in degrees 0-360 it is up to you to give valid values
        "pos_x": 0.0, # X position within slab
        "pos_y": 0.0, # Y position within slab
        "pos_z": 0.0}], # Z position within slab
    "reserved": 0, # Always set to 0
    "uuid": "01c3a210-94fb-449f-8c47-993eda3e7126" # Asset UUID
}
new_slab.data["layouts"].append(grass_layout)
new_slab_code = new_slab.encode_slab()

# You can paste that new_slab_code into TaleSpire to see your grass tile

Creature Blueprint Example usage:

from ts_encoding import TSCreature
from pprint import pprint

url_from_TS = ("talespire://creature-blueprint/"
              "AgAMV2hpdGUgTWVlcGxlAQAAACMAYnI6MDAwMDAwMDAwMDAwMDAwMD"
              "AwMDAwMDAwMDQ3MDQxMDABAAAAAI49u_vNJQRDrZctETEJKR8ABAAA"
              "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgQQAAIEEAACBBAAAgQQ"
              "AAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEAACBBAAAgQQAAIEEA"
              "ACBBAAAgQQAAIEEAACBBAAAA")

bp = TSCreature()
bp.decode_url(url_from_TS)
pprint(bp.data)

# You can change any of the data in `bp.data`
bp.data["name"] = "New Name"
bp.data["stats"][0] = {"max": 100.0, "value": 100.0}  # Changes hp to 100

# To re-encode the data
new_url = bp.encode_url()

print(new_url)  # You can copy/paste this new URL into TaleSpire

Stats Link Example Usage:

from ts_encoding import TSStatsLink
from pprint import pprint

# Example from the TaleSpire 5e Creature Blueprint Database
stats_link_url = "talespire://stat-names/AQAIAkFDBVNwZWVkB1NUUiBNb2QHREVYIE1vZAdDT04gTW9kB0lOVCBNb2QHV0lTIE1vZAdDSEEgTW9k"

stats = TSStatsLink()
stats.decode_url(stats_link_url)
pprint(stats.data)

# To create a stats link from scratch
new_stats = TSStatsLink()
new_stats.data["num_stats"] = 8
new_stats.data["names"] = [
    "AC", "CMD", "STR", "DEX", "CON", "INT", "WIS", "CHA"
]

new_url = new_stats.encode_url()

print(new_url) # You can copy/paste this URL into TaleSpire to import your stats.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

talespire_encoding-1.2.5.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

talespire_encoding-1.2.5-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file talespire_encoding-1.2.5.tar.gz.

File metadata

  • Download URL: talespire_encoding-1.2.5.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for talespire_encoding-1.2.5.tar.gz
Algorithm Hash digest
SHA256 cd421d7d849adf5813a4fc0843d1fd4e2cc09932d7e43f4c3cc31d4458a63d0e
MD5 beba13cf0a20e42ff79ef3e78310b935
BLAKE2b-256 78030e7e41b79f2511810c84fe8579bc83197cbf94fb4d631b3deed2d0ded3a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for talespire_encoding-1.2.5.tar.gz:

Publisher: python-publish.yml on Baldrax/TaleSpire-Encoding-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file talespire_encoding-1.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for talespire_encoding-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 da438f283c01a10b46b7b1390228976637623e368e7ae38c1226ac61acb9c0b2
MD5 8af2468107b024a001ac0f3091e8f651
BLAKE2b-256 97112c3863d18620db8b939236b67fa2790005236522265dadf5319071a79495

See more details on using hashes here.

Provenance

The following attestation bundles were made for talespire_encoding-1.2.5-py3-none-any.whl:

Publisher: python-publish.yml on Baldrax/TaleSpire-Encoding-Python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page