2022-04-30 21:59:01 -07:00
|
|
|
# Eryn Wells <eryn@erynwells.me>
|
|
|
|
|
2022-05-07 11:56:55 -07:00
|
|
|
'''Defines event handling mechanisms.'''
|
|
|
|
|
2022-05-08 10:03:28 -07:00
|
|
|
from typing import Optional, TYPE_CHECKING
|
2022-05-07 11:22:54 -07:00
|
|
|
|
2022-04-30 21:59:01 -07:00
|
|
|
import tcod
|
2022-05-07 11:22:54 -07:00
|
|
|
|
2022-05-12 20:40:06 -07:00
|
|
|
from . import log
|
2022-05-07 22:34:43 -07:00
|
|
|
from .actions import Action, ActionResult, ExitAction, RegenerateRoomsAction, BumpAction, WaitAction
|
2022-05-03 18:21:24 -07:00
|
|
|
from .geometry import Direction
|
2022-05-08 23:43:08 -07:00
|
|
|
from .object import Actor
|
2022-05-07 12:25:46 -07:00
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from .engine import Engine
|
|
|
|
|
2022-04-30 21:59:01 -07:00
|
|
|
class EventHandler(tcod.event.EventDispatch[Action]):
|
2022-05-07 11:56:55 -07:00
|
|
|
'''Handler of `tcod` events'''
|
|
|
|
|
2022-05-07 12:25:46 -07:00
|
|
|
def __init__(self, engine: 'Engine'):
|
|
|
|
super().__init__()
|
|
|
|
self.engine = engine
|
|
|
|
|
|
|
|
def wait_for_events(self):
|
|
|
|
'''Wait for events and handle them.'''
|
|
|
|
for event in tcod.event.wait():
|
|
|
|
self.handle_event(event)
|
|
|
|
|
|
|
|
def handle_event(self, event: tcod.event.Event) -> None:
|
|
|
|
'''Handle the given event. Transform that event into an Action via an EventHandler and perform it.'''
|
|
|
|
action = self.dispatch(event)
|
|
|
|
|
2022-05-12 08:53:26 -07:00
|
|
|
# Unhandled event. Ignore it.
|
2022-05-07 12:25:46 -07:00
|
|
|
if not action:
|
2022-05-12 20:40:06 -07:00
|
|
|
log.EVENTS.debug('Unhandled event: %s', event)
|
2022-05-07 12:25:46 -07:00
|
|
|
return
|
|
|
|
|
2022-05-12 20:40:06 -07:00
|
|
|
log.ACTIONS_TREE.info('Processing Hero Actions')
|
|
|
|
log.ACTIONS_TREE.info('|-> %s', action.actor)
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
|
2022-05-07 12:25:46 -07:00
|
|
|
result = self.perform_action_until_done(action)
|
|
|
|
|
2022-05-12 08:53:26 -07:00
|
|
|
# Player's action failed, don't proceed with turn.
|
2022-05-07 12:25:46 -07:00
|
|
|
if not result.success and result.done:
|
|
|
|
return
|
|
|
|
|
2022-05-12 08:53:26 -07:00
|
|
|
# Copy the list so we only act on the entities that exist at the start of this turn. Sort it by Euclidean
|
|
|
|
# distance to the Hero, so entities closer to the hero act first.
|
|
|
|
hero_position = self.engine.hero.position
|
|
|
|
entities = sorted(
|
|
|
|
self.engine.entities,
|
|
|
|
key=lambda e: e.position.euclidean_distance_to(hero_position))
|
|
|
|
|
2022-05-12 20:40:06 -07:00
|
|
|
log.ACTIONS_TREE.info('Processing Entity Actions')
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
|
2022-05-12 08:53:26 -07:00
|
|
|
for i, ent in enumerate(entities):
|
2022-05-08 23:43:08 -07:00
|
|
|
if not isinstance(ent, Actor):
|
|
|
|
continue
|
|
|
|
|
2022-05-08 10:03:28 -07:00
|
|
|
ent_ai = ent.ai
|
|
|
|
if not ent_ai:
|
2022-05-07 12:25:46 -07:00
|
|
|
continue
|
|
|
|
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
if self.engine.map.visible[tuple(ent.position)]:
|
2022-05-12 20:40:06 -07:00
|
|
|
log.ACTIONS_TREE.info('%s-> %s', '|' if i < len(entities) - 1 else '`', ent)
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
|
2022-05-08 10:03:28 -07:00
|
|
|
action = ent_ai.act(self.engine)
|
|
|
|
self.perform_action_until_done(action)
|
2022-05-07 12:25:46 -07:00
|
|
|
|
|
|
|
self.engine.update_field_of_view()
|
|
|
|
|
|
|
|
def perform_action_until_done(self, action: Action) -> ActionResult:
|
|
|
|
'''Perform the given action and any alternate follow-up actions until the action chain is done.'''
|
|
|
|
result = action.perform(self.engine)
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
|
2022-05-12 20:40:06 -07:00
|
|
|
if log.ACTIONS_TREE.isEnabledFor(log.INFO) and self.engine.map.visible[tuple(action.actor.position)]:
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
if result.alternate:
|
|
|
|
alternate_string = f'{result.alternate.__class__.__name__}[{result.alternate.actor.symbol}]'
|
|
|
|
else:
|
|
|
|
alternate_string = str(result.alternate)
|
2022-05-12 20:40:06 -07:00
|
|
|
log.ACTIONS_TREE.info('| %s-> %s => success=%s done=%s alternate=%s',
|
|
|
|
'|' if not result.success or not result.done else '`',
|
|
|
|
action,
|
|
|
|
result.success,
|
|
|
|
result.done,
|
|
|
|
alternate_string)
|
2022-05-07 12:25:46 -07:00
|
|
|
|
|
|
|
while not result.done:
|
2022-05-12 08:53:26 -07:00
|
|
|
action = result.alternate
|
|
|
|
assert action is not None, f'Action {result.action} incomplete but no alternate action given'
|
2022-05-07 12:25:46 -07:00
|
|
|
|
2022-05-12 08:53:26 -07:00
|
|
|
result = action.perform(self.engine)
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
|
2022-05-12 20:40:06 -07:00
|
|
|
if log.ACTIONS_TREE.isEnabledFor(log.INFO) and self.engine.map.visible[tuple(action.actor.position)]:
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
if result.alternate:
|
|
|
|
alternate_string = f'{result.alternate.__class__.__name__}[{result.alternate.actor.symbol}]'
|
|
|
|
else:
|
|
|
|
alternate_string = str(result.alternate)
|
2022-05-12 20:40:06 -07:00
|
|
|
log.ACTIONS_TREE.info('| %s-> %s => success=%s done=%s alternate=%s',
|
Add logging action handling in a tree-like fashion
These logs are available in the actions.tree logger. They'll print a helpful
list of actions and their results in a tree-like way.
For example:
```
2022-05-12 08:57:57 actions.tree: Processing Hero Actions
2022-05-12 08:57:57 actions.tree: |-> @[(x:4, y:6)][30/30]
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by @[(x:4, y:6)][30/30] => success=False done=False alternate=WalkAction[@]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by @[(x:3, y:7)][30/30] => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: Processing Entity Actions
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:4, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:3, y:6) => success=True done=True alternate=None
2022-05-12 08:57:57 actions.tree: |-> Orc with 10/10 hp at (x:5, y:5)
2022-05-12 08:57:57 actions.tree: | |-> BumpAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:5, y:5) => success=False done=False alternate=WalkAction[o]
2022-05-12 08:57:57 actions.tree: | `-> WalkAction toward (δx:-1, δy:1) by Orc with 10/10 hp at (x:4, y:6) => success=True done=True alternate=None
```
2022-05-12 08:56:15 -07:00
|
|
|
'|' if not result.success or not result.done else '`',
|
|
|
|
action,
|
|
|
|
result.success,
|
|
|
|
result.done,
|
|
|
|
alternate_string)
|
2022-05-07 12:25:46 -07:00
|
|
|
|
|
|
|
if result.success:
|
|
|
|
break
|
2022-05-07 22:34:43 -07:00
|
|
|
|
2022-05-07 12:25:46 -07:00
|
|
|
return result
|
|
|
|
|
2022-04-30 21:59:01 -07:00
|
|
|
def ev_quit(self, event: tcod.event.Quit) -> Optional[Action]:
|
2022-05-08 23:45:20 -07:00
|
|
|
return ExitAction(self.engine.hero)
|
2022-04-30 21:59:01 -07:00
|
|
|
|
|
|
|
def ev_keydown(self, event: tcod.event.KeyDown) -> Optional[Action]:
|
|
|
|
action: Optional[Action] = None
|
|
|
|
|
2022-05-07 12:25:46 -07:00
|
|
|
hero = self.engine.hero
|
|
|
|
|
2022-04-30 21:59:01 -07:00
|
|
|
sym = event.sym
|
2022-05-07 11:57:08 -07:00
|
|
|
match sym:
|
|
|
|
case tcod.event.KeySym.b:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.SouthWest)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.h:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.West)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.j:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.South)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.k:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.North)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.l:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.East)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.n:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.SouthEast)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.u:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.NorthEast)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.y:
|
2022-05-07 12:25:46 -07:00
|
|
|
action = BumpAction(hero, Direction.NorthWest)
|
2022-05-07 11:57:08 -07:00
|
|
|
case tcod.event.KeySym.SPACE:
|
2022-05-12 08:53:26 -07:00
|
|
|
action = RegenerateRoomsAction(hero)
|
2022-05-07 22:34:43 -07:00
|
|
|
case tcod.event.KeySym.PERIOD:
|
|
|
|
action = WaitAction(hero)
|
2022-04-30 21:59:01 -07:00
|
|
|
|
|
|
|
return action
|