Skip to content

Commit b7fa3d1

Browse files
committed
final cleanup on part 8
1 parent 300d988 commit b7fa3d1

3 files changed

Lines changed: 6 additions & 7 deletions

File tree

Tests/test_input_handlers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
)
1515

1616
from actions import (
17-
EscapeAction,
1817
BumpAction,
1918
WaitAction,
2019
PickupAction,
@@ -535,8 +534,8 @@ def test_ev_keydown_escape(self):
535534
event_handler = MainGameEventHandler(engine=eng)
536535
event = tcod.event.KeyDown(
537536
scancode=tcod.event.Scancode.ESCAPE, sym=tcod.event.K_ESCAPE, mod=tcod.event.Modifier.NONE)
538-
action = event_handler.dispatch(event)
539-
self.assertIsInstance(action, EscapeAction)
537+
with self.assertRaises(SystemExit):
538+
action = event_handler.dispatch(event)
540539

541540
def test_ev_keydown_v(self):
542541
'''

entity.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import copy
4-
from typing import Optional, Tuple, Type, TypeVar, TYPE_CHECKING
4+
from typing import Optional, Tuple, Type, TypeVar, TYPE_CHECKING, Union
55

66
from render_order import RenderOrder
77

@@ -19,7 +19,7 @@ class Entity:
1919
'''
2020
A generic object to represent players, enemies, items, etc.
2121
'''
22-
parent: GameMap
22+
parent: Union[GameMap, Inventory]
2323

2424
def __init__(
2525
self,
@@ -112,6 +112,7 @@ def is_alive(self) -> bool:
112112
"""
113113
return bool(self.ai)
114114

115+
115116
class Item(Entity):
116117
def __init__(
117118
self,

input_handlers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import actions
88
from actions import (
99
Action,
10-
EscapeAction,
1110
BumpAction,
1211
PickupAction,
1312
WaitAction,
@@ -109,7 +108,7 @@ def ev_keydown(self, event: tcod.event.KeyDown) -> Optional[Action]:
109108
action = WaitAction(player)
110109

111110
elif key == tcod.event.K_ESCAPE:
112-
action = EscapeAction(player)
111+
raise SystemExit()
113112

114113
elif key == tcod.event.K_v:
115114
self.engine.event_handler = HistoryViewer(self.engine)

0 commit comments

Comments
 (0)