Skip to content

Commit

Permalink
add custom file_name
Browse files Browse the repository at this point in the history
  • Loading branch information
xXUnique31Xx committed Jul 2, 2024
1 parent ebb1d59 commit 7f6f8df
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,16 @@ def save_gamestate(self):
saved_games_dir = Path.cwd() / 'SavedGames'
saved_games_dir.mkdir(exist_ok=True)

# Generate a detailed timestamped filename
timestamp = datetime.now().strftime('%d%m%Y_%H%M%S')
file_name = f"{timestamp}_Gamestate.json"
file_name = GameView.input_prompt("Enter a name for your save"
"(leave blank to use the current datetime): ")
if not file_name:
# Generate a detailed timestamped filename
timestamp = datetime.now().strftime('%d%m%Y_%H%M%S')
file_name = f"{timestamp}_Gamestate.json"
else:
if not file_name.endswith('.json'):
file_name += ".json"

file_path = saved_games_dir / file_name

try:
Expand Down

0 comments on commit 7f6f8df

Please sign in to comment.