From 04aa61fe4b0825d5cc31e82e9f99fb67d6212e80 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 7 May 2022 11:42:48 -0700 Subject: [PATCH] Doc strings and import reordering per pylint --- roguebasin/engine.py | 21 +++++++++++++++++++++ roguebasin/monsters.py | 24 +++++++++++++++++++----- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/roguebasin/engine.py b/roguebasin/engine.py index 22dd6c4..cfa0b33 100644 --- a/roguebasin/engine.py +++ b/roguebasin/engine.py @@ -25,6 +25,26 @@ class Configuration: map_size: Size class Engine: + '''The main game engine. + + This class provides the event handling, map drawing, and maintains the list of entities. + + Attributes + ---------- + configuration : Configuration + Defines the basic configuration for the game + entities : MutableSet[Entity] + A set of all the entities on the current map, including the Hero + event_handler : EventHandler + An event handler object that can handle events from `tcod` + hero : Hero + The hero, the Entity controlled by the player + map : Map + A map of the current level + rng : tcod.random.Random + A random number generator + ''' + def __init__(self, event_handler: EventHandler, configuration: Configuration): self.event_handler = event_handler self.configuration = configuration @@ -61,6 +81,7 @@ class Engine: self.update_field_of_view() def handle_event(self, event: tcod.event.Event): + '''Handle the specified event. Transform that event into an Action via an EventHandler and perform it.''' action = self.event_handler.dispatch(event) if not action: diff --git a/roguebasin/monsters.py b/roguebasin/monsters.py index a692a50..a9866a3 100644 --- a/roguebasin/monsters.py +++ b/roguebasin/monsters.py @@ -1,15 +1,29 @@ -#!/usr/bin/env python3 # Eryn Wells -import tcod -from .geometry import Point -from .object import Entity from dataclasses import dataclass from typing import Tuple +from .geometry import Point +from .object import Entity + @dataclass(frozen=True) class Species: - '''A kind of monster.''' + '''A kind of monster. + + Attributes + ---------- + name : str + A friendly, user-visiable name for the monster + symbol : str + The symbol used to render the monster on the map + maximum_hit_points : int + The maximum number of hit points the monster can be spawned with + foreground_color : Tuple[int, int, int] + The foreground color used to render the monster on the map + background_color : Tuple[int, int, int], optional + The background color used to render the monster on the map; if none is given, the tile color specified by the + map will be used. + ''' name: str symbol: str maximum_hit_points: int