Clean up the __str__ for a few Action subclasses
This commit is contained in:
parent
6f1d68db20
commit
e4f8aa5e80
1 changed files with 7 additions and 1 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue