Skip to content

Commit

Permalink
Fix loading saved games from the title splash.
Browse files Browse the repository at this point in the history
Saved games weren't loading from the title splash. This updates the code
used by the splash to match up with the load method used by the load
command.
  • Loading branch information
KevinMoonglow committed Jan 4, 2020
1 parent 76d613d commit d532d28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- `install.sh` will only use `sudo` if the user is not root
- Fix loading saved games from the title splash to use the new local save path.

## [2.2.0] - 2019-12-19

Expand Down
15 changes: 10 additions & 5 deletions story/story_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,20 @@ def start_new_story(
return str(self.story)

def load_new_story(self, story_id, upload_story=False):
save_path = "./saved_stories/"
file_name = "story" + story_id + ".json"
cmd = "gsutil cp gs://aidungeonstories/" + file_name + " ."
os.system(cmd)
exists = os.path.isfile(file_name)
exists = os.path.isfile(os.path.join(save_path, file_name))

if not exists:
return "Error save not found."
print("Save not found locally. Trying in the cloud bucket (only valid for saves before Dec 24 2019)")
cmd = "gsutil cp gs://aidungeonstories/" + file_name + " " + save_path
os.system(cmd)
exists = os.path.isfile(os.path.join(save_path, file_name))

if not exists:
return "Error save not found locally or on the cloud."

with open(file_name, "r") as fp:
with open(os.path.join(save_path, file_name), "r") as fp:
game = json.load(fp)
self.story = Story("", upload_story=upload_story)
self.story.init_from_dict(game)
Expand Down

0 comments on commit d532d28

Please sign in to comment.