Remove some redundancy
This commit is contained in:
parent
a796e947d1
commit
50ddf8cc01
@ -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:
|
||||
|
@ -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]
|
||||
return [(index[0], index[1]) for index in path]
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user