From aac01d8bef2592fee9866a7706621b5b9cebae5c Mon Sep 17 00:00:00 2001 From: eichhornchen Date: Wed, 18 Nov 2020 12:27:59 +0100 Subject: [PATCH] Added documentation for some classes again --- dungeonbattle/entities/items.py | 18 ++++++++++++ dungeonbattle/entities/monsters.py | 15 ++++++++++ dungeonbattle/entities/player.py | 3 ++ dungeonbattle/term_manager.py | 4 +++ resources/example_map_3.txt | 45 ------------------------------ test.py | 17 ----------- 6 files changed, 40 insertions(+), 62 deletions(-) delete mode 100644 resources/example_map_3.txt delete mode 100644 test.py diff --git a/dungeonbattle/entities/items.py b/dungeonbattle/entities/items.py index 4cfd26b..f09e657 100644 --- a/dungeonbattle/entities/items.py +++ b/dungeonbattle/entities/items.py @@ -5,6 +5,9 @@ from ..interfaces import Entity, FightingEntity, Map class Item(Entity): + """ + A class for items + """ held: bool held_by: Optional["Player"] @@ -13,6 +16,9 @@ class Item(Entity): self.held = False def drop(self, y: int, x: int) -> None: + """ + The item is dropped from the inventory onto the floor + """ if self.held: self.held_by.inventory.remove(self) self.held = False @@ -21,6 +27,9 @@ class Item(Entity): self.move(y, x) def hold(self, player: "Player") -> None: + """ + The item is taken from the floor and put into the inventory + """ self.held = True self.held_by = player self.map.remove_entity(self) @@ -28,6 +37,9 @@ class Item(Entity): class Heart(Item): + """ + A heart item to return health to the player + """ name: str = "heart" healing: int = 5 @@ -40,6 +52,9 @@ class Heart(Item): class Bomb(Item): + """ + A bomb item intended to deal damage to ennemies at long range + """ name: str = "bomb" damage: int = 5 exploding: bool @@ -53,6 +68,9 @@ class Bomb(Item): self.exploding = True def act(self, m: Map) -> None: + """ + Special exploding action of the bomb + """ if self.exploding: for e in m.entities: if abs(e.x - self.x) + abs(e.y - self.y) <= 1 and \ diff --git a/dungeonbattle/entities/monsters.py b/dungeonbattle/entities/monsters.py index 0f31f8d..f006ed3 100644 --- a/dungeonbattle/entities/monsters.py +++ b/dungeonbattle/entities/monsters.py @@ -5,6 +5,9 @@ from ..interfaces import FightingEntity, Map class Monster(FightingEntity): + """ + The class for all monsters in the dungeon + """ def __init__(self) -> None: super().__init__() @@ -38,6 +41,9 @@ class Monster(FightingEntity): class Beaver(Monster): + """ + A beaver monster + """ def __init__(self) -> None: super().__init__() name = "beaver" @@ -46,6 +52,9 @@ class Beaver(Monster): class Hedgehog(Monster): + """ + A really mean hedgehog monster + """ def __init__(self) -> None: super().__init__() name = "hedgehog" @@ -54,6 +63,9 @@ class Hedgehog(Monster): class Rabbit(Monster): + """ + A rabbit monster + """ def __init__(self) -> None: super().__init__() name = "rabbit" @@ -62,6 +74,9 @@ class Rabbit(Monster): class TeddyBear(Monster): + """ + A cute teddybear monster + """ def __init__(self) -> None: super().__init__() name = "teddy_bear" diff --git a/dungeonbattle/entities/player.py b/dungeonbattle/entities/player.py index c1bde5e..0c2883b 100644 --- a/dungeonbattle/entities/player.py +++ b/dungeonbattle/entities/player.py @@ -5,6 +5,9 @@ from ..interfaces import FightingEntity class Player(FightingEntity): + """ + The class of the player + """ name = "player" maxhealth: int = 20 strength: int = 5 diff --git a/dungeonbattle/term_manager.py b/dungeonbattle/term_manager.py index a425272..b1f10b1 100644 --- a/dungeonbattle/term_manager.py +++ b/dungeonbattle/term_manager.py @@ -3,6 +3,10 @@ from types import TracebackType class TermManager: # pragma: no cover + """ + The TermManager object initializes the terminal, returns a screen object and + de-initializes the terminal after use + """ def __init__(self): self.screen = curses.initscr() # convert escapes sequences to curses abstraction diff --git a/resources/example_map_3.txt b/resources/example_map_3.txt deleted file mode 100644 index 5a3ae82..0000000 --- a/resources/example_map_3.txt +++ /dev/null @@ -1,45 +0,0 @@ -1 1 -############################################################################################################## -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -#............................................................................................................# -############################################################################################################## diff --git a/test.py b/test.py deleted file mode 100644 index 2129a8d..0000000 --- a/test.py +++ /dev/null @@ -1,17 +0,0 @@ -import json - -class hi: - PLOP = "hello" - PPPP = "ghjk" - - def __init__(self): - self.bl = "zrfcv" - - def prin(self) : - return json.dumps(self.__dict__) - -def f() : - d = hi() - print(d.prin()) - -f()