Commit graph

16 commits

Author SHA1 Message Date
f6fe9d0f09 Move the roguebasin package to erynrl 2022-05-12 09:05:27 -07:00
da3d30872b 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
4084d98efd Clean up Action processing a little bit
- Sort entities by their Euclidean distance to the hero so actions from entities
  near the hero are processed first
- Fewer local variables for cleaner reading
- Pass hero into the RegerateRoomsAction, which was causing a pylint error
2022-05-12 08:53:26 -07:00
c9b86271d3 Remove these two logging messages
They aren't serving a good purpose.
2022-05-11 07:55:47 -07:00
bc46856117 Every action needs an actor, even ExitAction 2022-05-08 23:45:20 -07:00
7d871e52a9 Copy the entities set into a list before iterating it so there's no risk of modifying the array while iterating 2022-05-08 23:43:08 -07:00
46e1a42060 Let Entity.ai produce its own Actions! 2022-05-08 10:03:28 -07:00
4f7e477b24 Add a WaitAction and trigger it with . 2022-05-07 22:34:43 -07:00
8b3c0137a5 Refactor event handling into EventHandler
Move all the event handling code from Engine to EventHandler. EventHandler has a
reference to Engine and can deal with entities from its methods.

Refactor Action to take an optional Entity in its initializer. Some actions
don't require an Entity, but many do/will.
2022-05-07 12:25:46 -07:00
15e188b9f2 Convert the keysym matching to match/case from if/elif 2022-05-07 11:57:08 -07:00
7b747fb4d3 Doc comments and stuff 2022-05-07 11:56:55 -07:00
d0a2e2c2ef Clean up imports and terminal newlines in files according to pylint 2022-05-07 11:22:54 -07:00
4002b64640 Attack!!!
Refactor MovePlayerAction into a few different Action subclasses. Move direction
to a parent MoveAction, and create three new subclasses of MoveAction:

    - BumpAction: perform the test that an action can be performed in the given direction
    - WalkAction, take a step in the given direction
    - MeleeAction, attack another Entity in the given direction

Add an ActionResult class that communicates the result of performing an Action.

    - ActionResult.succeeded indicates whether the action succeeded.
    - ActionResult.done indicates if the action is fully complete or requires followup.
    - ActionResult.alternate specifies the follow-up action to perform.

Convert all the key handling actions to BumpActions.

In the Engine's event handler method, loop until an action is completed,
performing specified alternate actions until the result object indicates the
action is done.
2022-05-07 11:16:17 -07:00
1247617b87 Add diagonal movement 2022-05-04 09:25:35 -07:00
e1044f3a73 Move MovePlayerAction.Direction to geometry.Direction 2022-05-03 18:21:24 -07:00
9ddeef2561 Add actions and events modules 2022-04-30 21:59:01 -07:00