Commit graph

8 commits

Author SHA1 Message Date
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