Doc strings and import reordering per pylint

This commit is contained in:
Eryn Wells 2022-05-07 11:42:48 -07:00
parent d0a2e2c2ef
commit 04aa61fe4b
2 changed files with 40 additions and 5 deletions

View file

@ -25,6 +25,26 @@ class Configuration:
map_size: Size map_size: Size
class Engine: 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): def __init__(self, event_handler: EventHandler, configuration: Configuration):
self.event_handler = event_handler self.event_handler = event_handler
self.configuration = configuration self.configuration = configuration
@ -61,6 +81,7 @@ class Engine:
self.update_field_of_view() self.update_field_of_view()
def handle_event(self, event: tcod.event.Event): 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) action = self.event_handler.dispatch(event)
if not action: if not action:

View file

@ -1,15 +1,29 @@
#!/usr/bin/env python3
# Eryn Wells <eryn@erynwells.me> # Eryn Wells <eryn@erynwells.me>
import tcod
from .geometry import Point
from .object import Entity
from dataclasses import dataclass from dataclasses import dataclass
from typing import Tuple from typing import Tuple
from .geometry import Point
from .object import Entity
@dataclass(frozen=True) @dataclass(frozen=True)
class Species: 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 name: str
symbol: str symbol: str
maximum_hit_points: int maximum_hit_points: int