Linting
This commit is contained in:
parent
be6c949b18
commit
958dcdfee0
|
@ -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)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@ from typing import Optional
|
||||||
|
|
||||||
from dungeonbattle.settings import Settings
|
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):
|
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()
|
||||||
|
|
|
@ -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,18 +112,18 @@ 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)
|
||||||
|
|
||||||
def load_game(self) -> None:
|
def load_game(self) -> None:
|
||||||
"""
|
"""
|
||||||
Loads the game from a file
|
Loads the game from a file
|
||||||
|
|
|
@ -146,7 +146,8 @@ class Map:
|
||||||
self.currentx = d["currentx"]
|
self.currentx = d["currentx"]
|
||||||
self.currenty = d["currenty"]
|
self.currenty = d["currenty"]
|
||||||
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):
|
||||||
"""
|
"""
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
@ -300,7 +302,7 @@ class Entity:
|
||||||
d["y"] = self.y
|
d["y"] = self.y
|
||||||
return d
|
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
|
Loads the coordinates of the entity from a dictionnary
|
||||||
"""
|
"""
|
||||||
|
@ -364,18 +366,19 @@ 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():
|
||||||
d[name] = self.__getattribute__(name)
|
d[name] = self.__getattribute__(name)
|
||||||
return d
|
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
|
Loads the state of an entity from a dictionary
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import sys
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue