Created
June 1, 2018 13:13
-
-
Save MissingNoShiny/9aa99bf9e4a58a904bc1fe629cb4ac50 to your computer and use it in GitHub Desktop.
A quick script to recover lost Slay the Spire character data based on run history
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import os | |
| from pprint import pprint | |
| finalData = {} | |
| keys = ["TOTAL_FLOORS", | |
| "ENEMY_KILL", | |
| "BOSS_KILL", | |
| "WIN_STREAK", | |
| "LOSE_COUNT", | |
| "PLAYTIME", | |
| "HIGHEST_FLOOR", | |
| "HIGHEST_SCORE", | |
| "FAST_VICTORY", | |
| "BEST_WIN_STREAK", | |
| "WIN_COUNT", | |
| "ASCENSION_LEVEL"] | |
| for key in keys : | |
| finalData[key] = 0 | |
| finalData["FAST_VICTORY"] = 100000 | |
| path = r"C:\Program Files (x86)\Steam\steamapps\common\SlayTheSpire\runs\IRONCLAD" | |
| fileList = list(filter(lambda file : file.endswith(".run"), os.listdir(path))) | |
| for file in fileList: | |
| jsonString = open(path + "\\" + file, "r").read() | |
| runData = json.loads(jsonString) | |
| finalData["TOTAL_FLOORS"] += runData["floor_reached"] | |
| finalData["HIGHEST_FLOOR"] = max(runData["floor_reached"], finalData["HIGHEST_FLOOR"]) | |
| finalData["HIGHEST_SCORE"] = max(runData.get("score", 0), finalData["HIGHEST_SCORE"]) | |
| finalData["PLAYTIME"] += runData["playtime"] | |
| finalData["ENEMY_KILL"] += runData["path_taken"][:-1].count("M") + runData["path_taken"][:-1].count("E") | |
| finalData["BOSS_KILL"] += runData["path_taken"][:-1].count("BOSS") | |
| if runData["victory"]: | |
| finalData["WIN_COUNT"] += 1 | |
| finalData["WIN_STREAK"] += 1 | |
| finalData["FAST_VICTORY"] = min(runData["playtime"], finalData["FAST_VICTORY"]) | |
| finalData["ASCENSION_LEVEL"] = max(runData.get("ascension_level", 0) + 1, finalData["ASCENSION_LEVEL"]) | |
| else: | |
| finalData["LOSE_COUNT"] += 1 | |
| finalData["WIN_STREAK"] = 0 | |
| finalData["BEST_WIN_STREAK"] = max(finalData["WIN_STREAK"], finalData["BEST_WIN_STREAK"]) | |
| finalData["ENEMY_KILL"] *= 3 #Not accurate but good estimate in my experience | |
| for key in finalData.keys(): | |
| finalData[key] = str(finalData[key]) | |
| pprint(json.dumps(finalData)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment