Clean up the __str__ for a few Action subclasses

This commit is contained in:
Eryn Wells 2022-05-12 08:48:28 -07:00
parent 6f1d68db20
commit e4f8aa5e80

View file

@ -101,6 +101,9 @@ class Action:
'''Create an ActionResult indicating success with no follow-up'''
return ActionResult(self, success=True)
def __str__(self) -> str:
return f'{self.__class__.__name__} for {self.actor!s}'
def __repr__(self):
return f'{self.__class__.__name__}({self.actor!r})'
@ -127,6 +130,9 @@ class MoveAction(Action):
def __repr__(self):
return f'{self.__class__.__name__}({self.actor!r}, {self.direction!r})'
def __str__(self) -> str:
return f'{self.__class__.__name__} toward {self.direction} by {self.actor!s}'
class BumpAction(MoveAction):
'''Attempt to perform a movement action in a direction.
@ -236,4 +242,4 @@ class DropItemAction(Action):
def perform(self, engine: 'Engine') -> ActionResult:
engine.entities.add(self.item)
return self.success()
return self.success()