This commit is contained in:
Yohann D'ANELLO 2020-11-18 14:56:59 +01:00
parent be6c949b18
commit 958dcdfee0
5 changed files with 20 additions and 16 deletions

View File

@ -5,8 +5,9 @@ from dungeonbattle.term_manager import TermManager
class Bootstrap: class Bootstrap:
""" """
The bootstrap object is used to bootstrap the game so that it starts properly. The bootstrap object is used to bootstrap the game so that it starts
(It was initially created to avoid circulary imports between the Game and properly.
(It was initially created to avoid circular imports between the Game and
Display classes) Display classes)
""" """

View File

@ -9,7 +9,7 @@ from dungeonbattle.settings import Settings
class DisplayActions(Enum): class DisplayActions(Enum):
""" """
Display actions options for the callable displayaction Game uses 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() REFRESH = auto()
UPDATE = auto() UPDATE = auto()

View File

@ -1,7 +1,8 @@
from random import randint from random import randint
from typing import Any, Optional,Generator from typing import Any, Optional
import json import json
import os import os
import sys
from .entities.player import Player from .entities.player import Player
from .enums import GameMode, KeyValues, DisplayActions from .enums import GameMode, KeyValues, DisplayActions
@ -111,15 +112,15 @@ class Game:
elif option == menus.MainMenuValues.EXIT: elif option == menus.MainMenuValues.EXIT:
sys.exit(0) 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() return self.map.save_state()
def load_state(self, d: dict) -> None: def load_state(self, d: dict) -> None:
""" """
Loads the game from a dictionnary Loads the game from a dictionary
""" """
self.map.load_state(d) self.map.load_state(d)

View File

@ -148,6 +148,7 @@ class Map:
self.map = self.load_dungeon_from_string(d["map"]) self.map = self.load_dungeon_from_string(d["map"])
# add entities # add entities
class Tile(Enum): class Tile(Enum):
""" """
The internal representation of the tiles of the map The internal representation of the tiles of the map
@ -168,7 +169,8 @@ class Tile(Enum):
def char(self, pack: TexturePack) -> str: 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) return getattr(pack, self.name)
@ -364,11 +366,12 @@ class FightingEntity(Entity):
""" """
Returns a fighting entities specific attributes 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: 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() d = super().save_state()
for name in self.keys(): for name in self.keys():

View File

@ -1,4 +1,3 @@
import sys
from enum import Enum from enum import Enum
from typing import Any, Optional from typing import Any, Optional