From bd0db732b673c28e020a88be37a06fc624bf36bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20N=C3=B6llemeyer?= Date: Sat, 17 Aug 2024 11:36:48 +0200 Subject: [PATCH] fixed missing state -> screen refactor --- game/screens/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/game/screens/__init__.py b/game/screens/__init__.py index ee16cc0..f8da103 100644 --- a/game/screens/__init__.py +++ b/game/screens/__init__.py @@ -1,4 +1,4 @@ -"""Package for game state stuff.""" +"""Package for game screens.""" from __future__ import annotations @@ -55,8 +55,8 @@ def main_draw() -> None: g.context.present(g.console) -def apply_state_result(result: ScreenResult) -> None: - """Apply a StateResult to `g.states`.""" +def apply_screen_result(result: ScreenResult) -> None: + """Apply a ScreenResult to `g.screens`.""" match result: case Push(screen=screen): g.screens.append(screen) @@ -64,8 +64,8 @@ def apply_state_result(result: ScreenResult) -> None: g.screens.pop() case Reset(screen=screen): while g.screens: - apply_state_result(Pop()) - apply_state_result(Push(screen)) + apply_screen_result(Pop()) + apply_screen_result(Push(screen)) case None: pass case _: @@ -73,23 +73,23 @@ def apply_state_result(result: ScreenResult) -> None: def main_loop() -> None: - """Run the active state forever.""" + """Run the active screen forever.""" while g.screens: main_draw() for event in tcod.event.wait(): tile_event = g.context.convert_event(event) if g.screens: - apply_state_result(g.screens[-1].on_event(tile_event)) + apply_screen_result(g.screens[-1].on_event(tile_event)) def get_previous_screen(screen: Screen) -> Screen | None: - """Return the state before `state` in the stack if it exists.""" + """Return the screen before `screen` in the stack if it exists.""" current_index = next(index for index, value in enumerate(g.screens) if value is screen) return g.screens[current_index - 1] if current_index > 0 else None def draw_previous_screens(screen: Screen, console: tcod.console.Console, dim: bool = True) -> None: - """Draw previous states, optionally dimming all but the active state.""" + """Draw previous screens, optionally dimming all but the active screen.""" prev_screen = get_previous_screen(screen) if prev_screen is None: return