From 50ddf8cc01b534fbaf6e6a2e7df23ea615c5dfbb Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 7 Jan 2022 16:48:49 -0500 Subject: [PATCH] Remove some redundancy --- actions.py | 7 ++----- components/ai.py | 5 +---- input_handlers.py | 3 --- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/actions.py b/actions.py index 037f339..08136d3 100644 --- a/actions.py +++ b/actions.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Optional, Tuple, TYPE_CHECKING +from typing import Optional, Tuple, TYPE_CHECKING, overload if TYPE_CHECKING: from engine import Engine @@ -17,6 +17,7 @@ class Action: """Return the engine this action belongs to.""" return self.entity.gamemap.engine + @overload def perform(self) -> None: """Perform this action with the objects needed to determine its scope. @@ -26,7 +27,6 @@ class Action: This method must be overwritten by Action subclasses. """ - raise NotImplementedError() class EscapeAction(Action): @@ -51,9 +51,6 @@ class ActionWithDirection(Action): """Return the blocking entity at this action's destination.""" return self.engine.game_map.get_blocking_entity_at_location(*self.dest_xy) - def perform(self) -> None: - raise NotImplementedError() - class MeleeAction(ActionWithDirection): def perform(self) -> None: diff --git a/components/ai.py b/components/ai.py index e3997be..83aa356 100644 --- a/components/ai.py +++ b/components/ai.py @@ -10,9 +10,6 @@ from components.base_component import BaseComponent class BaseAI(Action, BaseComponent): - def perform(self) -> None: - raise NotImplementedError() - def get_path_to(self, dest_x: int, dest_y: int) -> List[Tuple[int, int]]: """Compute and return a path to the target position. @@ -40,4 +37,4 @@ class BaseAI(Action, BaseComponent): path: List[List[int]] = pathfinder.path_to((dest_x, dest_y))[1:].tolist() # Convert from List[List[int]] to List[Tuple[int, int]]. - return [(index[0], index[1]) for index in path] \ No newline at end of file + return [(index[0], index[1]) for index in path] diff --git a/input_handlers.py b/input_handlers.py index 17fedd7..609d8ef 100644 --- a/input_handlers.py +++ b/input_handlers.py @@ -26,9 +26,6 @@ class EventHandler(tcod.event.EventDispatch[Action]): self.engine.handle_enemy_turns() self.engine.update_fov() - def ev_quit(self, event: tcod.event.Quit) -> Optional[Action]: - raise SystemExit() - def ev_keydown(self, event: tcod.event.KeyDown) -> Optional[Action]: action: Optional[Action] = None