From f05dfdef559b918df24c81049ce47becde80fbf9 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 10 Feb 2023 21:25:00 -0800 Subject: [PATCH] PEP8 formatter changes --- erynrl/__main__.py | 6 ++++++ erynrl/ai.py | 6 +++++- erynrl/components.py | 1 + erynrl/events.py | 3 +++ erynrl/map/__init__.py | 5 +++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/erynrl/__main__.py b/erynrl/__main__.py index 74211ab..aab55ea 100644 --- a/erynrl/__main__.py +++ b/erynrl/__main__.py @@ -13,17 +13,20 @@ MAP_WIDTH, MAP_HEIGHT = 80, 45 FONT_CP437 = 'terminal16x16_gs_ro.png' FONT_BDF = 'ter-u32n.bdf' + def parse_args(argv, *a, **kw): parser = argparse.ArgumentParser(*a, **kw) parser.add_argument('--debug', action='store_true', default=True) args = parser.parse_args(argv) return args + def walk_up_directories_of_path(path): while path and path != '/': path = os.path.dirname(path) yield path + def find_fonts_directory(): '''Walk up the filesystem tree from this script to find a fonts/ directory.''' for parent_dir in walk_up_directories_of_path(__file__): @@ -36,6 +39,7 @@ def find_fonts_directory(): return possible_fonts_dir + def main(argv): ''' Beginning of the game @@ -68,6 +72,7 @@ def main(argv): with tcod.context.new(columns=console.width, rows=console.height, tileset=tileset) as context: engine.run_event_loop(context, console) + def run_until_exit(): ''' Run main() and call sys.exit when it finishes. In practice, this function will never return. The game engine has @@ -76,4 +81,5 @@ def run_until_exit(): result = main(sys.argv) sys.exit(0 if not result else result) + run_until_exit() diff --git a/erynrl/ai.py b/erynrl/ai.py index 867b236..710b2b1 100644 --- a/erynrl/ai.py +++ b/erynrl/ai.py @@ -17,6 +17,8 @@ if TYPE_CHECKING: from .engine import Engine # pylint: disable=too-few-public-methods + + class AI(Component): '''An abstract class providing AI for an entity.''' @@ -28,6 +30,7 @@ class AI(Component): '''Produce an action to perform''' raise NotImplementedError() + class HostileEnemy(AI): '''Entity AI for a hostile enemy. @@ -60,7 +63,8 @@ class HostileEnemy(AI): direction_to_next_position = entity_position.direction_to_adjacent_point(next_position) if engine.map.visible[tuple(self.entity.position)]: - log.AI.info('`-> Hero is visible to %s, bumping %s (%s)', self.entity, direction_to_next_position, next_position) + log.AI.info('`-> Hero is visible to %s, bumping %s (%s)', + self.entity, direction_to_next_position, next_position) return BumpAction(self.entity, direction_to_next_position) else: diff --git a/erynrl/components.py b/erynrl/components.py index 3e7a291..b8810ed 100644 --- a/erynrl/components.py +++ b/erynrl/components.py @@ -7,6 +7,7 @@ from typing import Optional class Component: '''A base, abstract Component that implement some aspect of an Entity's behavior.''' + class Fighter(Component): '''A Fighter is an Entity that can fight. That is, it has hit points (health), attack, and defense. diff --git a/erynrl/events.py b/erynrl/events.py index 9d9a69f..fd3577f 100644 --- a/erynrl/events.py +++ b/erynrl/events.py @@ -14,6 +14,7 @@ from .geometry import Direction, Point if TYPE_CHECKING: from .engine import Engine + class EventHandler(tcod.event.EventDispatch[Action]): '''Abstract event handler class''' @@ -49,6 +50,7 @@ class EventHandler(tcod.event.EventDispatch[Action]): def ev_quit(self, event: tcod.event.Quit) -> Optional[Action]: return ExitAction() + class MainGameEventHandler(EventHandler): ''' Handler of `tcod` events for the main game. @@ -95,6 +97,7 @@ class MainGameEventHandler(EventHandler): mouse_point = None self.engine.current_mouse_point = mouse_point + class GameOverEventHandler(EventHandler): '''When the game is over (the hero dies, the player quits, etc), this event handler takes over.''' diff --git a/erynrl/map/__init__.py b/erynrl/map/__init__.py index 075a915..9d8c945 100644 --- a/erynrl/map/__init__.py +++ b/erynrl/map/__init__.py @@ -1,5 +1,10 @@ # Eryn Wells +''' +This module defines the level map, a number of basic building blocks (Rooms, etc), and objects that generate various +parts of a map. +''' + import random import numpy as np