diff --git a/dungeonbattle/bootstrap.py b/dungeonbattle/bootstrap.py index 7c65e0e..9828fae 100644 --- a/dungeonbattle/bootstrap.py +++ b/dungeonbattle/bootstrap.py @@ -5,8 +5,9 @@ from dungeonbattle.term_manager import TermManager class Bootstrap: """ - The bootstrap object is used to bootstrap the game so that it starts properly. - (It was initially created to avoid circulary imports between the Game and + The bootstrap object is used to bootstrap the game so that it starts + properly. + (It was initially created to avoid circular imports between the Game and Display classes) """ diff --git a/dungeonbattle/enums.py b/dungeonbattle/enums.py index ed4e211..e5f73d9 100644 --- a/dungeonbattle/enums.py +++ b/dungeonbattle/enums.py @@ -3,13 +3,13 @@ from typing import Optional from dungeonbattle.settings import Settings -#This file contains a few useful enumeration classes used elsewhere in the code +# This file contains a few useful enumeration classes used elsewhere in the code class DisplayActions(Enum): """ Display actions options for the callable displayaction Game uses - (it just calls the same action on the display object displayaction refers to) + It just calls the same action on the display object displayaction refers to. """ REFRESH = auto() UPDATE = auto() diff --git a/dungeonbattle/game.py b/dungeonbattle/game.py index 18b8174..a232d50 100644 --- a/dungeonbattle/game.py +++ b/dungeonbattle/game.py @@ -1,7 +1,8 @@ from random import randint -from typing import Any, Optional,Generator +from typing import Any, Optional import json import os +import sys from .entities.player import Player from .enums import GameMode, KeyValues, DisplayActions @@ -111,18 +112,18 @@ class Game: elif option == menus.MainMenuValues.EXIT: sys.exit(0) - def save_state(self) -> dict(): + def save_state(self) -> dict: """ - Saves the game to a dictionnary + Saves the game to a dictionary """ return self.map.save_state() def load_state(self, d: dict) -> None: """ - Loads the game from a dictionnary + Loads the game from a dictionary """ self.map.load_state(d) - + def load_game(self) -> None: """ Loads the game from a file diff --git a/dungeonbattle/interfaces.py b/dungeonbattle/interfaces.py index ae0185d..a1d4475 100644 --- a/dungeonbattle/interfaces.py +++ b/dungeonbattle/interfaces.py @@ -146,7 +146,8 @@ class Map: self.currentx = d["currentx"] self.currenty = d["currenty"] self.map = self.load_dungeon_from_string(d["map"]) - #add entities + # add entities + class Tile(Enum): """ @@ -168,7 +169,8 @@ class Tile(Enum): def char(self, pack: TexturePack) -> str: """ - Translates a Tile to the corresponding character according to the texture pack + Translates a Tile to the corresponding character according + to the texture pack """ return getattr(pack, self.name) @@ -300,7 +302,7 @@ class Entity: d["y"] = self.y return d - def recover_state(self, d : dict) -> None: + def recover_state(self, d: dict) -> None: """ Loads the coordinates of the entity from a dictionnary """ @@ -364,18 +366,19 @@ class FightingEntity(Entity): """ Returns a fighting entities specific attributes """ - return ["maxhealth", "health", "level", "dead", "strength", "intelligence", "charisma", "dexterity", "constitution"] + return ["maxhealth", "health", "level", "dead", "strength", + "intelligence", "charisma", "dexterity", "constitution"] def save_state(self) -> dict: """ - Saves the state of the entity into a dictionnary + Saves the state of the entity into a dictionary """ d = super().save_state() for name in self.keys(): d[name] = self.__getattribute__(name) return d - def recover_state(self, d : dict) -> None: + def recover_state(self, d: dict) -> None: """ Loads the state of an entity from a dictionary """ diff --git a/dungeonbattle/menus.py b/dungeonbattle/menus.py index d17f24c..94c1a7a 100644 --- a/dungeonbattle/menus.py +++ b/dungeonbattle/menus.py @@ -1,4 +1,3 @@ -import sys from enum import Enum from typing import Any, Optional