GithubHelp home page GithubHelp logo

rahmatnazali / spireslayer Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 482 KB

Programmable save editor for Slay the Spire

Home Page: https://pypi.org/project/spireslayer

License: Apache License 2.0

Python 100.00%
autosave editor slay-the-spire slaythespire card game slay spire

spireslayer's Introduction

Slay the Spire faster by editing the save file! If done right, this will keep the fun while avoiding too much time to be wasted.

How the script works

  • It starts by finding the obfuscated autosave file that named with this format: <Name of the character>.autosave. For example, see DEFECT.autosave.
  • The SaveEditor object will decrypt the save data and convert it to an editable JSON object format.
  • At this point, you can edit the json object as needed.
  • Finally, call the SaveEditor.write_json_to_file() and the script will write the modified save file back to the obfuscated save file format, replacing the old one

How to use the package

Install the package with pip install spireslayer.

1. Creating your own save file editor

Create your own script as needed, for example:

from spireslayer.save_editor import SaveEditor
from spireslayer.decks import Deck
from spireslayer.card import Card
from spireslayer.templates.defect_card import GLACIER, DEFRAGMENT, BLIZZARD

# Declare a valid path to the save folder
save_file_path = "C:\Program Files (x86)\Steam\steamapps\common\SlayTheSpire\saves"

# Declare a save editor that points to the save_file path
save_editor = SaveEditor(save_file_path)

# Edit whatever you want.
# here we are making custom powerful deck for our Defect
save_editor.set_deck(Deck([
    Card(GLACIER),
    Card(GLACIER),
    Card(GLACIER),
    Card(DEFRAGMENT),
    Card(DEFRAGMENT),
    Card(DEFRAGMENT),
    Card(BLIZZARD),
    Card(BLIZZARD),
    Card(BLIZZARD),
    Card(BLIZZARD),
    Card(BLIZZARD),
]))

# or maybe increase our Defect's max orb
save_editor.update_max_orbs(15)

# or anything that can be adjusted to your need
save_editor.update_current_health(400)
save_editor.update_max_health(500)
save_editor.update_hand_size(10)
save_editor.update_energy_per_turn(20)

# After customization is finished, call this method to rewrite the save data back to the original place.
# The old save file will be replaced.
save_editor.write_json_to_file()

2. Running the save file editor

  • Open the game. You can create a new game or continue your session.
  • On the first encounter after loading the game, hit the menu and choose Save & Quit.
  • From the main menu, switch back to your script and run it. You don't need to close the game.
  • Back to your game and click Continue. Enjoy the game!

Note

Currently, the package only supports The Defect. For other character, you can create the method yourself (PR is greatly appreciated!) or alternatively use the provided API SaveEditor.get_json() to get the JSON formatted save file, change the JSON directly, and assign it back with the provided API SaveEditor.set_json(). For example:

from spireslayer.save_editor import SaveEditor

editor = SaveEditor(...)

save_file = editor.get_json()
save_file['current_health'] = 1000
editor.set_json(save_file)

Refer to the readable save file example for more example.

Disclaimer

I got the save file encryption logic from Kirill89's gist written in JS. What I did was only rewriting it in python and adding features so that the save data can be programmatically edited.

spireslayer's People

Contributors

rahmatnazali avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

wondergood

spireslayer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.