Add a WaitAction and trigger it with .

This commit is contained in:
Eryn Wells 2022-05-07 22:34:43 -07:00
parent 85423e739c
commit 4f7e477b24
2 changed files with 14 additions and 3 deletions

View file

@ -178,3 +178,10 @@ class MeleeAction(MoveAction):
def perform(self, engine: 'Engine') -> ActionResult: def perform(self, engine: 'Engine') -> ActionResult:
LOG.info('Attack! %s', self.target) LOG.info('Attack! %s', self.target)
return ActionResult(self, success=True) 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)

View file

@ -8,7 +8,7 @@ from typing import MutableSet, Optional, TYPE_CHECKING
import tcod import tcod
from .actions import Action, ActionResult, ExitAction, RegenerateRoomsAction, BumpAction from .actions import Action, ActionResult, ExitAction, RegenerateRoomsAction, BumpAction, WaitAction
from .geometry import Direction from .geometry import Direction
from .object import Entity from .object import Entity
@ -77,8 +77,10 @@ class EventHandler(tcod.event.EventDispatch[Action]):
if result.success: if result.success:
LOG.info('Action succeded!') LOG.info('Action succeded!')
break break
else:
LOG.info('Action failed!') if result.done:
LOG.info('Action failed!')
break
return result return result
@ -110,5 +112,7 @@ class EventHandler(tcod.event.EventDispatch[Action]):
action = BumpAction(hero, Direction.NorthWest) action = BumpAction(hero, Direction.NorthWest)
case tcod.event.KeySym.SPACE: case tcod.event.KeySym.SPACE:
action = RegenerateRoomsAction() action = RegenerateRoomsAction()
case tcod.event.KeySym.PERIOD:
action = WaitAction(hero)
return action return action