Skip to content

Commit

Permalink
Fix game
Browse files Browse the repository at this point in the history
  • Loading branch information
YummyBacon5 authored Jan 21, 2025
1 parent c6e5de0 commit 5b762c8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,14 @@ def load_game(self):
loaded_save = all_player_datas[choicen_save_int]

for key, value in loaded_save.items():
setattr(self, key, value)
self.__dict__[key] = value
print(f"{Fore.GREEN}Loaded game: {shlex.quote(self.game_name)}{Style.RESET_ALL}")

self._set_typewriter_option()

is_location_an_ending = not GAME_WORLD[self.current_location]["options"]

if is_location_an_ending and get_valid_bool_input("Do you want to load the point before you died?"):
self.previous_location = self.current_location
self.current_location = self.previous_location
print(f"{Fore.GREEN}Game loaded with previous location successfully!{Style.RESET_ALL}")
return True
Expand All @@ -344,13 +343,16 @@ def load_game(self):


def __setattr__(self, name, value):
if name == "current_location":
if name == "current_location" and value != self.current_location:
self.previous_location = self.current_location

self.__dict__[name] = value

if name != "last_updated":
self._save_game()

def __getattr__(self, name):
return self.__dict__[name]

def _save_game(self, override: list[PlayerDataType] | None = None):
if override is not None:
Expand Down

0 comments on commit 5b762c8

Please sign in to comment.