From 4f7e477b24f4047c334c3ea96e1b67959ebd756a Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 7 May 2022 22:34:43 -0700 Subject: [PATCH] Add a WaitAction and trigger it with . --- roguebasin/actions.py | 7 +++++++ roguebasin/events.py | 10 +++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/roguebasin/actions.py b/roguebasin/actions.py index 5e849fa..c9426a0 100644 --- a/roguebasin/actions.py +++ b/roguebasin/actions.py @@ -178,3 +178,10 @@ class MeleeAction(MoveAction): def perform(self, engine: 'Engine') -> ActionResult: LOG.info('Attack! %s', self.target) return ActionResult(self, success=True) + +class WaitAction(Action): + '''Wait a turn''' + + def perform(self, engine: 'Engine') -> ActionResult: + LOG.info('%s is waiting a turn', self.entity) + return ActionResult(self, success=True) diff --git a/roguebasin/events.py b/roguebasin/events.py index 55ac392..33074a9 100644 --- a/roguebasin/events.py +++ b/roguebasin/events.py @@ -8,7 +8,7 @@ from typing import MutableSet, Optional, TYPE_CHECKING import tcod -from .actions import Action, ActionResult, ExitAction, RegenerateRoomsAction, BumpAction +from .actions import Action, ActionResult, ExitAction, RegenerateRoomsAction, BumpAction, WaitAction from .geometry import Direction from .object import Entity @@ -77,8 +77,10 @@ class EventHandler(tcod.event.EventDispatch[Action]): if result.success: LOG.info('Action succeded!') break - else: - LOG.info('Action failed!') + + if result.done: + LOG.info('Action failed!') + break return result @@ -110,5 +112,7 @@ class EventHandler(tcod.event.EventDispatch[Action]): action = BumpAction(hero, Direction.NorthWest) case tcod.event.KeySym.SPACE: action = RegenerateRoomsAction() + case tcod.event.KeySym.PERIOD: + action = WaitAction(hero) return action