Commit graph

17 commits

Author SHA1 Message Date
2266511ec5 Implement attacking and reducing hit points
Attacks are computed with attack_power and defense. When an Actor dies,
a DieAction is produced and possibly also a DropItemAction.
2022-05-08 23:41:54 -07:00
aae1251660 Rename Action.entity -> Action.actor 2022-05-08 23:40:33 -07:00
7653df1e3f Add Action.success() and Action.failure() helper methods to produce results for straight success and failure 2022-05-08 23:34:09 -07:00
f5a8a55182 Add WaitAction to the class hierarchy 2022-05-08 08:55:08 -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
d75c9faea3 Little bits of cleanup 2022-05-07 12:25:44 -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
57bbb2c3fc Some more fixes from the linter 2022-05-07 09:57:39 -07:00
7720bc525a Address some linter issues; add doc strings
- Clean up some import ordering
- Write some Numpy style doc strings for classes and functions
2022-05-07 08:55:10 -07:00
16b4b64099 Clean up the logging; use % formats instead of f-strings 2022-05-07 08:53:58 -07:00
c2c67ae9ef Move logging hero movement into the if block where it actually does the move 2022-05-06 21:13:37 -07:00
e1044f3a73 Move MovePlayerAction.Direction to geometry.Direction 2022-05-03 18:21:24 -07:00
a54828c7fb Fix up all the runtime errors caused by the previous refactoring 2022-05-01 09:51:22 -07:00
5ce26e310b Move the action perform logic to Action.perform() on each Action subclass
Rename Object to Entity to avoid name clashes with Python.object
2022-05-01 09:29:30 -07:00
cde6ea2065 Make the MovePlayerAction.Direction values Vectors 2022-05-01 09:27:59 -07:00
9ddeef2561 Add actions and events modules 2022-04-30 21:59:01 -07:00