rahmatnazali / spireslayer

Programmable save editor for Slay the Spire
https://pypi.org/project/spireslayer
Apache License 2.0
7 stars 2 forks source link

Refactor `SaveEditor` to accept `installation_path` and `save_folder_name` #15

Closed rahmatnazali closed 2 months ago

rahmatnazali commented 2 months ago

Known facts:

  1. Default installation path for windows is C:\\Program Files (x86)\\Steam\\steamapps\\common\\SlayTheSpire
  2. The folder in which the save files are contained is named saves

and then considering these possibilities:

  1. Game installation path may be customized on user's behalf, so the default installation path wont always work. We also have player with different OS that doesn't necessarily has the same path pattern.
  2. Future version of the game might change/rename the saves folder inside the game installation. Probably would never happen, but if it does then this package will simply break

In this PR, I would like to separate the full path of the save folder to installation_path and save_folder_name. Both with the currently working value as the default value, but entirely customizable as needed.

Example 1: Windows user with default installation

from spireslayer.save_editor import SaveEditor

# this should work out of the box without any configuration needed
save_editor = SaveEditor()

Example 2: Windows user (or Linux user, for example) with custom installation path

from spireslayer.save_editor import SaveEditor

# installation_path can be configured as needed
save_editor = SaveEditor(
    installation_path="D:\\MyGames\\SlayTheSpire",
)

# or
save_editor = SaveEditor(
    installation_path="/home/rahmat/.steam/debian-installation/steamapps/common/SlayTheSpire",
)

Example 3: Custom save folder name

from spireslayer.save_editor import SaveEditor

# case that probably will never happen (e.g. due to version change)
# but if it happened then only small change from the user is needed instead of bumping the package version
save_editor = SaveEditor(
    save_folder_name="savestates",
)

Other than that, small changes are also included in several files to adhere with PEP styling.

rahmatnazali commented 2 months ago

Note that this PR reverts the default SaveEditor path value back to C:\\Program Files (x86)\\Steam\\steamapps\\common\\SlayTheSpire.

cc @gabrekt , just want to let you know that I'm reverting this.