Skip to content

Commit

Permalink
Fix a small bug with save mechanics introduced by Death sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
DiddiLeija committed May 31, 2024
1 parent c628c51 commit 6d6339e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def update(self):
# Also, keep memory of your player choice :)
if self.situation.finished:
tmp = self.situation.player_choice
if self.situation.nextlevel != "menu":
if self.situation.nextlevel not in ("menu", "death"):
write_savedata({"level": self.situation.nextlevel})
self.situation = init_class(stages_list[self.situation.nextlevel], tmp)
del(tmp) # we have to remove 'tmp' ASAP
Expand Down
14 changes: 7 additions & 7 deletions src/scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ class DeathSequence(BaseLevel):
A former scene (though not inherited from BaseScene, nor
behaving much like BaseLevel) to use when losing the game.
"""
player_selection = None
player_choice = None

def __init__(self, player_choice):
self.player_selection = player_choice
self.player_choice = player_choice
pyxel.camera(0, 0) # NOTE: draw_v is not needed here
pyxel.stop()

def update(self):
self.check_quit()
if self.check_reset():
self.nextlevel = "menu"
elif pyxel.btnp(pyxel.KEY_SPACE):
self.finished = True
self.nextlevel = get_savedata()["level"]

def draw(self):
pyxel.cls(0)
pyxel.bltm(0, 0, 2, 0, 384, 128, 128, 0)
Expand All @@ -106,15 +106,15 @@ def draw(self):
5,
5
)

def get_player_names(self):
"Get a proper text to refer to the player pack."
ideas = ["Diddi", "Eli", "Diddi & Eli"]
try:
return ideas[self.player_selection]
return ideas[self.player_choice]
except (TypeError, IndexError, ValueError) as exc:
report_crash(
f"DeathSequence.get_player_names (player_selection = {self.player_selection})",
f"DeathSequence.get_player_names (player_choice = {self.player_choice})",
str(exc)
)

Expand Down

0 comments on commit 6d6339e

Please sign in to comment.